Delete Collection

Delete collection group and pages
557493
public function deleteCollection()
    {
        // Get dependencies
        $collectionMapper = ($this->container->dataMapper)('CollectionMapper');
        $pageMapper = ($this->container->dataMapper)('PageMapper');
        $pageElementMapper = ($this->container->dataMapper)('PageElementMapper');
        $pageSettingMapper = ($this->container->dataMapper)('PageSettingMapper');

        if (null !== $collectionId = $this->request->getParsedBodyParam('id')) {
            // Get list of pages to delete
            $pages = $pageMapper->findCollectionPagesById($collectionId, false);

            foreach ($pages as $value) {
                $page = $pageMapper->make();
                $page->id = $value->id;
                $pageMapper->delete($page);

                $pageElementMapper->deleteElementsByPageId($value->id);
                $pageSettingMapper->deleteByPageId($value->id);
            }

            // Last, delete collection
            $collection = $collectionMapper->make();
            $collection->id = $collectionId;
            $collectionMapper->delete($collection);
        }

        // Redirect back to show collections
        return $this->redirect('adminCollections');
    }
38127
function destroy(foPairs, index, collection, operand) {
  if (foPairs[index][collection].size === 1) {
    if (containsOne(foPairs[index])) {
      delete foPairs[index];
    } else {
      delete foPairs[index][collection];
    }
  }else {
    foPairs[index][collection].delete(operand);
  }
}
1249688
def group_delete(attribs, dir_info)
      attribs = group_record_name_alternatives(attribs)

      check_critical_attribute( attribs, :record_name )

      command = {action: 'delete', scope: 'Groups', attribute: nil, value: nil}
      user_attrs = attribs.merge(command)

      dscl( user_attrs, dir_info )
    end
979420
def delete_many(cls, documents):
        """"""

        # Ensure all documents have been converted to frames
        frames = cls._ensure_frames(documents)

        all_count = len(documents)
        assert len([f for f in frames if '_id' in f._document]) == all_count, \
                "Can't delete documents without `_id`s"

        # Send delete signal
        signal('delete').send(cls, frames=frames)

        # Prepare the documents to be deleted
        ids = [f._id for f in frames]

        # Delete the documents
        cls.get_collection().delete_many({'_id': {'$in': ids}})

        # Send deleted signal
        signal('deleted').send(cls, frames=frames)
862359
protected void deleteCollection() throws PolicyIndexException {

        // get root collection management service
        Collection rootCol;
        try {
            rootCol = DatabaseManager.getCollection(m_databaseURI + ROOT_COLLECTION_PATH ,m_user, m_password);
            CollectionManagementService mgtService = (CollectionManagementService) rootCol.getService("CollectionManagementService", "1.0");

            // delete the collection
            mgtService.removeCollection(m_collectionName);

            log.debug("Policy collection deleted");
        } catch (XMLDBException e) {
            throw new PolicyIndexException("Error deleting collection " + e.getMessage(), e);
        }
    }
64457
private function adminDeleteGroup()
    {
        $id = arg('group_delete', 'int');
        /* @var Gallery_Entity_Table_Group $table */
        $table = ORM::getTable($this, 'Group');
        $group = $table->find($id);
        $table->delete($group);

        HTTP::goback();
    }
553295
def deleteAllGroups(server):
    '''
    
    '''

    try:
        client, key = _get_session(server)
    except Exception as exc:
        err_msg = 'Exception raised when connecting to spacewalk server ({0}): {1}'.format(server, exc)
        log.error(err_msg)
        return {'Error': err_msg}

    groups = client.systemgroup.listAllGroups(key)

    deleted_groups = []
    failed_groups = []

    for group in groups:
        if client.systemgroup.delete(key, group['name']) == 1:
            deleted_groups.append(group['name'])
        else:
            failed_groups.append(group['name'])

    ret = {'deleted': deleted_groups}
    if failed_groups:
        ret['failed'] = failed_groups
    return ret
659969
def delete(self, request, _id):
        
        _id = deserialize(_id)

        to_delete = self.collection.get({'_id': _id})
        if to_delete:
            deleted = to_delete.delete()

            return Response(
                response=serialize(deleted),
                status=(
                    200 if not all(
                        key in deleted for key in [
                            'error_code', 'error_type', 'error_message'
                        ]
                    ) else 400
                )
            )
        else:
            return Response(
                response=serialize(
                    DocumentNotFoundError(self.collection.__name__, _id)
                ),
                status=404
            )
871599
function(groupName, callback) {
        var url = this.getResourceUrl({ path: '/groups/' + groupName, user: null });
        request.del(this.getSignedResourceUrl('DELETE', url), callback);

        return this;
    }
