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

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


     */
    private Document cmisFolder( CmisObject cmisObject ) {
        Folder folder = (Folder)cmisObject;
        DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.OBJECT, folder.getId()));

        ObjectType objectType = cmisObject.getType();
        if (objectType.isBaseType()) {
            writer.setPrimaryType(NodeType.NT_FOLDER);
        } else {
            writer.setPrimaryType(objectType.getId());
        }

        writer.setParent(folder.getParentId());
        writer.addMixinType(NodeType.MIX_REFERENCEABLE);

View Full Code Here


     */
    public Document cmisDocument( CmisObject cmisObject ) {
        org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document)cmisObject;
        DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.OBJECT, doc.getId()));

        ObjectType objectType = cmisObject.getType();
        if (objectType.isBaseType()) {
            writer.setPrimaryType(NodeType.NT_FILE);
        } else {
            writer.setPrimaryType(objectType.getId());
        }

        List<Folder> parents = doc.getParents();
        ArrayList<String> parentIds = new ArrayList<String>();
        for (Folder f : parents) {
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

            statement.append("*");
        } else {
            statement.append(select);
        }

        final ObjectType type = getTypeDefinition(typeId);
        statement.append(" FROM ");
        statement.append(type.getQueryName());

        if (where != null && where.trim().length() > 0) {
            statement.append(" WHERE ");
            statement.append(where);
        }
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;
        List<SecondaryType> secondaryTypes = null;
        if (source instanceof CmisObject) {
            type = ((CmisObject) source).getType();
            secondaryTypes = ((CmisObject) source).getSecondaryTypes();
        } else {
            CmisObject sourceObj = getObject(source);
            type = sourceObj.getType();
            secondaryTypes = sourceObj.getSecondaryTypes();
        }

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

        String newId = getBinding().getObjectService().createDocumentFromSource(
                getRepositoryId(),
View Full Code Here

        if ((objects == null) || objects.isEmpty()) {
            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 = new HashSet<Updatability>();
View Full Code Here

                            .get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
                    if (stids != null && stids.size() > 0) {
                        secondaryTypes = new ArrayList<SecondaryType>();
                        for (String stid : stids) {
                            if (stid != null) {
                                ObjectType type = session.getTypeDefinition(stid);
                                if (type instanceof SecondaryType) {
                                    secondaryTypes.add((SecondaryType) type);
                                }
                            }
                        }
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: "
                                    + secondaryType.getId());
                }

                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

    public CmisObject convertObject(ObjectData objectData, OperationContext context) {
        if (objectData == null) {
            throw new IllegalArgumentException("Object data is null!");
        }

        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

    }

    public synchronized List<ObjectType> getCreateableTypes(String rootTypeId) {
        List<ObjectType> result = new ArrayList<ObjectType>();

        ObjectType rootType = null;
        try {
            rootType = clientSession.getSession().getTypeDefinition(rootTypeId);
        } catch (CmisBaseException e) {
            return result;
        }

        List<Tree<ObjectType>> types = clientSession.getSession().getTypeDescendants(rootTypeId, -1, false);
        addType(types, result);

        boolean isCreatable = (rootType.isCreatable() == null ? true : rootType.isCreatable().booleanValue());
        if (isCreatable) {
            result.add(rootType);
        }

        Collections.sort(result, new Comparator<ObjectType>() {
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.