org.apache.chemistry.opencmis.client.api.CmisObject Java Examples

The following examples show how to use org.apache.chemistry.opencmis.client.api.CmisObject. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CmisIntegrationTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
private void deleteAllContent() {
    Session session = createSession();
    Folder rootFolder = session.getRootFolder();
    ItemIterable<CmisObject> children = rootFolder.getChildren();
    for (CmisObject cmisObject : children) {
        if ("cmis:folder".equals(cmisObject.getPropertyValue(PropertyIds.OBJECT_TYPE_ID))) {
            List<String> notDeltedIdList = ((Folder)cmisObject)
                    .deleteTree(true, UnfileObject.DELETE, true);
            if (notDeltedIdList != null && notDeltedIdList.size() > 0) {
                throw new RuntimeException("Cannot empty repo");
            }
        } else {
            cmisObject.delete(true);
        }
    }
    session.getBinding().close();
}
 
Example #2
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<Tree<FileableCmisObject>> getFolderTree(String folderId, int depth)
{
    CmisObject o = session.getObject(folderId);
    if(o instanceof Folder)
    {
        Folder f = (Folder)o;

        OperationContextImpl ctx = new OperationContextImpl();
        List<Tree<FileableCmisObject>> res = f.getFolderTree(depth, ctx);
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a folder");
    }
}
 
Example #3
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public FolderNode getDescendants(String folderId, int depth)
{
    Session session = getCMISSession();

    CmisObject o = session.getObject(folderId);
    if(o instanceof Folder)
    {
        Folder f = (Folder)o;

        OperationContextImpl ctx = new OperationContextImpl();
        List<Tree<FileableCmisObject>> res = f.getDescendants(depth, ctx);
        FolderNode ret = (FolderNode)CMISNode.createNode(f);
        for(Tree<FileableCmisObject> t : res)
        {
            addChildren(ret, t);
        }

        return ret;
    }
    else
    {
        throw new IllegalArgumentException("Folder does not exist or is not a folder");
    }
}
 
Example #4
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<Folder> getObjectParents(String objectId)
{
    CmisObject o = session.getObject(objectId);
    if(o instanceof FileableCmisObject)
    {
        FileableCmisObject f = (FileableCmisObject)o;

        OperationContextImpl ctx = new OperationContextImpl();
        List<Folder> res = f.getParents(ctx);
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a fileable cmis object");
    }
}
 
Example #5
Source File: CMISNode.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static CMISNode createNode(CmisObject o)
{
	CMISNode n = null;

	Map<String, Serializable> properties = CMISNode.getProperties(o.getProperties());

	if(o.getBaseType() instanceof FolderTypeDefinition)
	{
		n = new FolderNode(o.getId(), o.getId(), properties);
	}
	else
	{
		n = new CMISNode(o.getId(), o.getId(), properties);
	}

	return n;
}
 
Example #6
Source File: FolderNode.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void checkChildren(ItemIterable<CmisObject> expectedChildren)
{
	Map<String, FolderNode> expectedFolderNodes = new HashMap<String, FolderNode>();
	Map<String, CMISNode> expectedDocumentNodes = new HashMap<String, CMISNode>();
	for(CmisObject child : expectedChildren)
	{
		CMISNode dn = CMISNode.createNode(child);
		if(dn instanceof FolderNode)
		{
			expectedFolderNodes.put(getBareObjectId(dn.getNodeId()), (FolderNode)dn);
		}
		else
		{
			expectedDocumentNodes.put(getBareObjectId(dn.getNodeId()), dn);
		}
	}
	checkChildrenImpl(expectedFolderNodes, expectedDocumentNodes);
}
 
Example #7
Source File: TestCMIS.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void assertIsPwcProperty(CmisObject pwc, boolean nullExpected)
{
    boolean isPwcFound = false;
    Boolean isPwcValueTrue = null;
    for (Property<?> property : pwc.getProperties())
    {
        if ((null != property) && PropertyIds.IS_PRIVATE_WORKING_COPY.equals(property.getId()))
        {
            isPwcFound = true;
            isPwcValueTrue = property.getValue();
            break;
        }
    }

    if (nullExpected)
    {
        assertTrue(("'" + PropertyIds.IS_PRIVATE_WORKING_COPY + "' property is not null!"), !isPwcFound || (null == isPwcValueTrue));
        return;
    }

    assertTrue(("'" + PropertyIds.IS_PRIVATE_WORKING_COPY + "' property has not been found!"), isPwcFound);
    assertNotNull(("'" + PropertyIds.IS_PRIVATE_WORKING_COPY + "' property value must not be null!"), isPwcValueTrue);
    assertTrue(("'" + PropertyIds.IS_PRIVATE_WORKING_COPY + "' property value must be equal to 'true'!"), isPwcValueTrue);
}
 
