Package org.apache.chemistry.opencmis.commons.impl.json

Examples of org.apache.chemistry.opencmis.commons.impl.json.JSONArray


        // execute
        List<RenditionData> renditions = service.getRenditions(repositoryId, objectId, renditionFilter, maxItems,
                skipCount, null);

        JSONArray jsonRenditions = new JSONArray();
        if (renditions != null) {
            for (RenditionData rendition : renditions) {
                jsonRenditions.add(JSONConverter.convert(rendition));
            }
        }

        response.setStatus(HttpServletResponse.SC_OK);
        writeJSON(jsonRenditions, request, response);
View Full Code Here


        result.put(JSON_REPINFO_CHANGE_LOCK_TOKEN, repositoryInfo.getLatestChangeLogToken());
        result.put(JSON_REPINFO_CMIS_VERSION_SUPPORTED, repositoryInfo.getCmisVersionSupported());
        setIfNotNull(JSON_REPINFO_THIN_CLIENT_URI, repositoryInfo.getThinClientUri(), result);
        setIfNotNull(JSON_REPINFO_CHANGES_INCOMPLETE, repositoryInfo.getChangesIncomplete(), result);

        JSONArray changesOnType = new JSONArray();
        if (repositoryInfo.getChangesOnType() != null) {
            for (BaseTypeId type : repositoryInfo.getChangesOnType()) {
                changesOnType.add(getJSONStringValue(type.value()));
            }
        }
        result.put(JSON_REPINFO_CHANGES_ON_TYPE, changesOnType);

        setIfNotNull(JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous(), result);
        setIfNotNull(JSON_REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone(), result);

        if (repositoryInfo.getExtensionFeatures() != null && !repositoryInfo.getExtensionFeatures().isEmpty()) {
            JSONArray extendedFeatures = new JSONArray();

            for (ExtensionFeature feature : repositoryInfo.getExtensionFeatures()) {
                JSONObject jsonFeature = new JSONObject();

                setIfNotNull(JSON_FEATURE_ID, feature.getId(), jsonFeature);
                setIfNotNull(JSON_FEATURE_URL, feature.getUrl(), jsonFeature);
                setIfNotNull(JSON_FEATURE_COMMON_NAME, feature.getCommonName(), jsonFeature);
                setIfNotNull(JSON_FEATURE_VERSION_LABEL, feature.getVersionLabel(), jsonFeature);
                setIfNotNull(JSON_FEATURE_DESCRIPTION, feature.getDescription(), jsonFeature);

                if (feature.getFeatureData() != null && !feature.getFeatureData().isEmpty()) {
                    JSONObject data = new JSONObject();
                    data.putAll(feature.getFeatureData());
                    jsonFeature.put(JSON_FEATURE_DATA, data);
                }

                convertExtension(feature, jsonFeature);

                extendedFeatures.add(jsonFeature);
            }

            result.put(JSON_REPINFO_EXTENDED_FEATURES, extendedFeatures);
        }
View Full Code Here

            CreatablePropertyTypes creatablePropertyTypes = capabilities.getCreatablePropertyTypes();

            JSONObject creatablePropertyTypesJson = new JSONObject();

            if (creatablePropertyTypes.canCreate() != null) {
                JSONArray canCreate = new JSONArray();
                for (PropertyType propType : creatablePropertyTypes.canCreate()) {
                    canCreate.add(propType.value());
                }
                creatablePropertyTypesJson.put(JSON_CAP_CREATABLE_PROPERTY_TYPES_CANCREATE, canCreate);
            }

            convertExtension(creatablePropertyTypes, creatablePropertyTypesJson);
