org.apache.chemistry.opencmis.client.api.ObjectId Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.client.api.ObjectId.
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: PublicApiClient.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public ObjectId createRelationship(String sourceObjectId, String targetObjectId) { Map<String, Serializable> relProps = new HashMap<String, Serializable>(); relProps.put("cmis:sourceId", sourceObjectId); relProps.put("cmis:targetId", targetObjectId); relProps.put("cmis:objectTypeId", "cmis:relationship"); ObjectId res = session.createRelationship(relProps); return res; }
Example #2
Source File: PublicApiClient.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
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 #3
Source File: TestCreateAction.java From iaf with Apache License 2.0 | 5 votes |
@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 #4
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 5 votes |
@Override public List<ObjectId> getPolicyIds() { List<ObjectId> policies = new ArrayList<ObjectId>(); ObjectId objectId = mock(ObjectId.class); when(objectId.getId()).thenReturn("dummyObjectId"); policies.add(objectId); return policies; }
Example #5
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public void removePolicy(ObjectId policyId, boolean refresh) { // TODO Auto-generated method stub }
Example #6
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public Document copy(ObjectId targetFolderId, Map<String, ?> properties, VersioningState versioningState, List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs, OperationContext context) { // TODO Auto-generated method stub return null; }
Example #7
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public Document copy(ObjectId targetFolderId) { // TODO Auto-generated method stub return null; }
Example #8
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId checkIn(boolean major, Map<String, ?> properties, ContentStream contentStream, String checkinComment) { // TODO Auto-generated method stub return null; }
Example #9
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId checkIn(boolean major, Map<String, ?> properties, ContentStream contentStream, String checkinComment, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces) { // TODO Auto-generated method stub return null; }
Example #10
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId checkOut() { // TODO Auto-generated method stub return null; }
Example #11
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId deleteContentStream(boolean refresh) { // TODO Auto-generated method stub return null; }
Example #12
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId appendContentStream(ContentStream contentStream, boolean isLastChunk, boolean refresh) { // TODO Auto-generated method stub return null; }
Example #13
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId setContentStream(ContentStream contentStream, boolean overwrite, boolean refresh) { // TODO Auto-generated method stub return null; }
Example #14
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public void removeFromFolder(ObjectId folderId) { // TODO Auto-generated method stub }
Example #15
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public void addToFolder(ObjectId folderId, boolean allVersions) { // TODO Auto-generated method stub }
Example #16
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public FileableCmisObject move(ObjectId sourceFolderId, ObjectId targetFolderId, OperationContext context) { // TODO Auto-generated method stub return null; }
Example #17
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public FileableCmisObject move(ObjectId sourceFolderId, ObjectId targetFolderId) { // TODO Auto-generated method stub return null; }
Example #18
Source File: SampleClient.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
private static void checkoutCheckin() throws IOException { // Folder root = connect("admin", "admin"); // Folder root = connect("manager", "12345678"); // user solely in group // author Folder root = connect("admin", "12345678"); // user in groups // author and // admin root.getName(); CmisObject object = session.getObjectByPath(TEST_FOLDER_PATH); System.out.println(object.getId() + " " + object.getName()); object = session.getObjectByPath(TEST_FOLDER_PATH + "/" + TEST_DOCUMENT_NAME_1); System.out.println(object.getId() + " " + object.getProperty(PropertyIds.NAME).getValues().get(0)); Document pwc = (Document) object; ObjectId oid = pwc.checkOut(); // default values if the document has no content String filename = "test.txt"; String mimetype = "text/plain; fileNameCharset=UTF-8"; File myFile = new File("C:/tmp/test.txt"); FileInputStream fis = new FileInputStream(myFile); byte[] buf = IOUtils.toByteArray(fis); ByteArrayInputStream input = new ByteArrayInputStream(buf); ContentStream contentStream = session.getObjectFactory().createContentStream(filename, buf.length, mimetype, input); boolean major = false; // Check in the pwc try { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("cmis:name","test-doc.txt"); pwc.checkIn(major, properties, contentStream, "minor version"); System.out.println("checkin completed!"); } catch (RuntimeException e) { e.printStackTrace(); System.out.println("checkin failed, trying to cancel the checkout"); try { pwc.cancelCheckOut(); // this can also generate a permission // exception System.out.println("checkout status canceled"); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
Example #19
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public void removePolicy(ObjectId... policyIds) { // TODO Auto-generated method stub }
Example #20
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public void applyPolicy(ObjectId policyId, boolean refresh) { // TODO Auto-generated method stub }
Example #21
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public void applyPolicy(ObjectId... policyIds) { // TODO Auto-generated method stub }
Example #22
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId rename(String newName, boolean refresh) { // TODO Auto-generated method stub return null; }
Example #23
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId updateProperties(Map<String, ?> properties, List<String> addSecondaryTypeIds, List<String> removeSecondaryTypeIds, boolean refresh) { // TODO Auto-generated method stub return null; }
Example #24
Source File: CmisTestObject.java From iaf with Apache License 2.0 | 4 votes |
@Override public ObjectId updateProperties(Map<String, ?> properties, boolean refresh) { // TODO Auto-generated method stub return null; }
Example #25
Source File: TestBindingTypes.java From iaf with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public CmisSender createSender() throws ConfigurationException { CmisSender sender = spy(new CmisSender()); sender.setUrl("http://dummy.url"); sender.setRepository("dummyRepository"); sender.setFileContentSessionKey("fileContent"); sender.setFileNameSessionKey("my-file"); sender.setUsername("test"); sender.setPassword("test"); sender.setKeepSession(false); byte[] base64 = Base64.encodeBase64("dummy data".getBytes()); session.put("fileContent", new String(base64)); HttpServletResponse response = mock(HttpServletResponse.class); session.put(IPipeLineSession.HTTP_RESPONSE_KEY, response); 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)); // GET OperationContext operationContext = mock(OperationContextImpl.class); doReturn(operationContext).when(cmisSession).createOperationContext(); // CREATE Folder folder = mock(FolderImpl.class); doReturn(cmisObject).when(folder).createDocument(anyMap(), any(ContentStreamImpl.class), any(VersioningState.class)); doReturn(folder).when(cmisSession).getRootFolder(); // FIND ItemIterable<QueryResult> query = new EmptyItemIterable<QueryResult>(); doReturn(query).when(cmisSession).query(anyString(), anyBoolean(), any(OperationContext.class)); 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 #26
Source File: CmisUtils.java From iaf with Apache License 2.0 | 4 votes |
public static void cmisObject2Xml(XmlBuilder cmisXml, CmisObject object) { if(object.getProperties() != null) { XmlBuilder propertiesXml = new XmlBuilder("properties"); for (Iterator<Property<?>> it = object.getProperties().iterator(); it.hasNext();) { Property<?> property = (Property<?>) it.next(); propertiesXml.addSubElement(CmisUtils.getPropertyXml(property)); } cmisXml.addSubElement(propertiesXml); } if(object.getAllowableActions() != null) { XmlBuilder allowableActionsXml = new XmlBuilder("allowableActions"); Set<Action> actions = object.getAllowableActions().getAllowableActions(); for (Action action : actions) { XmlBuilder actionXml = new XmlBuilder("action"); actionXml.setValue(action.value()); allowableActionsXml.addSubElement(actionXml); } cmisXml.addSubElement(allowableActionsXml); } if(object.getAcl() != null) { XmlBuilder isExactAclXml = new XmlBuilder("isExactAcl"); isExactAclXml.setValue(object.getAcl().isExact().toString()); cmisXml.addSubElement(isExactAclXml); } List<ObjectId> policies = object.getPolicyIds(); if(policies != null) { XmlBuilder policiesXml = new XmlBuilder("policyIds"); for (ObjectId objectId : policies) { XmlBuilder policyXml = new XmlBuilder("policyId"); policyXml.setValue(objectId.getId()); policiesXml.addSubElement(policyXml); } cmisXml.addSubElement(policiesXml); } XmlBuilder relationshipsXml = new XmlBuilder("relationships"); List<Relationship> relationships = object.getRelationships(); if(relationships != null) { for (Relationship relation : relationships) { XmlBuilder relationXml = new XmlBuilder("relation"); relationXml.setValue(relation.getId()); relationshipsXml.addSubElement(relationXml); } } cmisXml.addSubElement(relationshipsXml); }
Example #27
Source File: TestCMIS.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
/** * <p>Related to REPO-4613.</p> * <p>A checkout should not lock the private working copy.</p> * <p>Adding aspects or properties to a pwc should remain possible after a checkout.</p> * @throws Exception */ @Test public void aPrivateCopyShouldAllowTheAdditionOfAspects_CMIS_1_1_Version() throws Exception { final String aspectName = "P:cm:summarizable"; final String propertyName = "cm:summary"; final String propertyValue = "My summary"; final TestNetwork network1 = getTestFixture().getRandomNetwork(); String username = "user" + System.currentTimeMillis(); PersonInfo personInfo = new PersonInfo(username, username, username, TEST_PASSWORD, null, null, null, null, null, null, null); TestPerson person1 = network1.createUser(personInfo); String person1Id = person1.getId(); final String siteName = "site" + System.currentTimeMillis(); TenantUtil.runAsUserTenant(new TenantRunAsWork<NodeRef>() { @Override public NodeRef doWork() throws Exception { SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, SiteVisibility.PRIVATE); TestSite site = repoService.createSite(null, siteInfo); String name = GUID.generate(); NodeRef folderNodeRef = repoService.createFolder(site.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), name); return folderNodeRef; } }, person1Id, network1.getId()); // Create a document... publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id)); CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_11); Folder folder = (Folder) cmisSession.getObjectByPath(String.format(DOCUMENT_LIBRARY_PATH_PATTERN, siteName)); String fileName = String.format(TEST_DOCUMENT_NAME_PATTERN, GUID.generate()); // Create a document... publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id)); HashMap<String, Object> props = new HashMap<>(); props.put(PropertyIds.OBJECT_TYPE_ID, TYPE_CMIS_DOCUMENT); props.put(PropertyIds.NAME, fileName); final ContentStream cs = new ContentStreamImpl(fileName, "text/plain", "This is just a test"); final Document document = folder.createDocument(props, cs, VersioningState.MAJOR); ObjectId pwcObjectId = document.checkOut(); CmisObject cmisObject = cmisSession.getObject(pwcObjectId.getId()); final Document pwc = (Document) cmisObject; List<Object> aspects = pwc.getProperty(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues(); // asserts that we have the right aspect for the private working copy assertTrue(aspects.contains("P:cm:workingcopy")); aspects.add(aspectName); props = new HashMap<>(); props.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects); props.put(propertyName, propertyValue); pwc.updateProperties(props); final ObjectId id = pwc.checkIn(true, null, null, "CheckIn comment"); Document checkedInDocument = (Document) cmisSession.getObject(id.getId()); List<String> secondaryTypeIds = checkedInDocument.getPropertyValue(PropertyIds.SECONDARY_OBJECT_TYPE_IDS); // asserts the new aspect has been added to the original copy, via the check in from the private copy assertTrue(secondaryTypeIds.contains(aspectName)); assertEquals(checkedInDocument.getPropertyValue(propertyName), propertyValue); }
Example #28
Source File: CMISDataCreatorTest.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void run() { Session session = getSession(""+id+id+id, ""+id+id+id); CmisObject object = session.getObjectByPath(path); Map<String, Object> baseProps = new HashMap<String, Object>(); baseProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); baseProps.put(PropertyIds.NAME, "Thread"+id); ObjectId base = session.createFolder(baseProps, object); for(int i = 0; i < 100; i++) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); properties.put(PropertyIds.NAME, "Folder-"+i); ObjectId folder = session.createFolder(properties, base); System.out.println("Thread "+id +" @Folder "+i); for(int j = 0; j < 1000; j++) { Map<String, Object> folderProps = new HashMap<String, Object>(); folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); folderProps.put(PropertyIds.NAME, "Folder-"+i); ObjectId child = session.createFolder(folderProps, folder); // Map<String, Object> docProps = new HashMap<String, Object>(); // docProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); // docProps.put(PropertyIds.NAME, "Doc-"+j); // // ContentStreamImpl contentSream = new ContentStreamImpl(); // contentSream.setFileName(GUID.generate()); // contentSream.setLength(BigInteger.valueOf(10)); // contentSream.setMimeType("text/plain"); // contentSream.setStream(new StringInputStream("abcdefghij")); // // ObjectId document = session.createDocument(docProps, folder, contentSream, VersioningState.MAJOR); if(j % 20 == 0) { System.out.println(id+" @ "+j); } } } }