Example #8
Source File: CmisSender.java    From iaf with Apache License 2.0 6 votes vote down vote up
private String sendMessageForActionDelete(String message, IPipeLineSession session) throws SenderException, TimeOutException {
	if (StringUtils.isEmpty(message)) {
		throw new SenderException(getLogPrefix() + "input string cannot be empty but must contain a documentId");
	}
	CmisObject object = null;
	try {
		object = getCmisObject(message);
	} catch (CmisObjectNotFoundException e) {
		if (StringUtils.isNotEmpty(getResultOnNotFound())) {
			log.info(getLogPrefix() + "document with id [" + message + "] not found", e);
			return getResultOnNotFound();
		} else {
			throw new SenderException(e);
		}
	}
	if (object.hasAllowableAction(Action.CAN_DELETE_OBJECT)) { //// You can delete
		Document suppDoc = (Document) object;
		suppDoc.delete(true);
		String correlationID = session==null ? null : session.getMessageId();
		return correlationID;

	} else {  //// You can't delete
		throw new SenderException(getLogPrefix() + "Document cannot be deleted");
	}
}
 
Example #9
Source File: CmisSender.java    From iaf with Apache License 2.0 6 votes vote down vote up
private CmisObject getCmisObject(Element queryElement) throws SenderException, CmisObjectNotFoundException {
	String filter = XmlUtils.getChildTagAsString(queryElement, "filter");
	boolean includeAllowableActions = XmlUtils.getChildTagAsBoolean(queryElement, "includeAllowableActions");
	boolean includePolicies = XmlUtils.getChildTagAsBoolean(queryElement, "includePolicies");
	boolean includeAcl = XmlUtils.getChildTagAsBoolean(queryElement, "includeAcl");

	OperationContext operationContext = cmisSession.createOperationContext();

	if (StringUtils.isNotEmpty(filter))
		operationContext.setFilterString(filter);
	operationContext.setIncludeAllowableActions(includeAllowableActions);
	operationContext.setIncludePolicies(includePolicies);
	operationContext.setIncludeAcls(includeAcl);

	String objectIdstr = XmlUtils.getChildTagAsString(queryElement, "objectId");
	if(objectIdstr == null)
		objectIdstr = XmlUtils.getChildTagAsString(queryElement, "id");

	if(objectIdstr != null) {
		return cmisSession.getObject(cmisSession.createObjectId(objectIdstr), operationContext);
	}
	else { //Ok, id can still be null, perhaps its a path?
		String path = XmlUtils.getChildTagAsString(queryElement, "path");
		return cmisSession.getObjectByPath(path, operationContext);
	}
}
 
Example #10
Source File: CmisServiceImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
@HasPermission(type = DefaultPermission.class, action = "clone_content_cmis")
public void cloneContent(@ProtectedResourceId(SITE_ID_RESOURCE_ID) String siteId, String cmisRepoId, String cmisPath,
                         @ProtectedResourceId(PATH_RESOURCE_ID) String studioPath)
        throws StudioPathNotFoundException, CmisRepositoryNotFoundException, CmisUnavailableException, CmisTimeoutException, CmisPathNotFoundException, ServiceLayerException {
    if (!contentService.contentExists(siteId, studioPath))
        throw new StudioPathNotFoundException("Studio repository path does not exist for site " + siteId +
                " (path: " + studioPath + ")");
    List<CmisContentItemTO> toRet = new ArrayList<CmisContentItemTO>();
    DataSourceRepository repositoryConfig = getConfiguration(siteId, cmisRepoId);
    if (repositoryConfig != null) {
        logger.debug("Create new CMIS session");
        Session session = createCMISSession(repositoryConfig);
        if (session != null) {
            String contentPath = Paths.get(repositoryConfig.getBasePath(), cmisPath).toString();
            logger.debug("Find object for CMIS path: " + contentPath);
            CmisObject cmisObject = session.getObjectByPath(contentPath);
            if (cmisObject != null) {
                if (BaseTypeId.CMIS_FOLDER.equals(cmisObject.getBaseTypeId())) {
                    throw new CmisPathNotFoundException();
                } else if (CMIS_DOCUMENT.equals(cmisObject.getBaseTypeId())) {
                    org.apache.chemistry.opencmis.client.api.Document cmisDoc =
                            (org.apache.chemistry.opencmis.client.api.Document)cmisObject;
                    String fileName = cmisDoc.getName();
                    String savePath = studioPath + FILE_SEPARATOR + fileName;
                    ContentStream cs = cmisDoc.getContentStream();
                    logger.debug("Save CMIS file to: " + savePath);
                    contentService.writeContent(siteId, savePath, cs.getStream());
                }
            } else {
                throw new CmisPathNotFoundException();
            }
        } else {
            throw new CmisUnauthorizedException();
        }
    }
}
 
