Package org.apache.chemistry.opencmis.commons.impl.dataobjects

Examples of org.apache.chemistry.opencmis.commons.impl.dataobjects.FailedToDeleteDataImpl


        // make the call
        HttpUtils.Response resp = HttpUtils.invokeDELETE(url, getSession());

        // check response code
        if ((resp.getResponseCode() == 200) || (resp.getResponseCode() == 202) || (resp.getResponseCode() == 204)) {
            return new FailedToDeleteDataImpl();
        }

        throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
    }
View Full Code Here


    public static FailedToDeleteData convert(DeleteTreeResponse.FailedToDelete failedToDelete) {
        if (failedToDelete == null) {
            return null;
        }

        FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();

        result.setIds(failedToDelete.getObjectIds());

        // handle extensions
        convertExtension(failedToDelete, result);

        return result;
View Full Code Here

        // make the call
        HttpUtils.Response resp = HttpUtils.invokeDELETE(url, getSession());

        // check response code
        if ((resp.getResponseCode() == 200) || (resp.getResponseCode() == 202) || (resp.getResponseCode() == 204)) {
            return new FailedToDeleteDataImpl();
        }

        throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
    }
View Full Code Here

            Boolean allVersions, UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {

        LOG.debug("start deleteTree()");
        StoredObject so = validator.deleteTree(context, repositoryId, folderId, allVersions, unfileObjects, extension);
        List<String> failedToDeleteIds = new ArrayList<String>();
        FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();

        if (null == allVersions)
            allVersions = true;
        if (null == unfileObjects)
            unfileObjects = UnfileObject.DELETE;
        if (null == continueOnFailure)
            continueOnFailure = false;

        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);

        if (null == so)
            throw new CmisInvalidArgumentException("Cannot delete object with id  " + folderId + ". Object does not exist.");

        if (!(so instanceof Folder))
            throw new CmisInvalidArgumentException("deleteTree can only be invoked on a folder, but id " + folderId
                    + " does not refer to a folder");

        if (unfileObjects == UnfileObject.UNFILE)
            throw new CmisNotSupportedException("This repository does not support unfile operations.");

        // check if it is the root folder
        if (folderId.equals(objectStore.getRootFolder().getId()))
            throw new CmisNotSupportedException("You can't delete a root folder");

        // recursively delete folder
        deleteRecursive(objectStore, (Folder) so, continueOnFailure, allVersions, failedToDeleteIds);

        result.setIds(failedToDeleteIds);
        LOG.debug("stop deleteTree()");
        return result;
    }
View Full Code Here

    /**
     * See CMIS 1.0 section 2.2.4.15 deleteTree
     */
    public FailedToDeleteDataImpl deleteTree() {
        FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();

        String id = getId();
        try {
            Node node = getNode();
            if (hasCheckOuts(node)) {
                result.setIds(Collections.<String>singletonList(id));               
            }
            else {
                Session session = node.getSession();
                node.remove();
                session.save();
                result.setIds(Collections.<String>emptyList());
            }
        }
        catch (RepositoryException e) {
            result.setIds(Collections.singletonList(id));
        }

        return result;
    }
View Full Code Here

    public static FailedToDeleteData convertFailedToDelete(final Map<String, Object> json) {
        if (json == null) {
            return null;
        }

        FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();

        List<String> ids = new ArrayList<String>();
        List<Object> jsonIds = getList(json.get(JSON_FAILEDTODELETE_ID));

        if (jsonIds != null) {
            for (Object obj : jsonIds) {
                if (obj != null) {
                    ids.add(obj.toString());
                }
            }
        }

        result.setIds(ids);

        convertExtension(json, result, FAILEDTODELETE_KEYS);

        return result;
    }
View Full Code Here

    public static FailedToDeleteData convert(DeleteTreeResponse.FailedToDelete failedToDelete) {
        if (failedToDelete == null) {
            return null;
        }

        FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();

        result.setIds(failedToDelete.getObjectIds());

        // handle extensions
        convertExtension(failedToDelete, result);

        return result;
View Full Code Here

        // make the call
        Response resp = getHttpInvoker().invokeDELETE(url, getSession());

        // check response code
        if (resp.getResponseCode() == 200 || resp.getResponseCode() == 202 || resp.getResponseCode() == 204) {
            return new FailedToDeleteDataImpl();
        }

        // If the server returned an internal server error, get the remaining
        // children of the folder. We only retrieve the first level, since
        // getDescendants() is not supported by all repositories.
        if (resp.getResponseCode() == 500) {
            link = loadLink(repositoryId, folderId, Constants.REL_DOWN, Constants.MEDIATYPE_CHILDREN);

            if (link != null) {
                url = new UrlBuilder(link);
                // we only want the object ids
                url.addParameter(Constants.PARAM_FILTER, "cmis:objectId");
                url.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, false);
                url.addParameter(Constants.PARAM_RELATIONSHIPS, IncludeRelationships.NONE);
                url.addParameter(Constants.PARAM_RENDITION_FILTER, "cmis:none");
                url.addParameter(Constants.PARAM_PATH_SEGMENT, false);
                // 1000 children should be enough to indicate a problem
                url.addParameter(Constants.PARAM_MAX_ITEMS, 1000);
                url.addParameter(Constants.PARAM_SKIP_COUNT, 0);

                // read and parse
                resp = read(url);
                AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

                // prepare result
                FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
                List<String> ids = new ArrayList<String>();
                result.setIds(ids);

                // get the children ids
                for (AtomEntry entry : feed.getEntries()) {
                    ids.add(entry.getId());
                }
View Full Code Here

        boolean cof = (continueOnFailure == null ? false : continueOnFailure.booleanValue());

        // get the file or folder
        File file = getFile(folderId);

        FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
        result.setIds(new ArrayList<String>());

        // if it is a folder, remove it recursively
        if (file.isDirectory()) {
            deleteFolder(file, cof, result);
        } else {
            getPropertiesFile(file).delete();
            if (!file.delete()) {
                result.getIds().add(getId(file));
            }
        }

        return result;
    }
View Full Code Here

        // make the call
        Response resp = getHttpInvoker().invokeDELETE(url, getSession());

        // check response code
        if (resp.getResponseCode() == 200 || resp.getResponseCode() == 202 || resp.getResponseCode() == 204) {
            return new FailedToDeleteDataImpl();
        }

        // If the server returned an internal server error, get the remaining
        // children of the folder. We only retrieve the first level, since
        // getDescendants() is not supported by all repositories.
        if (resp.getResponseCode() == 500) {
            link = loadLink(repositoryId, folderId, Constants.REL_DOWN, Constants.MEDIATYPE_CHILDREN);

            if (link != null) {
                url = new UrlBuilder(link);
                // we only want the object ids
                url.addParameter(Constants.PARAM_FILTER, "cmis:objectId");
                url.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, false);
                url.addParameter(Constants.PARAM_RELATIONSHIPS, IncludeRelationships.NONE);
                url.addParameter(Constants.PARAM_RENDITION_FILTER, "cmis:none");
                url.addParameter(Constants.PARAM_PATH_SEGMENT, false);
                // 1000 children should be enough to indicate a problem
                url.addParameter(Constants.PARAM_MAX_ITEMS, 1000);
                url.addParameter(Constants.PARAM_SKIP_COUNT, 0);

                // read and parse
                resp = read(url);
                AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

                // prepare result
                FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
                List<String> ids = new ArrayList<String>();
                result.setIds(ids);

                // get the children ids
                for (AtomEntry entry : feed.getEntries()) {
                    ids.add(entry.getId());
                }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.impl.dataobjects.FailedToDeleteDataImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.