org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl. 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: Converter.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts a type list
 * 
 * @param typeList the list to convert
 * 
 * @return the converted definition list
 */
public static TypeDefinitionList convert(CmisTypeDefinitionListType typeList) {
	if (typeList == null) {
		return null;
	}

	TypeDefinitionListImpl result = new TypeDefinitionListImpl();
	List<TypeDefinition> types = new ArrayList<TypeDefinition>();
	for (CmisTypeDefinitionType typeDefinition : typeList.getTypes()) {
		types.add(convert(typeDefinition));
	}

	result.setList(types);
	result.setHasMoreItems(typeList.isHasMoreItems());
	result.setNumItems(typeList.getNumItems());

	// handle extensions
	convertExtension(typeList, result);

	return result;
}
 
Example #2
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public TypeDefinitionList getTypeChildren(CmisRepositoryConfiguration config,
		String typeId,
		Boolean includePropertyDefinitions,
		BigInteger maxItems,
		BigInteger skipCount,
		ExtensionsData extension) {
	if (typeId == null) {
		return cmisRepositoryConfiguration.getCmisTypeDefinitionList();
	}
	return new TypeDefinitionListImpl(Collections.EMPTY_LIST);
}
 
Example #3
Source File: TypeManager.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * CMIS getTypesChildren
 * 
 * @param context the call context
 * @param typeId identifier of the type
 * @param includePropertyDefinitions if the property definition must be
 *        included
 * @param maxItems maximum number of items
 * @param skipCount if the counting of children must be avoided
 * 
 * @return list of definitions
 */
public TypeDefinitionList getTypesChildren(CallContext context, String typeId, boolean includePropertyDefinitions,
		BigInteger maxItems, BigInteger skipCount) {
	TypeDefinitionListImpl result = new TypeDefinitionListImpl(new ArrayList<TypeDefinition>());

	int skip = (skipCount == null ? 0 : skipCount.intValue());
	if (skip < 0) {
		skip = 0;
	}

	int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
	if (max < 1) {
		return result;
	}

	if (typeId == null) {
		if (skip < 1) {
			result.getList().add(copyTypeDefintion(types.get(FOLDER_TYPE_ID).getTypeDefinition()));
			max--;
		}
		if ((skip < 2) && (max > 0)) {
			result.getList().add(copyTypeDefintion(types.get(DOCUMENT_TYPE_ID).getTypeDefinition()));
			max--;
		}

		result.setHasMoreItems((result.getList().size() + skip) < 2);
		result.setNumItems(BigInteger.valueOf(2));
	} else {
		TypeDefinitionContainer tc = types.get(typeId);
		if ((tc == null) || (tc.getChildren() == null)) {
			return result;
		}

		for (TypeDefinitionContainer child : tc.getChildren()) {
			if (skip > 0) {
				skip--;
				continue;
			}

			result.getList().add(copyTypeDefintion(child.getTypeDefinition()));

			max--;
			if (max == 0) {
				break;
			}
		}

		result.setHasMoreItems((result.getList().size() + skip) < tc.getChildren().size());
		result.setNumItems(BigInteger.valueOf(tc.getChildren().size()));
	}

	if (!includePropertyDefinitions) {
		for (TypeDefinition type : result.getList()) {
			type.getPropertyDefinitions().clear();
		}
	}

	return result;
}
 
Example #4
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
    public TypeDefinitionList getTypeChildren(
            String repositoryId, String typeId, Boolean includePropertyDefinitions,
            BigInteger maxItems, BigInteger skipCount, ExtensionsData extension)
    {
        checkRepositoryId(repositoryId);

        // convert BigIntegers to int
        int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
        int skip = (skipCount == null || skipCount.intValue() < 0 ? 0 : skipCount.intValue());

        // set up the result
        TypeDefinitionListImpl result = new TypeDefinitionListImpl();
        List<TypeDefinition> list = new ArrayList<TypeDefinition>();
        result.setList(list);

        // get the types from the dictionary
        List<TypeDefinitionWrapper> childrenList;
        if (typeId == null)
        {
            childrenList = connector.getOpenCMISDictionaryService().getBaseTypes(true);
        }
        else
        {
        	TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId);
        	if (tdw == null)
        	{
        		throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
        	}
        	childrenList = connector.getOpenCMISDictionaryService().getChildren(typeId);
//            childrenList = tdw.getChildren();
        }

        // create result
        if (max > 0)
        {
            int lastIndex = (max + skip > childrenList.size() ? childrenList.size() : max + skip) - 1;
            for (int i = skip; i <= lastIndex; i++)
            {
                list.add(childrenList.get(i).getTypeDefinition(includePropertyDefinitions));
            }
        }

        result.setHasMoreItems(childrenList.size() - skip > result.getList().size());
        result.setNumItems(BigInteger.valueOf(childrenList.size()));

        return result;
    }