Example #11
Source File: CmisSender.java    From iaf with Apache License 2.0 5 votes vote down vote up
private CmisObject getCmisObject(String message) throws SenderException, CmisObjectNotFoundException {
	if (XmlUtils.isWellFormed(message, "cmis")) {
		try {
			Element queryElement = XmlUtils.buildElement(message);
			return getCmisObject(queryElement);
		} catch (DomBuilderException e) {
			throw new SenderException("unable to build cmis xml from sender input message", e);
		}
	}
	throw new SenderException("unable to build cmis xml from sender input message");
}
 
Example #12
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ObjectId checkoutObject(String objectId)
{
    CmisObject o = getObject(objectId);
    if(o instanceof Document)
    {
        Document d = (Document)o;
        ObjectId res = d.checkOut();
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a document");
    }
}
 
Example #13
Source File: TestCreateAction.java    From iaf with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
	@Override
	public CmisSender createSender() throws ConfigurationException {
		CmisSender sender = spy(new CmisSender());

		sender.setUrl("http://dummy.url");
		sender.setRepository("dummyRepository");
		sender.setUsername("test");
		sender.setPassword("test");
		sender.setKeepSession(false);

		Session cmisSession = mock(Session.class);
		ObjectFactory objectFactory = mock(ObjectFactoryImpl.class);
		doReturn(objectFactory).when(cmisSession).getObjectFactory();

//			GENERIC cmis object
		ObjectId objectId = mock(ObjectIdImpl.class);
		doReturn(objectId).when(cmisSession).createObjectId(anyString());
		CmisObject cmisObject = spy(new CmisTestObject());
		doReturn(cmisObject).when(cmisSession).getObject(any(ObjectId.class));
		doReturn(cmisObject).when(cmisSession).getObject(any(ObjectId.class), any(OperationContext.class));
		
//			CREATE
		Folder folder = mock(FolderImpl.class);
		doReturn(cmisObject).when(folder).createDocument(anyMap(), any(ContentStreamImpl.class), any(VersioningState.class));
		doReturn(folder).when(cmisSession).getRootFolder();
		doReturn(objectId).when(cmisSession).createDocument(anyMap(), any(ObjectId.class), any(ContentStreamImpl.class), any(VersioningState.class));
		doReturn("dummy_id").when(objectId).getId();
		
		try {
			doReturn(cmisSession).when(sender).createCmisSession(any(ParameterValueList.class));
		} catch (SenderException e) {
			//Since we stub the entire session it won't throw exceptions
		}

		return sender;
	}
 
Example #14
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Folder createFolder(String folderId, String name, Map<String, Serializable> properties)
{
    CmisObject o = getObject(folderId);

    if(o instanceof Folder)
    {
        Folder f = (Folder)o;

        if(properties == null)
        {
            properties = new HashMap<String, Serializable>();
        }
        String objectTypeId = (String)properties.get(PropertyIds.OBJECT_TYPE_ID);
        String type = "cmis:folder";
        if(objectTypeId == null)
        {
            objectTypeId = type;
        }
        if(objectTypeId.indexOf(type) == -1)
        {
            StringBuilder sb = new StringBuilder(objectTypeId);
            if(sb.length() > 0)
            {
                sb.append(",");
            }
            sb.append(type);
            objectTypeId = sb.toString();
        }

        properties.put(PropertyIds.NAME, name);
        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);

        Folder res = f.createFolder(properties);
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Parent does not exist or is not a folder");
    }
}
 
Example #15
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Document createDocument(String parentId, String name, Map<String, Serializable> properties, ContentStream contentStream, VersioningState versioningState)
{
    CmisObject o = getObject(parentId);

    if(o instanceof Folder)
    {
        Folder f = (Folder)o;

        if(properties == null)
        {
            properties = new HashMap<String, Serializable>();
        }
        String objectTypeId = (String)properties.get(PropertyIds.OBJECT_TYPE_ID);
        String type = "cmis:document";
        if(objectTypeId == null)
        {
            objectTypeId = type;
        }
        if(objectTypeId.indexOf(type) == -1)
        {
            StringBuilder sb = new StringBuilder(objectTypeId);
            if(sb.length() > 0)
            {
                sb.append(",");
            }
            sb.append(type);
            objectTypeId = sb.toString();
        }

        properties.put(PropertyIds.NAME, name);
        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);

        Document res = f.createDocument(properties, contentStream, versioningState);
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Parent does not exists or is not a folder");
    }
}
 
