org.apache.chemistry.opencmis.commons.data.RepositoryInfo Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.data.RepositoryInfo. 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: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
	log.debug("** getRepositoryInfo");

	validateSession();

	String latestChangeLogToken;
	if (cachedChangeLogToken != null) {
		latestChangeLogToken = cachedChangeLogToken;
	} else {
		latestChangeLogToken = getLatestChangeLogToken(repositoryId);
		cachedChangeLogToken = latestChangeLogToken;
	}

	for (LDRepository repo : repositories.values()) {
		if (repo.getId().equals(repositoryId)) {
			return repo.getRepositoryInfo(getCallContext(), latestChangeLogToken);
		}
	}

	throw new CmisObjectNotFoundException("Unknown repository '" + repositoryId + "'!");
}
 
Example #2
Source File: IbisRepositoryService.java    From iaf with Apache License 2.0 6 votes vote down vote up
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.GET_REPOSITORY_INFO)) {
		return repositoryService.getRepositoryInfo(repositoryId, extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");
		cmisXml.addSubElement(buildXml("repositoryId", repositoryId));

		Element cmisResult = eventDispatcher.trigger(CmisEvent.GET_REPOSITORY_INFO, cmisXml.toXML(), callContext);

		Element repositories = XmlUtils.getFirstChildTag(cmisResult, "repositories");
		Element repository = XmlUtils.getFirstChildTag(repositories, "repository");

		return CmisUtils.xml2repositoryInfo(repository);
	}
}
 
Example #3
Source File: IbisRepositoryService.java    From iaf with Apache License 2.0 6 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.GET_REPOSITORIES)) {
		return repositoryService.getRepositoryInfos(extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");

		Element cmisResult = eventDispatcher.trigger(CmisEvent.GET_REPOSITORIES, cmisXml.toXML(), callContext);
		Element repositories = XmlUtils.getFirstChildTag(cmisResult, "repositories");

		List<RepositoryInfo> repositoryInfoList = new ArrayList<RepositoryInfo>();
		for(Node node : XmlUtils.getChildTags(repositories, "repository")) {
			repositoryInfoList.add(CmisUtils.xml2repositoryInfo((Element) node));
		}
		return repositoryInfoList;
	}
}
 
Example #4
Source File: CmisUtils.java    From iaf with Apache License 2.0 6 votes vote down vote up
public static RepositoryInfo xml2repositoryInfo(Element cmisResult) {
	RepositoryInfoImpl repositoryInfo = new RepositoryInfoImpl();

	repositoryInfo.setCmisVersion(CmisVersion.fromValue(cmisResult.getAttribute("cmisVersion")));
	repositoryInfo.setCmisVersionSupported(cmisResult.getAttribute("cmisVersionSupported"));
	repositoryInfo.setDescription(cmisResult.getAttribute("description"));
	repositoryInfo.setId(cmisResult.getAttribute("id"));
	repositoryInfo.setLatestChangeLogToken(cmisResult.getAttribute("latestChangeLogToken"));
	repositoryInfo.setName(cmisResult.getAttribute("name"));
	repositoryInfo.setPrincipalAnonymous(cmisResult.getAttribute("principalIdAnonymous"));
	repositoryInfo.setPrincipalAnyone(cmisResult.getAttribute("principalIdAnyone"));
	repositoryInfo.setProductName(cmisResult.getAttribute("productName"));
	repositoryInfo.setProductVersion(cmisResult.getAttribute("productVersion"));
	repositoryInfo.setRootFolder(cmisResult.getAttribute("rootFolderId"));
	repositoryInfo.setThinClientUri(cmisResult.getAttribute("thinClientUri"));
	repositoryInfo.setVendorName(cmisResult.getAttribute("vendorName"));
	repositoryInfo.setChangesIncomplete(CmisUtils.parseBooleanAttr(cmisResult, "changesIncomplete"));
	repositoryInfo.setAclCapabilities(CmisUtils.xml2aclCapabilities(cmisResult));
	repositoryInfo.setCapabilities(CmisUtils.xml2capabilities(cmisResult));
	repositoryInfo.setChangesOnType(CmisUtils.xml2changesOnType(cmisResult));

	return repositoryInfo;
}
 
