org.apache.chemistry.opencmis.commons.server.CmisService Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.server.CmisService.
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: CmisServiceFactory.java From document-management-system with GNU General Public License v2.0 | 6 votes |
@Override public CmisService getService(CallContext context) { // authentication can go here String user = context.getUsername(); String password = context.getPassword(); log.debug("User: {}", user); log.debug("Password: {}", password); // if the authentication fails, throw a CmisPermissionDeniedException // create a new service object (can also be pooled or stored in a ThreadLocal) CmisServiceImpl service = new CmisServiceImpl(repository); // add the CMIS service wrapper // (The wrapper catches invalid CMIS requests and sets default values // for parameters that have not been provided by the client.) CmisServiceWrapper<CmisService> wrapperService = new CmisServiceWrapper<CmisService>(service, DEFAULT_MAX_ITEMS_TYPES, DEFAULT_DEPTH_TYPES, DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS); // hand over the call context to the service object service.setCallContext(context); return wrapperService; }
Example #2
Source File: ServiceFactory.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
@Override public CmisService getService(CallContext context) { Session session = SessionManager.get().getSession( (HttpServletRequest) context.get(CallContext.HTTP_SERVLET_REQUEST)); CmisService wrapperService = null; if (session != null) { if (context.getRepositoryId() != null) session.getDictionary().put(KEY_REPO_ID, context.getRepositoryId()); log.debug("Using session " + session.getSid() + " for user " + session.getUsername()); wrapperService = new CmisServiceWrapper<LDCmisService>(new LDCmisService(context, session.getSid()), DEFAULT_MAX_ITEMS_TYPES, BigInteger.valueOf(Context.get().getProperties() .getInt("cmis.maxitems", 200)), DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS); } else { log.warn("No session was found for this request"); } return wrapperService; }
Example #3
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private <T extends Object> T withCmisService(CmisServiceCallback<T> callback, CmisVersion cmisVersion) { CmisService cmisService = null; try { CallContext context = new SimpleCallContext("admin", "admin", cmisVersion); cmisService = factory.getService(context); T ret = callback.execute(cmisService); return ret; } finally { if(cmisService != null) { cmisService.close(); } } }
Example #4
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void setProperiesToObject(CmisService cmisService, String repositoryId, String objectIdStr, String propertyStr, BigInteger bigIntValue) throws CmisConstraintException{ Properties properties = cmisService.getProperties(repositoryId, objectIdStr, null, null); PropertyIntegerImpl pd = (PropertyIntegerImpl)properties.getProperties().get(propertyStr); pd.setValue(bigIntValue); Collection<PropertyData<?>> propsList = new ArrayList<PropertyData<?>>(); propsList.add(pd); Properties newProps = new PropertiesImpl(propsList); cmisService.updateProperties(repositoryId, new Holder<String>(objectIdStr), null, newProps, null); }
Example #5
Source File: RepositoryConnectorFactory.java From iaf with Apache License 2.0 | 5 votes |
@Override public CmisService getService(CallContext context) { LOG.debug("Retrieve proxy repository service"); CallContextAwareCmisService service = threadLocalService.get(); if (service == null) { service = new ConformanceCmisServiceWrapper(createService(context)); threadLocalService.set(service); LOG.info("Create service wrapper"); } service.setCallContext(context); //Update the CallContext return service; }
Example #6
Source File: ContentCmisServiceFactory.java From spring-content with Apache License 2.0 | 5 votes |
@Override public CmisService getService(CallContext context) { CallContextAwareCmisService service = threadLocalService.get(); if (service == null) { service = new ContentCmisService(config, bridge); threadLocalService.set(service); } service.setCallContext(context); return service; }
Example #7
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void assertVersions(final NodeRef nodeRef, final String expectedVersionLabel, final VersionType expectedVersionType) { transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>() { @Override public List<Void> execute() throws Throwable { assertTrue("Node should be versionable", nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)); Version version = versionService.getCurrentVersion(nodeRef); assertNotNull(version); assertEquals(expectedVersionLabel, version.getVersionLabel()); assertEquals(expectedVersionType, version.getVersionType()); return null; } }); withCmisService(new CmisServiceCallback<Void>() { @Override public Void execute(CmisService cmisService) { String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId(); ObjectData data = cmisService.getObjectOfLatestVersion(repositoryId, nodeRef.toString(), null, Boolean.FALSE, null, null, null, null, null, null, null); assertNotNull(data); PropertyData<?> prop = data.getProperties().getProperties().get(PropertyIds.VERSION_LABEL); Object versionLabelCmisValue = prop.getValues().get(0); assertEquals(expectedVersionLabel, versionLabelCmisValue); return null; } }, CmisVersion.CMIS_1_1); }
Example #8
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * ACE-33 * * Cmis Item support */ @Test public void testItems() { withCmisService(new CmisServiceCallback<String>() { @Override public String execute(CmisService cmisService) { List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); assertTrue(repositories.size() > 0); RepositoryInfo repo = repositories.get(0); String repositoryId = repo.getId(); TypeDefinition def = cmisService.getTypeDefinition(repositoryId, "cmis:item", null); assertNotNull("the cmis:item type is not defined", def); @SuppressWarnings("unused") TypeDefinition p = cmisService.getTypeDefinition(repositoryId, "I:cm:person", null); assertNotNull("the I:cm:person type is not defined", def); ObjectList result = cmisService.query(repositoryId, "select * from cm:person", Boolean.FALSE, Boolean.TRUE, IncludeRelationships.NONE, "", BigInteger.TEN, BigInteger.ZERO, null); assertTrue("", result.getNumItems().intValue() > 0); return ""; }; }, CmisVersion.CMIS_1_1); }
Example #9
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * ALF-20389 Test Alfresco cmis stream interceptor that checks content stream for mimetype. Only ContentStreamImpl extensions should take palace. */ @Test public void testGetRepositoryInfos() { boolean cmisEx = false; List<RepositoryInfo> infoDataList = null; try { infoDataList = withCmisService(new CmisServiceCallback<List<RepositoryInfo>>() { @Override public List<RepositoryInfo> execute(CmisService cmisService) { ExtensionDataImpl result = new ExtensionDataImpl(); List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>(); result.setExtensions(extensions); return cmisService.getRepositoryInfos(result); } }); } catch (CmisRuntimeException e) { cmisEx = true; } assertNotNull(cmisEx ? "CmisRuntimeException was thrown. Please, take a look on ALF-20389" : "No CMIS repository information was retrieved", infoDataList); }
Example #10
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Alternative constructor. * * @param service * the {@link CmisService} object, not {@code null} */ public ConformanceCmisServiceWrapper(CmisService service, BigInteger defaultTypesMaxItems, BigInteger defaultTypesDepth, BigInteger defaultMaxItems, BigInteger defaultDepth) { super(service); this.defaultTypesMaxItems = defaultTypesMaxItems; this.defaultTypesDepth = defaultTypesDepth; this.defaultMaxItems = defaultMaxItems; this.defaultDepth = defaultDepth; }
Example #11
Source File: AbstractCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public AbstractCmisServiceWrapper(CmisService service) { if (service == null) { throw new IllegalArgumentException("Service must be set!"); } this.service = service; }
Example #12
Source File: AlfrescoLocalCmisServiceFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CmisService getService(CallContext context) { ConformanceCmisServiceWrapper wrapperService = THREAD_LOCAL_SERVICE.get(); if (wrapperService == null) { AlfrescoCmisService cmisService = new AlfrescoCmisServiceImpl(CMIS_CONNECTOR); wrapperService = new ConformanceCmisServiceWrapper(cmisService, CMIS_CONNECTOR.getTypesDefaultMaxItems(), CMIS_CONNECTOR.getTypesDefaultDepth(), CMIS_CONNECTOR.getObjectsDefaultMaxItems(), CMIS_CONNECTOR.getObjectsDefaultDepth()); THREAD_LOCAL_SERVICE.set(wrapperService); } ((AlfrescoCmisService)wrapperService.getWrappedService()).open(context); return wrapperService; }
Example #13
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private Holder<String> getHolderOfObjectOfLatestVersion(CmisService cmisService, String repositoryId, Holder<String> currentHolder) { ObjectData oData = cmisService.getObjectOfLatestVersion(repositoryId, currentHolder.getValue(), null, Boolean.FALSE, null, null, null, null, null, null, null); return new Holder<String>(oData.getId()); }
Example #14
Source File: OpenCmisLocalTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public CmisService getService(CallContext context) { return serviceFactory.getService(context); }
Example #15
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * MNT-13529: Just-installed Alfresco does not return a CMIS latestChangeLogToken * * @throws Exception */ @Test public void testMNT13529() throws Exception { setupAudit(); AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); try { // Delete the entries, it simulates just installed Alfresco for reproduce the issue final Long appId = auditSubsystem.getAuditApplicationByName("CMISChangeLog").getApplicationId(); RetryingTransactionCallback<Void> deletedCallback = new RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { auditDAO.deleteAuditEntries(appId, null, null); return null; } }; transactionService.getRetryingTransactionHelper().doInTransaction(deletedCallback); // Retrieve initial latestChangeLogToken final String initialChangeLogToken = withCmisService(new CmisServiceCallback<String>() { @Override public String execute(CmisService cmisService) { List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); assertNotNull(repositories); assertTrue(repositories.size() > 0); RepositoryInfo repo = repositories.iterator().next(); return repo.getLatestChangeLogToken(); } }, CmisVersion.CMIS_1_1); assertNotNull(initialChangeLogToken); assertEquals("0", initialChangeLogToken); } finally { auditSubsystem.destroy(); AuthenticationUtil.popAuthentication(); } }
Example #16
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * MNT-11304: Test that Alfresco has no default boundaries for decimals * @throws Exception */ @Test public void testDecimalDefaultBoundaries() throws Exception { AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); try { withCmisService(new CmisServiceCallback<Void>() { @Override public Void execute(CmisService cmisService) { List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); assertTrue(repositories.size() > 0); RepositoryInfo repo = repositories.get(0); String repositoryId = repo.getId(); TypeDefinition decimalTypeDef = cmisService.getTypeDefinition(repositoryId, "D:tcdm:testdecimalstype", null); PropertyDecimalDefinitionImpl floatNoBoundsTypeDef = (PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:float"); PropertyDecimalDefinitionImpl doubleNoBoundsTypeDef = (PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:double"); PropertyDecimalDefinitionImpl floatWithBoundsTypeDef = (PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:floatwithbounds"); PropertyDecimalDefinitionImpl doubleWithBoundsTypeDef = (PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:doublewithbounds"); // test that there is not default boundaries for decimals assertNull(floatNoBoundsTypeDef.getMinValue()); assertNull(floatNoBoundsTypeDef.getMaxValue()); assertNull(doubleNoBoundsTypeDef.getMinValue()); assertNull(doubleNoBoundsTypeDef.getMaxValue()); // test for pre-defined boundaries assertTrue(floatWithBoundsTypeDef.getMinValue().equals(BigDecimal.valueOf(-10f))); assertTrue(floatWithBoundsTypeDef.getMaxValue().equals(BigDecimal.valueOf(10f))); assertTrue(doubleWithBoundsTypeDef.getMinValue().equals(BigDecimal.valueOf(-10d))); assertTrue(doubleWithBoundsTypeDef.getMaxValue().equals(BigDecimal.valueOf(10d))); return null; } }, CmisVersion.CMIS_1_1); } finally { AuthenticationUtil.popAuthentication(); } }
Example #17
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * ACE-2904 */ @Test public void testACE2904() { // Basic CMIS Types // Additional types from Content Model final String[] types = { "cmis:document", "cmis:relationship", "cmis:folder", "cmis:policy", "cmis:item", "R:cm:replaces", "P:cm:author", "I:cm:cmobject" }; final String[] displayNames = { "Document", "Relationship", "Folder", "Policy", "Item Type", "Replaces", "Author", "Object" }; final String[] descriptions = { "Document Type", "Relationship Type", "Folder Type", "Policy Type", "CMIS Item", "Replaces", "Author", "I:cm:cmobject" }; CmisServiceCallback<String> callback = new CmisServiceCallback<String>() { @Override public String execute(CmisService cmisService) { List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); assertTrue(repositories.size() > 0); RepositoryInfo repo = repositories.get(0); String repositoryId = repo.getId(); for (int i = 0; i < types.length; i++) { TypeDefinition def = cmisService.getTypeDefinition(repositoryId, types[i], null); assertNotNull("The " + types[i] + " type is not defined", def); assertNotNull("The display name is incorrect. Please, refer to ACE-2904.", def.getDisplayName()); assertEquals("The display name is incorrect. Please, refer to ACE-2904.", def.getDisplayName(), displayNames[i]); assertEquals("The description is incorrect. Please, refer to ACE-2904.", def.getDescription(), descriptions[i]); for (PropertyDefinition<?> property : def.getPropertyDefinitions().values()) { assertNotNull("Property definition dispaly name is incorrect. Please, refer to ACE-2904.", property.getDisplayName()); assertNotNull("Property definition description is incorrect. Please, refer to ACE-2904.", property.getDescription()); } } return ""; }; }; // Lets test types for cmis 1.1 and cmis 1.0 withCmisService(callback, CmisVersion.CMIS_1_1); withCmisService(callback, CmisVersion.CMIS_1_0); }
Example #18
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * ACE-3322 */ @Test public void testACE3322() { final String[] types = { "cmis:document", "cmis:relationship", "cmis:folder", "cmis:item" }; CmisServiceCallback<String> callback = new CmisServiceCallback<String>() { @Override public String execute(CmisService cmisService) { for (int i = 0; i < types.length; i++) { List<TypeDefinitionWrapper> baseTypes = cmisDictionaryService.getBaseTypes(); assertNotNull(baseTypes); checkDefs(baseTypes); List<TypeDefinitionWrapper> children = cmisDictionaryService.getChildren(types[i]); assertNotNull(children); // Check that children were updated checkDefs(children); } return ""; }; private void checkDefs(List<TypeDefinitionWrapper> defs) { for (TypeDefinitionWrapper def : defs) { assertNotNull("Type definition was not updated. Please refer to ACE-3322", def.getTypeDefinition(false).getDisplayName()); assertNotNull("Type definition was not updated. Please refer to ACE-3322", def.getTypeDefinition(false).getDescription()); // Check that property's display name and description were updated for (PropertyDefinitionWrapper property : def.getProperties()) { assertNotNull("Display name is null", property.getPropertyDefinition().getDisplayName()); assertNotNull("Description is null", property.getPropertyDefinition().getDescription()); } } } }; withCmisService(callback, CmisVersion.CMIS_1_1); }
Example #19
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Test auto version behavior for setContentStream, deleteContentStream and appendContentStream according to ALF-21852. */ @Test public void testSetDeleteAppendContentStreamVersioning() throws Exception { AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); final String DOC1 = "documentProperties1-" + GUID.generate(); try { final FileInfo doc = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>() { @Override public FileInfo execute() throws Throwable { FileInfo document; // create document document = fileFolderService.create(repositoryHelper.getCompanyHome(), DOC1, ContentModel.TYPE_CONTENT); nodeService.setProperty(document.getNodeRef(), ContentModel.PROP_NAME, DOC1); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_TITLE, "Initial Title"); props.put(ContentModel.PROP_DESCRIPTION, "Initial Description"); nodeService.addAspect(document.getNodeRef(), ContentModel.ASPECT_TITLED, props); // apply versionable aspect with properties props = new HashMap<QName, Serializable>(); // ContentModel.PROP_INITIAL_VERSION always true props.put(ContentModel.PROP_INITIAL_VERSION, true); props.put(ContentModel.PROP_AUTO_VERSION, true); props.put(ContentModel.PROP_AUTO_VERSION_PROPS, true); versionService.ensureVersioningEnabled(document.getNodeRef(), props); return document; } }); withCmisService(new CmisServiceCallback<Void>() { @Override public Void execute(CmisService cmisService) { final String documentNodeRefId = doc.getNodeRef().toString(); final String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId(); ObjectInfo objInfoInitialVersion = cmisService.getObjectInfo(repositoryId, documentNodeRefId); assertTrue("We had just created the document - it should be version 1.0", objInfoInitialVersion.getId().endsWith("1.0")); ContentStreamImpl contentStream = new ContentStreamImpl(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, "Content " + GUID.generate()); Holder<String> objectIdHolder = new Holder<>(documentNodeRefId); // Test setContentStream cmisService.setContentStream(repositoryId, objectIdHolder, true, null, contentStream, null); assertTrue("The \"output\" parameter should returns the newly created version id: 1.1", objectIdHolder.getValue().endsWith("1.1")); // we can use this new version id to get information about the cmis object ObjectInfo objInfoAfterSetContentStream = cmisService.getObjectInfo(repositoryId, objectIdHolder.getValue()); assertTrue("The object info should reflect the version requested: 1.1", objInfoAfterSetContentStream.getId().endsWith("1.1")); // Test deleteContentStream cmisService.deleteContentStream(repositoryId, objectIdHolder, null, null); assertTrue("The \"output\" parameter should returns the newly created version id: 1.2", objectIdHolder.getValue().endsWith("1.2")); // we can use this new version id to get information about the cmis object objInfoAfterSetContentStream = cmisService.getObjectInfo(repositoryId, objectIdHolder.getValue()); assertTrue("The object info should reflect the version requested: 1.2", objInfoAfterSetContentStream.getId().endsWith("1.2")); // Test appendContentStream cmisService.appendContentStream(repositoryId, objectIdHolder, null, contentStream, true, null); assertTrue("The \"output\" parameter should returns the newly created version id: 1.3", objectIdHolder.getValue().endsWith("1.3")); // we can use this new version id to get information about the cmis object objInfoAfterSetContentStream = cmisService.getObjectInfo(repositoryId, objectIdHolder.getValue()); assertTrue("The object info should reflect the version requested: 1.3", objInfoAfterSetContentStream.getId().endsWith("1.3")); return null; } }, CmisVersion.CMIS_1_1); } finally { AuthenticationUtil.popAuthentication(); } }
Example #20
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Test to ensure that versioning properties have default values defined in Alfresco content model. * Testing <b>cm:initialVersion</b>, <b>cm:autoVersion</b> and <b>cm:autoVersionOnUpdateProps</b> properties * * @throws Exception */ @Test public void testVersioningPropertiesHaveDefaultValue() throws Exception { AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); try { // Create document via CMIS final NodeRef documentNodeRef = withCmisService(new CmisServiceCallback<NodeRef>() { @Override public NodeRef execute(CmisService cmisService) { String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId(); String rootNodeId = cmisService.getObjectByPath(repositoryId, "/", null, true, IncludeRelationships.NONE, null, false, true, null).getId(); Collection<PropertyData<?>> propsList = new ArrayList<PropertyData<?>>(); propsList.add(new PropertyStringImpl(PropertyIds.NAME, "Folder-" + GUID.generate())); propsList.add(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, "cmis:folder")); String folderId = cmisService.createFolder(repositoryId, new PropertiesImpl(propsList), rootNodeId, null, null, null, null); propsList = new ArrayList<PropertyData<?>>(); propsList.add(new PropertyStringImpl(PropertyIds.NAME, "File-" + GUID.generate())); propsList.add(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, "cmis:document")); String nodeId = cmisService.createDocument(repositoryId, new PropertiesImpl(propsList), folderId, null, null, null, null, null, null); return new NodeRef(nodeId.substring(0, nodeId.indexOf(';'))); } }, CmisVersion.CMIS_1_1); // check versioning properties transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>() { @Override public List<Void> execute() throws Throwable { assertTrue(nodeService.exists(documentNodeRef)); assertTrue(nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_VERSIONABLE)); AspectDefinition ad = dictionaryService.getAspect(ContentModel.ASPECT_VERSIONABLE); Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> properties = ad.getProperties(); for (QName qName : new QName[] {ContentModel.PROP_INITIAL_VERSION, ContentModel.PROP_AUTO_VERSION, ContentModel.PROP_AUTO_VERSION_PROPS}) { Serializable property = nodeService.getProperty(documentNodeRef, qName); assertNotNull(property); org.alfresco.service.cmr.dictionary.PropertyDefinition pd = properties.get(qName); assertNotNull(pd.getDefaultValue()); assertEquals(property, Boolean.parseBoolean(pd.getDefaultValue())); } return null; } }); } finally { AuthenticationUtil.popAuthentication(); } }
Example #21
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * MNT-14951: Test that the list of parents can be retrieved for a folder. */ @Test public void testCMISGetObjectParents() throws Exception { // setUp audit subsystem setupAudit(); AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); try { final NodeRef folderWithTwoParents = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<NodeRef>() { @Override public NodeRef execute() throws Throwable { NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome(); String folder1 = GUID.generate(); FileInfo folderInfo1 = fileFolderService.create(companyHomeNodeRef, folder1, ContentModel.TYPE_FOLDER); assertNotNull(folderInfo1); String folder2 = GUID.generate(); FileInfo folderInfo2 = fileFolderService.create(companyHomeNodeRef, folder2, ContentModel.TYPE_FOLDER); assertNotNull(folderInfo2); // Create folder11 as a subfolder of folder1 String folder11 = GUID.generate(); FileInfo folderInfo11 = fileFolderService.create(folderInfo1.getNodeRef(), folder11, ContentModel.TYPE_FOLDER); assertNotNull(folderInfo11); // Add folder2 as second parent for folder11 nodeService.addChild(folderInfo2.getNodeRef(), folderInfo11.getNodeRef(), ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS); return folderInfo11.getNodeRef(); } }); withCmisService(new CmisServiceCallback<Void>() { @Override public Void execute(CmisService cmisService) { List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); assertNotNull(repositories); assertTrue(repositories.size() > 0); String repositoryId = repositories.iterator().next().getId(); List<ObjectParentData> parents = cmisService.getObjectParents(repositoryId, folderWithTwoParents.getId(), null, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null); // Check if the second parent was also returned. assertEquals(2, parents.size()); return null; } }, CmisVersion.CMIS_1_1); } finally { auditSubsystem.destroy(); AuthenticationUtil.popAuthentication(); } }
Example #22
Source File: AlfrescoCmisServiceFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * TODO: * We are producing new instances each time. */ @Override public CmisService getService(final CallContext context) { if (logger.isDebugEnabled()) { StringBuilder sb = new StringBuilder(); sb.append("getService: ").append(AuthenticationUtil.getFullyAuthenticatedUser()) .append(" [runAsUser=").append(AuthenticationUtil.getRunAsUser()) .append(",ctxUserName=").append(context.getUsername()) .append(",ctxRepoId=").append(context.getRepositoryId()).append("]"); logger.debug(sb.toString()); } // Avoid using guest user if the user is provided in the context if(AuthenticationUtil.getFullyAuthenticatedUser() != null && authorityService.isGuestAuthority(AuthenticationUtil.getFullyAuthenticatedUser())) { AuthenticationUtil.clearCurrentSecurityContext(); } AlfrescoCmisService service = getCmisServiceTarget(connector); // Wrap it ProxyFactory proxyFactory = new ProxyFactory(service); proxyFactory.addInterface(AlfrescoCmisService.class); proxyFactory.addAdvice(cmisExceptions); proxyFactory.addAdvice(cmisControl); proxyFactory.addAdvice(cmisStreams); proxyFactory.addAdvice(cmisTransactions); proxyFactory.addAdvice(cmisHolder); AlfrescoCmisService cmisService = (AlfrescoCmisService) proxyFactory.getProxy(); ConformanceCmisServiceWrapper wrapperService = new ConformanceCmisServiceWrapper( cmisService, connector.getTypesDefaultMaxItems(), connector.getTypesDefaultDepth(), connector.getObjectsDefaultMaxItems(), connector.getObjectsDefaultDepth()); // We use our specific open method here because only we know about it cmisService.open(context); return wrapperService; }
Example #23
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructor used by {@link CmisServiceWrapperManager}. * * @param service * the {@link CmisService} object, not {@code null} */ public ConformanceCmisServiceWrapper(CmisService service) { super(service); }
Example #24
Source File: AbstractCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * Returns the wrapped service or the next service wrapper. * * @return the wrapped service */ public CmisService getWrappedService() { return service; }
Example #25
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | votes |
T execute(CmisService cmisService);