Example #16
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main1(String[] args) throws IOException {

		Folder root = connect();
		root.getName();

		// cleanup(root, TEST_FOLDER_NAME);
		// Folder newFolder = createFolder(root, TEST_FOLDER_NAME);
		// createDocument(newFolder, TEST_DOCUMENT_NAME_1);
		// createDocument(newFolder, TEST_DOCUMENT_NAME_2);
		// System.out.println("+++ List Folder +++");
		// listFolder(0, newFolder);
		// DeleteDocument(newFolder, "/" + TEST_DOCUMENT_NAME_2);
		// System.out.println("+++ List Folder +++");
		// listFolder(0, newFolder);

		CmisObject object = session.getObjectByPath(TEST_FOLDER_PATH);
		System.out.println(object.getId() + " " + object.getName());
		//
		// object = session.getObjectByPath(TEST_FOLDER_NAME + "/" +
		// TEST_DOCUMENT_NAME_1);
		// System.out.println(object.getId() + " " +
		// object.getProperty(TypeManager.PROP_TITLE).getValues().get(0));

		// checkoutCheckin();

		ItemIterable<QueryResult> result = session
				.query("SELECT cmis:objectId,cmis:name,ldoc:tags FROM cmis:document WHERE ldoc:tags = '12345'", true);
		for (QueryResult r : result) {
			System.out.println("result: " + r.getPropertyById("ldoc:tags"));
		}
	}
 
Example #17
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public FolderNode getChildren(String folderId, int skipCount, int maxItems)
{
    CmisObject o = session.getObject(folderId);
    if(o instanceof Folder)
    {
        Folder f = (Folder)o;
        FolderNode ret = (FolderNode)CMISNode.createNode(f);

        OperationContextImpl ctx = new OperationContextImpl();
        ItemIterable<CmisObject> res = f.getChildren(ctx);
        res.skipTo(skipCount);
        ItemIterable<CmisObject> l = res.getPage(maxItems);
        for(CmisObject c : l)
        {
            CMISNode child = null;
            if(c.getBaseType() instanceof FolderTypeDefinition)
            {
                child = (FolderNode)CMISNode.createNode(c);
                ret.addFolder((FolderNode)child);
            }
            else
            {
                child = CMISNode.createNode(c);
                ret.addNode(child);
            }
        }

        return ret;
    }
    else
    {
        throw new IllegalArgumentException("Folder does not exist or is not a folder");
    }
}
 
Example #18
Source File: CmisIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void testCmisProducer() throws Exception {
    deleteAllContent();

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .to("cmis://http://127.0.0.1:8080/chemistry-opencmis-server-inmemory/atom11");
        }
    });

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();

        String content = "Some content to be store";
        String rootFolderId = createSession().getRootFolder().getId();

        Map<String,Object> headers = new HashMap<>();
        headers.put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
        headers.put(CamelCMISConstants.CMIS_OBJECT_ID, rootFolderId);
        headers.put(CamelCMISConstants.CMIS_ACTION, CamelCMISActions.CREATE);
        headers.put(PropertyIds.NAME, "test.file");

        CmisObject object = template.requestBodyAndHeaders("direct:start", "Some content to be store", headers, CmisObject.class);
        Assert.assertNotNull(object);

        String nodeContent = getDocumentContentAsString(object.getId());
        Assert.assertEquals(content, nodeContent);
    } finally {
        camelctx.close();
    }
}
 
Example #19
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public List<Document> getAllVersions(String objectId)
{
    CmisObject o = getObject(objectId);
    if(o instanceof Document)
    {
        Document d = (Document)o;
        OperationContext ctx = new OperationContextImpl();
        List<Document> res = d.getAllVersions(ctx);
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a document");
    }
}
 
Example #20
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void updateProperties(String objectId, Map<String, ?> properties, boolean refresh)
{
    CmisObject o = getObject(objectId);
    if(o != null)
    {
        o.updateProperties(properties, refresh);
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist");
    }
}
 
Example #21
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CmisObject getObject(String objectId)
{
    RequestContext rc = getRequestContext();
    OperationContext ctx = rc.getCmisOperationCtxOverride();
    if(ctx == null)
    {
         ctx = new OperationContextImpl();
    }

    CmisObject res = session.getObject(objectId, ctx);
    return res;
}
 