Example #5
Source File: CmisUtils.java    From iaf with Apache License 2.0 6 votes vote down vote up
public static XmlBuilder repositoryInfo2xml(RepositoryInfo repository) {
	XmlBuilder repositoryXml = new XmlBuilder("repository");
	repositoryXml.addAttribute("cmisVersion", repository.getCmisVersion().value());
	repositoryXml.addAttribute("cmisVersionSupported", repository.getCmisVersionSupported());
	repositoryXml.addAttribute("description", repository.getDescription());
	repositoryXml.addAttribute("id", repository.getId());
	repositoryXml.addAttribute("latestChangeLogToken", repository.getLatestChangeLogToken());
	repositoryXml.addAttribute("name", repository.getName());
	repositoryXml.addAttribute("principalIdAnonymous", repository.getPrincipalIdAnonymous());
	repositoryXml.addAttribute("principalIdAnyone", repository.getPrincipalIdAnyone());
	repositoryXml.addAttribute("productName", repository.getProductName());
	repositoryXml.addAttribute("productVersion", repository.getProductVersion());
	repositoryXml.addAttribute("rootFolderId", repository.getRootFolderId());
	repositoryXml.addAttribute("thinClientUri", repository.getThinClientUri());
	repositoryXml.addAttribute("vendorName", repository.getVendorName());
	repositoryXml.addAttribute("changesIncomplete", repository.getChangesIncomplete());
	repositoryXml.addSubElement(CmisUtils.aclCapabilities2xml(repository.getAclCapabilities()));
	repositoryXml.addSubElement(CmisUtils.repositoryCapabilities2xml(repository.getCapabilities()));
	repositoryXml.addSubElement(CmisUtils.changesOnType2xml(repository.getChangesOnType()));

	return repositoryXml;
}
 
Example #6
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private RepositoryInfo getRepositoryInfo(final Network network)
{
	final String networkId = network.getTenantDomain();
    final String tenantDomain = (networkId.equals(TenantUtil.SYSTEM_TENANT) || networkId.equals(TenantUtil.DEFAULT_TENANT)) ? TenantService.DEFAULT_DOMAIN : networkId;

    return TenantUtil.runAsSystemTenant(new TenantRunAsWork<RepositoryInfo>()
    {
        public RepositoryInfo doWork()
        {
            RepositoryInfoImpl repoInfo = (RepositoryInfoImpl)connector.getRepositoryInfo(getContext().getCmisVersion());

            repoInfo.setId(!networkId.equals("") ? networkId : TenantUtil.SYSTEM_TENANT);
            repoInfo.setName(tenantDomain);
            repoInfo.setDescription(tenantDomain);

            return repoInfo;
        }
    }, tenantDomain);
}
 
Example #7
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension)
{
	Network network = null;
	
	try
	{
        checkRepositoryId(repositoryId);
        network = networksService.getNetwork(repositoryId);
	}
	catch(Exception e)
	{
		// ACE-2540: Avoid information leak. Same response if repository does not exist or if user is not a member
        throw new CmisObjectNotFoundException("Unknown repository '" + repositoryId + "'!");
	}

    return getRepositoryInfo(network);
}
 
Example #8
Source File: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
	log.debug("** getRepositoryInfos");

	validateSession();

	List<RepositoryInfo> result = new ArrayList<RepositoryInfo>();

	for (LDRepository repo : repositories.values()) {
		String latestChangeLogToken = getLatestChangeLogToken(repo.getId());
		result.add(repo.getRepositoryInfo(getCallContext(), latestChangeLogToken));
	}

	return result;
}
 
Example #9
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
    checkRepositoryId(repositoryId);

    try {
        return getWrappedService().getRepositoryInfo(repositoryId, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #10
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
    try {
        return getWrappedService().getRepositoryInfos(extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #11
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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 #12
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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 #13
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension)
{
	// for currently authenticated user
	PagingResults<Network> networks = networksService.getNetworks(new PagingRequest(0, Integer.MAX_VALUE));
	List<Network> page = networks.getPage();
    final List<RepositoryInfo> repoInfos = new ArrayList<RepositoryInfo>(page.size() + 1);
    for (Network network : page)
    {
        repoInfos.add(getRepositoryInfo(network));
    }
    return repoInfos;
}
 
Example #14
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

	CmisVersion cmisVersion = getContext().getCmisVersion();
    return connector.getRepositoryInfo(cmisVersion);
}
 
Example #15
Source File: CmisSessionBuilder.java    From iaf with Apache License 2.0 5 votes vote down vote up
public static String getRepositoryInfo(Session cmisSession) {
	RepositoryInfo ri = cmisSession.getRepositoryInfo();
	String id = ri.getId();
	String productName = ri.getProductName();
	String productVersion = ri.getProductVersion();
	String cmisVersion = ri.getCmisVersion().value();
	return "id [" + id + "] cmis version [" + cmisVersion + "] product ["
			+ productName + "] version [" + productVersion + "]";
}
 
Example #16
Source File: AbstractCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
    return service.getRepositoryInfo(repositoryId, extension);
}
 
Example #17
Source File: FilterCmisService.java    From iaf with Apache License 2.0 4 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
	return getRepositoryService().getRepositoryInfos(extension);
}
 
Example #18
Source File: FilterCmisService.java    From iaf with Apache License 2.0 4 votes vote down vote up
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
	return getRepositoryService().getRepositoryInfo(repositoryId, extension);
}
 
Example #19
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Returns the repository info object.
 */