48705
private void doDelete() throws PageException, SearchException {
	required("index", action, "collection", collection);
	if (type != SearchIndex.TYPE_CUSTOM) required("index", action, "key", key);

	// no type defined
	if (type == -1) {
	    if (query != null) {
		type = SearchIndex.TYPE_CUSTOM;
	    }
	    else {
		Resource file = null;
		try {
		    file = ResourceUtil.toResourceExisting(pageContext, key);
		    pageContext.getConfig().getSecurityManager().checkFileLocation(file);
		}
		catch (ExpressionException e) {}

		if (file != null && file.exists() && file.isFile()) type = SearchIndex.TYPE_FILE;
		else if (file != null && file.exists() && file.isDirectory()) type = SearchIndex.TYPE_PATH;
		else {
		    try {
			new URL(key);
			type = SearchIndex.TYPE_URL;
		    }
		    catch (MalformedURLException e) {}
		}
	    }
	}

	collection.deleteIndex(pageContext, key, type, query);
    }
539834
public function confirmDeleteCollection($args)
    {
        // Get dependencies
        $collectionMapper = ($this->container->dataMapper)('CollectionMapper');
        $pageMapper = ($this->container->dataMapper)('PageMapper');

        $data = $collectionMapper->findById($args['id']);
        $data->pages = $pageMapper->findCollectionPagesById($args['id'], false);

        return $this->render('confirmDeleteCollection.html', $data);
    }
781138
def clear(self):
        
        collection = self.ds.connection(COLLECTION_MANAGED_PROCESS)
        return collection.delete_many(filter={})
886976
def delete_group(self, group_id):
        
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url('group_id', group_id, 'str')
        self._send(http_method='DELETE',
                   location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
                   version='5.0',
                   route_values=route_values)
1123008
def delete(config, group, force):
        """"""
        if not force:
            if not click.confirm(
                    'Confirm that you want to delete group {}'.format(group)):
                sys.exit("Deletion of {} aborted".format(group))

        client = Client()
        client.prepare_connection()
        group_api = API(client)
        group_api.delete(group)
1280785
function deleteGroup(group) {
  if (!runningAsRoot()) return;
  if (!group) throw new Error('You must provide a group to delete');
  if (!groupExists(group)) {
    return;
  }
  const groupdelBin = _safeLocateBinary('groupdel');
  const delgroupBin = _safeLocateBinary('delgroup');

  if (isPlatform('linux')) {
    if (groupdelBin !== null) { // most modern systems
      runProgram(groupdelBin, [group]);
    } else {
      if (_isBusyboxBinary(delgroupBin)) { // busybox-based systems
        runProgram(delgroupBin, [group]);
      } else {
        throw new Error(`Don't know how to delete group ${group} on this strange linux`);
      }
    }
  } else if (isPlatform('osx')) {
    runProgram('dscl', ['.', '-delete', `/Groups/${group}`]);
  } else if (isPlatform('windows')) {
    throw new Error(`Don't know how to delete group ${group} on Windows`);
  } else {
    throw new Error(`Don't know how to delete group ${group} on the current platformp`);
  }
}
1076709
def delete(collection)
    each_resource_with_edit_url(collection) do |resource, edit_url|
      connection.delete(edit_url, 'If-Match' => "*")
    end
    # return count
    collection.size
  end
1297880
public function delete()
    {
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);

        $commands = [];

        // Delete page tree and all their records on this tree
        $topUids = $recordFinder->findUidsOfStyleguideEntryPages();
        if (!empty($topUids)) {
            foreach ($topUids as $topUid) {
                $commands['pages'][(int)$topUid]['delete'] = 1;
            }
        }

        // Delete all the sys_language demo records
        $languageUids = $recordFinder->findUidsOfDemoLanguages();
        if (!empty($languageUids)) {
            foreach ($languageUids as $languageUid) {
                $commands['sys_language'][(int)$languageUid]['delete'] = 1;
            }
        }

        // Delete demo users
        $demoUserUids = $recordFinder->findUidsOfDemoBeUsers();
        if (!empty($demoUserUids)) {
            foreach ($demoUserUids as $demoUserUid) {
                $commands['be_users'][(int)$demoUserUid]['delete'] = 1;
            }
        }

        // Delete demo groups
        $demoGroupUids = $recordFinder->findUidsOfDemoBeGroups();
        if (!empty($demoGroupUids)) {
            foreach ($demoGroupUids as $demoUserGroup) {
                $commands['be_groups'][(int)$demoUserGroup]['delete'] = 1;
            }
        }

        // Do the thing
        if (!empty($commands)) {
            $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
            $dataHandler->deleteTree = true;
            $dataHandler->start([], $commands);
            $dataHandler->process_cmdmap();
            BackendUtility::setUpdateSignal('updatePageTree');
        }

        // Delete demo images in fileadmin again
        $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
        $storage = $storageRepository->findByUid(1);
        $folder = $storage->getRootLevelFolder();
        try {
            $folder = $folder->getSubfolder('styleguide');
            $folder->delete(true);
        } catch (\InvalidArgumentException $e) {
            // No op if folder does not exist
        }
    }