Example #22
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Delete test document
 * 
 * @param target
 * @param delDocName
 */
private static void deleteDocument(Folder target, String delDocName) {
	try {
		CmisObject object = session.getObjectByPath(target.getPath() + delDocName);
		Document delDoc = (Document) object;
		delDoc.delete(true);
	} catch (CmisObjectNotFoundException e) {
		System.err.println("Document is not found: " + delDocName);
	}
}
 
Example #23
Source File: AbstractE2EFunctionalTest.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
private FileModel getCustomModel(String fileName)
{
    FileModel customModel = null;

    try
    {
        if ((fileName != null) && (fileName.endsWith("-model.xml")))

        {
            Session session = contentService.getCMISSession(dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword());

            CmisObject modelInRepo = session.getObjectByPath(String.format("/Data Dictionary/Models/%s", fileName));

            if (modelInRepo != null)
            {
                customModel = new FileModel(modelInRepo.getName());
                customModel.setNodeRef(modelInRepo.getId());
                customModel.setNodeRef(customModel.getNodeRefWithoutVersion());
                customModel.setCmisLocation(String.format("/Data Dictionary/Models/%s", fileName));
                LOGGER.info("Custom Model file: " + customModel.getCmisLocation());
            }
            else
            {
                LOGGER.info("Custom Content Model [{}] is not available under [/Data Dictionary/Models/] location", fileName);
            }
        }
    }
    catch (Exception e)
    {
        LOGGER.warn("Error Getting Custom Model: " + fileName, e);
    }

    return customModel;
}
 
Example #24
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 
 * @param target
 */
private static void listFolder(int depth, Folder target) {
	String indent = StringUtils.repeat("\t", depth);
	for (Iterator<CmisObject> it = target.getChildren().iterator(); it.hasNext();) {
		CmisObject o = it.next();
		if (BaseTypeId.CMIS_DOCUMENT.equals(o.getBaseTypeId())) {
			System.out.println(indent + "[Docment] " + o.getName());
		} else if (BaseTypeId.CMIS_FOLDER.equals(o.getBaseTypeId())) {
			System.out.println(indent + "[Folder] " + o.getName());
			listFolder(++depth, (Folder) o);
		}
	}

}
 
Example #25
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Clean up test folder before executing test
 * 
 * @param target
 * @param delFolderName
 */
private static void cleanup(Folder target, String delFolderName) {
	try {
		CmisObject object = session.getObjectByPath(target.getPath() + delFolderName);
		Folder delFolder = (Folder) object;
		delFolder.deleteTree(true, UnfileObject.DELETE, true);
	} catch (CmisObjectNotFoundException e) {
		System.err.println("No need to clean up.");
	}
}
 
Example #26
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void deleteContent(String objectId, boolean refresh)
{
    CmisObject o = getObject(objectId);

    if(o instanceof Document)
    {
        Document d = (Document)o;
        d.deleteContentStream(refresh);
    }
    else
    {
        throw new IllegalArgumentException("Object does not exists or is not a document");
    }
}
 
Example #27
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ContentData getContent(String objectId) throws IOException
{
    CmisObject o = getObject(objectId);
    if(o instanceof Document)
    {
        Document d = (Document)o;
        ContentStream res = d.getContentStream();
        ContentData c = new ContentData(res);
        return c;
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a document");
    }
}
 
Example #28
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void putContent(String objectId, String filename, BigInteger length, String mimetype, InputStream content, boolean overwrite)
{
    CmisObject o = getObject(objectId);
    if(o instanceof Document)
    {
        Document d = (Document)o;
        ContentStream contentStream = new ContentStreamImpl(filename, length, mimetype, content);
        try
        {
            d.setContentStream(contentStream, overwrite);
        }
        finally
        {
            try
            {
                contentStream.getStream().close();
            }
            catch (Exception e)
            {
            }
        }
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a document");
    }
}
 
Example #29
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public List<String> removeTree(String objectId, boolean allVersions, UnfileObject unfile, boolean continueOnFailure)
{
    CmisObject o = getObject(objectId);
    if(o instanceof Folder)
    {
        Folder f = (Folder)o;
        List<String> res = f.deleteTree(allVersions, unfile, continueOnFailure);
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a folder");
    }
}
 
Example #30
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void removeAllVersions(String objectId)
{
    CmisObject o = getObject(objectId);
    if(o instanceof Document)
    {
        Document d = (Document)o;
        d.deleteAllVersions();
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a document");
    }
}