public RepositoryInfo getRepositoryInfo(CmisVersion cmisVersion)
{
    return createRepositoryInfo(cmisVersion);
}
 
Example #20
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Creates the repository info object.
 */
private RepositoryInfo createRepositoryInfo(CmisVersion cmisVersion)
{
    Descriptor currentDescriptor = descriptorService.getCurrentRepositoryDescriptor();

    // get change token
    boolean auditEnabled = auditService.isAuditEnabled(CMIS_CHANGELOG_AUDIT_APPLICATION, "/"
            + CMIS_CHANGELOG_AUDIT_APPLICATION);
    String latestChangeLogToken = null;

    if (auditEnabled)
    {
        EntryIdCallback auditQueryCallback = new EntryIdCallback(false);
        AuditQueryParameters params = new AuditQueryParameters();
        params.setApplicationName(CMIS_CHANGELOG_AUDIT_APPLICATION);
        params.setForward(false);
        auditService.auditQuery(auditQueryCallback, params, 1);
        String entryId = auditQueryCallback.getEntryId();
        // MNT-13529
        // add initial change log token
        latestChangeLogToken = entryId == null ? "0" : entryId;
    }

    // compile repository info
    RepositoryInfoImpl ri = new RepositoryInfoImpl();

    ri.setId(currentDescriptor.getId());
    ri.setName(currentDescriptor.getName());
    ri.setDescription(currentDescriptor.getName());
    ri.setVendorName("Alfresco");
    ri.setProductName("Alfresco " + descriptorService.getServerDescriptor().getEdition());
    ri.setProductVersion(currentDescriptor.getVersion());
    NodeRef rootNodeRef = getRootNodeRef();
    ri.setRootFolder(constructObjectId(rootNodeRef, null));
    ri.setCmisVersion(cmisVersion);

    ri.setChangesIncomplete(true);
    ri.setChangesOnType(Arrays.asList(new BaseTypeId[] { BaseTypeId.CMIS_DOCUMENT, BaseTypeId.CMIS_FOLDER }));
    ri.setLatestChangeLogToken(latestChangeLogToken);
    ri.setPrincipalAnonymous(AuthenticationUtil.getGuestUserName());
    ri.setPrincipalAnyone(PermissionService.ALL_AUTHORITIES);

    RepositoryCapabilitiesImpl repCap = new RepositoryCapabilitiesImpl();
    ri.setCapabilities(repCap);

    repCap.setAllVersionsSearchable(false);
    repCap.setCapabilityAcl(CapabilityAcl.MANAGE);
    repCap.setCapabilityChanges(auditEnabled ? CapabilityChanges.OBJECTIDSONLY : CapabilityChanges.NONE);
    repCap.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME);
    repCap.setCapabilityJoin(CapabilityJoin.NONE);
    repCap.setCapabilityQuery(CapabilityQuery.BOTHCOMBINED);
    repCap.setCapabilityRendition(CapabilityRenditions.READ);
    repCap.setIsPwcSearchable(false);
    repCap.setIsPwcUpdatable(true);
    repCap.setSupportsGetDescendants(true);
    repCap.setSupportsGetFolderTree(true);
    repCap.setSupportsMultifiling(true);
    repCap.setSupportsUnfiling(false);
    repCap.setSupportsVersionSpecificFiling(false);

    AclCapabilitiesDataImpl aclCap = new AclCapabilitiesDataImpl();
    ri.setAclCapabilities(aclCap);

    aclCap.setAclPropagation(AclPropagation.PROPAGATE);
    aclCap.setSupportedPermissions(SupportedPermissions.BOTH);
    aclCap.setPermissionDefinitionData(repositoryPermissions);
    aclCap.setPermissionMappingData(permissionMappings);

    return ri;
}
 
Example #21
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 4 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extensionsData) {

	return Collections.singletonList(config.getCmisRepositoryInfo());
}
 
Example #22
Source File: CmisRepositoryConfigurationImpl.java    From spring-content with Apache License 2.0 4 votes vote down vote up
public void setCmisRepositoryInfo(RepositoryInfo cmisRepositoryInfo) {
	this.cmisRepositoryInfo = cmisRepositoryInfo;
}
 
Example #23
Source File: CmisRepositoryConfigurationImpl.java    From spring-content with Apache License 2.0 4 votes vote down vote up
public RepositoryInfo getCmisRepositoryInfo() {
	return cmisRepositoryInfo;
}
 
Example #24
Source File: CmisRepository.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * CMIS getRepositoryInfo.
 */
public RepositoryInfo getRepositoryInfo(CallContext context) {
	return repositoryInfo;
}
 
Example #25
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension)
{
	CmisVersion cmisVersion = getContext().getCmisVersion();
    return Collections.singletonList(connector.getRepositoryInfo(cmisVersion));
}
 
Example #26
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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 #27
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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 #28
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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 #29
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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 #30
Source File: AbstractCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
    return service.getRepositoryInfos(extension);
}