View Full Code Here

                getJSONStringValue(capabilities.getSupportedPermissions().value()));
        result.put(JSON_ACLCAP_ACL_PROPAGATION, getJSONStringValue(capabilities.getAclPropagation().value()));

        // permissions
        if (capabilities.getPermissions() != null) {
            JSONArray permissions = new JSONArray();

            for (PermissionDefinition permDef : capabilities.getPermissions()) {
                JSONObject permission = new JSONObject();
                permission.put(JSON_ACLCAP_PERMISSION_PERMISSION, permDef.getId());
                permission.put(JSON_ACLCAP_PERMISSION_DESCRIPTION, permDef.getDescription());

                permissions.add(permission);
            }

            result.put(JSON_ACLCAP_PERMISSIONS, permissions);
        }

        // permission mapping
        if (capabilities.getPermissionMapping() != null) {
            JSONArray permissionMapping = new JSONArray();

            for (PermissionMapping permMap : capabilities.getPermissionMapping().values()) {
                JSONArray mappingPermissions = new JSONArray();
                if (permMap.getPermissions() != null) {
                    for (String p : permMap.getPermissions()) {
                        mappingPermissions.add(p);
                    }
                }

                JSONObject mapping = new JSONObject();
                mapping.put(JSON_ACLCAP_MAPPING_KEY, permMap.getKey());
View Full Code Here

            result.put(JSON_OBJECT_ALLOWABLE_ACTIONS, convert(object.getAllowableActions()));
        }

        // relationships
        if ((object.getRelationships() != null) && (!object.getRelationships().isEmpty())) {
            JSONArray relationships = new JSONArray();

            for (ObjectData relationship : object.getRelationships()) {
                relationships.add(convert(relationship, typeCache, false, succinct));
            }

            result.put(JSON_OBJECT_RELATIONSHIPS, relationships);
        }

        // change event info
        if (object.getChangeEventInfo() != null && !isQueryResult) {
            JSONObject changeEventInfo = new JSONObject();

            ChangeEventInfo cei = object.getChangeEventInfo();
            if (cei.getChangeType() != null) {
                changeEventInfo.put(JSON_CHANGE_EVENT_TYPE, getJSONStringValue(cei.getChangeType().value()));
            }
            changeEventInfo.put(JSON_CHANGE_EVENT_TIME, getJSONValue(cei.getChangeTime()));

            convertExtension(object.getChangeEventInfo(), changeEventInfo);

            result.put(JSON_OBJECT_CHANGE_EVENT_INFO, changeEventInfo);
        }

        // ACL
        if ((object.getAcl() != null) && (object.getAcl().getAces() != null) && !isQueryResult) {
            result.put(JSON_OBJECT_ACL, convert(object.getAcl()));
            result.put(JSON_OBJECT_EXACT_ACL, object.isExactAcl());
        }

        // policy ids
        if ((object.getPolicyIds() != null) && (object.getPolicyIds().getPolicyIds() != null)) {
            JSONObject policyIds = new JSONObject();
            JSONArray ids = new JSONArray();
            policyIds.put(JSON_OBJECT_POLICY_IDS_IDS, ids);

            for (String pi : object.getPolicyIds().getPolicyIds()) {
                ids.add(pi);
            }

            convertExtension(object.getPolicyIds(), policyIds);

            result.put(JSON_OBJECT_POLICY_IDS, policyIds);
        }

        // renditions
        if ((object.getRenditions() != null) && (!object.getRenditions().isEmpty())) {
            JSONArray renditions = new JSONArray();

            for (RenditionData rendition : object.getRenditions()) {
                renditions.add(convert(rendition));
            }

            result.put(JSON_OBJECT_RENDITIONS, renditions);
        }
View Full Code Here

                if ((property.getValues() == null) || (property.getValues().size() == 0)) {
                    result = null;
                } else if (propDef.getCardinality() == Cardinality.SINGLE) {
                    result = getJSONValue(property.getValues().get(0));
                } else {
                    JSONArray values = new JSONArray();

                    for (Object value : property.getValues()) {
                        values.add(getJSONValue(value));
                    }

                    result = values;
                }
            } else {
                if ((property.getValues() == null) || (property.getValues().size() == 0)) {
                    result = null;
                } else if (property.getValues().size() > 0) {
                    JSONArray values = new JSONArray();

                    for (Object value : property.getValues()) {
                        values.add(getJSONValue(value));
                    }

                    result = values;
                }
            }

            return result;
        } else {
            JSONObject result = new JSONObject();

            result.put(JSON_PROPERTY_ID, property.getId());
            setIfNotNull(JSON_PROPERTY_LOCALNAME, property.getLocalName(), result);
            setIfNotNull(JSON_PROPERTY_DISPLAYNAME, property.getDisplayName(), result);
            setIfNotNull(JSON_PROPERTY_QUERYNAME, property.getQueryName(), result);

            if (propDef != null) {
                result.put(JSON_PROPERTY_DATATYPE, propDef.getPropertyType().value());
                result.put(JSON_PROPERTY_CARDINALITY, propDef.getCardinality().value());

                if ((property.getValues() == null) || (property.getValues().size() == 0)) {
                    result.put(JSON_PROPERTY_VALUE, null);
                } else if (propDef.getCardinality() == Cardinality.SINGLE) {
                    result.put(JSON_PROPERTY_VALUE, getJSONValue(property.getValues().get(0)));
                } else {
                    JSONArray values = new JSONArray();

                    for (Object value : property.getValues()) {
                        values.add(getJSONValue(value));
                    }

                    result.put(JSON_PROPERTY_VALUE, values);
                }
            } else {
                result.put(JSON_PROPERTY_DATATYPE, getJSONPropertyDataType(property));

                if ((property.getValues() == null) || (property.getValues().size() == 0)) {
                    result.put(JSON_PROPERTY_VALUE, null);
                } else if (property.getValues().size() > 0) {
                    JSONArray values = new JSONArray();

                    for (Object value : property.getValues()) {
                        values.add(getJSONValue(value));
                    }

                    result.put(JSON_PROPERTY_VALUE, values);
                }
            }
View Full Code Here

    public static JSONObject convert(final Acl acl) {
        if ((acl == null) || (acl.getAces() == null)) {
            return null;
        }

        JSONArray aceObjects = new JSONArray();

        for (Ace ace : acl.getAces()) {
            JSONArray permissions = new JSONArray();
            if (ace.getPermissions() != null) {
                for (String p : ace.getPermissions()) {
                    permissions.add(p);
                }
            }

            JSONObject aceObject = new JSONObject();
            JSONObject principalObjecy = new JSONObject();
View Full Code Here

            return null;
        }

        JSONObject result = new JSONObject();

        JSONArray objects = new JSONArray();
        if (list.getObjects() != null) {
            for (ObjectData object : list.getObjects()) {
                objects.add(convert(object, typeCache, isQueryResult, succinct));
            }
        }

        if (isQueryResult) {
            result.put(JSON_QUERYRESULTLIST_RESULTS, objects);
View Full Code Here

        }

        JSONObject result = new JSONObject();

        if (objectInFolderList.getObjects() != null) {
            JSONArray objects = new JSONArray();

            for (ObjectInFolderData object : objectInFolderList.getObjects()) {
                objects.add(convert(object, typeCache, succinct));
            }

            result.put(JSON_OBJECTINFOLDERLIST_OBJECTS, objects);
        }
View Full Code Here

        JSONObject result = new JSONObject();
        result.put(JSON_OBJECTINFOLDERCONTAINER_OBJECT, convert(container.getObject(), typeCache, succinct));

        if ((container.getChildren() != null) && (container.getChildren().size() > 0)) {
            JSONArray children = new JSONArray();
            for (ObjectInFolderContainer descendant : container.getChildren()) {
                children.add(JSONConverter.convert(descendant, typeCache, succinct));
            }

            result.put(JSON_OBJECTINFOLDERCONTAINER_CHILDREN, children);
        }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.impl.json.JSONArray

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.