Package org.apache.chemistry.opencmis.client.api

Examples of org.apache.chemistry.opencmis.client.api.ObjectType


        objectOperationContext = new ClientOperationContext(OBJECT_PREFIX, sessionParameters);

        // folder operation context
        if (!sessionParameters.containsKey(FOLDER_PREFIX + ClientOperationContext.FILTER)) {
            ObjectType type = session.getTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value());

            StringBuilder filter = new StringBuilder();
            for (String propId : FOLDER_PROPERTY_SET) {
                PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(propId);
                if (propDef != null) {
                    if (filter.length() > 0) {
                        filter.append(",");
                    }
                    filter.append(propDef.getQueryName());
                }
            }

            sessionParameters.put(FOLDER_PREFIX + ClientOperationContext.FILTER, filter.toString());
        }

        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.INCLUDE_ACLS, "false");
        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.INCLUDE_ALLOWABLE_ACTIONS, "false");
        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.INCLUDE_POLICIES, "false");
        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.INCLUDE_RELATIONSHIPS,
                IncludeRelationships.NONE.value());
        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.RENDITION_FILTER, "cmis:none");
        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.ORDER_BY, null);
        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.MAX_ITEMS_PER_PAGE, "10000");

        folderOperationContext = new ClientOperationContext(FOLDER_PREFIX, sessionParameters);

        if (!sessionParameters.containsKey(VERSION_PREFIX + ClientOperationContext.FILTER)) {
            ObjectType type = session.getTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value());

            StringBuilder filter = new StringBuilder();
            for (String propId : VERSION_PROPERTY_SET) {
                PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(propId);
                if (propDef != null) {
                    if (filter.length() > 0) {
                        filter.append(",");
                    }
                    filter.append(propDef.getQueryName());
View Full Code Here


     */
    private List<Tree<ObjectType>> convertTypeDescendants(List<TypeDefinitionContainer> descendantsList) {
        List<Tree<ObjectType>> result = new ArrayList<Tree<ObjectType>>();

        for (TypeDefinitionContainer container : descendantsList) {
            ObjectType objectType = objectFactory.convertTypeDefinition(container.getTypeDefinition());
            List<Tree<ObjectType>> children = convertTypeDescendants(container.getChildren());

            result.add(new TreeImpl<ObjectType>(objectType, children));
        }

View Full Code Here

        if ((source == null) || (source.getId() == null)) {
            throw new IllegalArgumentException("Source must be set!");
        }

        // get the type of the source document
        ObjectType type = null;
        if (source instanceof CmisObject) {
            type = ((CmisObject) source).getType();
        } else {
            CmisObject sourceObj = getObject(source);
            type = sourceObj.getType();
        }

        if (type.getBaseTypeId() != BaseTypeId.CMIS_DOCUMENT) {
            throw new IllegalArgumentException("Source object must be a document!");
        }

        String newId = getBinding().getObjectService().createDocumentFromSource(getRepositoryId(), source.getId(),
                objectFactory.convertProperties(properties, type, CREATE_UPDATABILITY),
View Full Code Here

        if (isNullOrEmpty(properties)) {
            throw new IllegalArgumentException("Objects must be set!");
        }

        ObjectType objectType = null;
        Map<String, SecondaryType> secondaryTypes = new HashMap<String, SecondaryType>();

        // gather secondary types
        if (addSecondaryTypeIds != null) {
            for (String stid : addSecondaryTypeIds) {
                ObjectType secondaryType = getTypeDefinition(stid);

                if (!(secondaryType instanceof SecondaryType)) {
                    throw new IllegalArgumentException("Secondary types contains a type that is not a secondary type: "
                            + secondaryType.getId());
                }

                secondaryTypes.put(secondaryType.getId(), (SecondaryType) secondaryType);
            }
        }

        // gather ids and change tokens
        List<BulkUpdateObjectIdAndChangeToken> objectIdsAndChangeTokens = new ArrayList<BulkUpdateObjectIdAndChangeToken>();
        for (CmisObject object : objects) {
            if (object == null) {
                continue;
            }

            objectIdsAndChangeTokens.add(new BulkUpdateObjectIdAndChangeTokenImpl(object.getId(), object
                    .getChangeToken()));

            if (objectType == null) {
                objectType = object.getType();
            }

            if (object.getSecondaryTypes() != null) {
                for (SecondaryType secondaryType : object.getSecondaryTypes()) {
                    secondaryTypes.put(secondaryType.getId(), secondaryType);
                }
            }
        }

        Set<Updatability> updatebility = EnumSet.noneOf(Updatability.class);
View Full Code Here

        this.session = session;

        StringBuilder stmt = new StringBuilder();

        // find the primary type and check if all types are queryable
        ObjectType primaryType = null;
        String primaryAlias = null;

        Map<String, ObjectType> types = new HashMap<String, ObjectType>();
        for (Map.Entry<String, String> fte : fromTypes.entrySet()) {
            ObjectType type = session.getTypeDefinition(fte.getValue());

            if (Boolean.FALSE.equals(type.isQueryable())) {
                throw new IllegalArgumentException("Type '" + fte.getValue() + "' is not queryable!");
            }

            String alias = fte.getKey().trim();
            if (alias.length() < 1) {
                throw new IllegalArgumentException("Invalid alias for type '" + fte.getValue() + "'!");
            }

            if (type.getBaseTypeId() != BaseTypeId.CMIS_SECONDARY) {
                if (primaryType == null) {
                    primaryType = type;
                    primaryAlias = alias;
                } else {
                    throw new IllegalArgumentException("Two primary types found: " + primaryType.getId() + " and "
                            + type.getId());
                }
            }

            // exclude secondary types without properties
            if (isNotEmpty(type.getPropertyDefinitions())) {
                types.put(alias, type);
            }
        }

        if (primaryType == null) {
View Full Code Here

        parametersMap.put(parameterIndex, queryName);
    }

    public void setProperty(int parameterIndex, String typeId, String propertyId) {
        ObjectType type = session.getTypeDefinition(typeId);

        PropertyDefinition<?> propertyDefinition = type.getPropertyDefinitions().get(propertyId);
        if (propertyDefinition == null) {
            throw new IllegalArgumentException("Property does not exist!");
        }

        setProperty(parameterIndex, propertyDefinition);
View Full Code Here

                if (!(secondaryTypeId instanceof String)) {
                    throw new IllegalArgumentException("Secondary types property contains an invalid entry: "
                            + secondaryTypeId);
                }

                ObjectType secondaryType = session.getTypeDefinition(secondaryTypeId.toString());
                if (!(secondaryType instanceof SecondaryType)) {
                    throw new IllegalArgumentException(
                            "Secondary types property contains a type that is not a secondary type: " + secondaryTypeId);
                }

                allSecondaryTypes.add((SecondaryType) secondaryType);
            }
        }

        if (secondaryTypes != null && allSecondaryTypes == null) {
            allSecondaryTypes = secondaryTypes;
        }

        // some preparation
        BindingsObjectFactory bof = getBindingsObjectFactory();
        List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();

        // the big loop
        for (Map.Entry<String, ?> property : properties.entrySet()) {
            if ((property == null) || (property.getKey() == null)) {
                continue;
            }

            String id = property.getKey();
            Object value = property.getValue();

            if (value instanceof Property<?>) {
                Property<?> p = (Property<?>) value;
                if (!id.equals(p.getId())) {
                    throw new IllegalArgumentException("Property id mismatch: '" + id + "' != '" + p.getId() + "'!");
                }
                value = (p.getDefinition().getCardinality() == Cardinality.SINGLE ? p.getFirstValue() : p.getValues());
            }

            // get the property definition
            PropertyDefinition<?> definition = type.getPropertyDefinitions().get(id);

            if (definition == null && allSecondaryTypes != null) {
                for (SecondaryType secondaryType : allSecondaryTypes) {
                    if (secondaryType != null && secondaryType.getPropertyDefinitions() != null) {
                        definition = (PropertyDefinition<?>) secondaryType.getPropertyDefinitions().get(id);
                        if (definition != null) {
                            break;
                        }
                    }
                }
View Full Code Here

        if (objectData.getBaseTypeId() == null) {
            throw new IllegalArgumentException("Base type ID property not set!");
        }

        ObjectType type = getTypeFromObjectData(objectData);

        /* determine type */
        switch (objectData.getBaseTypeId()) {
        case CMIS_DOCUMENT:
            return new DocumentImpl((SessionImpl) this.session, type, objectData, context);
View Full Code Here

     */
    private List<Tree<ObjectType>> convertTypeDescendants(List<TypeDefinitionContainer> descendantsList) {
        List<Tree<ObjectType>> result = new ArrayList<Tree<ObjectType>>();

        for (TypeDefinitionContainer container : descendantsList) {
            ObjectType objectType = convertTypeDefinition(container.getTypeDefinition());
            List<Tree<ObjectType>> children = convertTypeDescendants(container.getChildren());

            result.add(new TreeImpl<ObjectType>(objectType, children));
        }

View Full Code Here

     * object and puts it into the cache.
     */
    private ObjectType convertTypeDefinition(TypeDefinition typeDefinition) {
        lock.writeLock().lock();
        try {
            ObjectType result = null;
            if (objectTypeCache == null) {
                objectTypeCache = new IdentityHashMap<TypeDefinition, ObjectType>();
            } else {
                result = objectTypeCache.get(typeDefinition);
            }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.client.api.ObjectType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.