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

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


    public static JSONObject convert(final FailedToDeleteData ftd) {
        if (ftd == null) {
            return null;
        }

        JSONObject result = new JSONObject();

        JSONArray ids = new JSONArray();
        if (ftd.getIds() != null) {
            for (String id : ftd.getIds()) {
                ids.add(id);
            }
        }

        result.put(JSON_FAILEDTODELETE_ID, ids);

        convertExtension(ftd, result);

        return result;
    }
View Full Code Here


    public static JSONObject convert(BulkUpdateObjectIdAndChangeToken oc) {
        if (oc == null) {
            return null;
        }

        JSONObject result = new JSONObject();

        setIfNotNull(JSON_BULK_UPDATE_ID, oc.getId(), result);
        setIfNotNull(JSON_BULK_UPDATE_NEW_ID, oc.getNewId(), result);
        setIfNotNull(JSON_BULK_UPDATE_CHANGE_TOKEN, oc.getChangeToken(), result);
View Full Code Here

    private static JSONObject convertExtensionList(final List<CmisExtensionElement> extensionList) {
        if (extensionList == null) {
            return null;
        }

        JSONObject result = new JSONObject();

        for (CmisExtensionElement ext : extensionList) {
            addExtensionToTarget(ext, result);
        }
View Full Code Here

            final String rootUrl, final boolean addExtendedDatetimeExtensionFeature) {
        if (repositoryInfo == null) {
            return null;
        }

        JSONObject result = new JSONObject();

        result.put(JSON_REPINFO_ID, repositoryInfo.getId());
        result.put(JSON_REPINFO_NAME, repositoryInfo.getName());
        result.put(JSON_REPINFO_DESCRIPTION, repositoryInfo.getDescription());
        result.put(JSON_REPINFO_VENDOR, repositoryInfo.getVendorName());
        result.put(JSON_REPINFO_PRODUCT, repositoryInfo.getProductName());
        result.put(JSON_REPINFO_PRODUCT_VERSION, repositoryInfo.getProductVersion());
        result.put(JSON_REPINFO_ROOT_FOLDER_ID, repositoryInfo.getRootFolderId());
        result.put(JSON_REPINFO_CAPABILITIES, convert(repositoryInfo.getCapabilities()));
        setIfNotNull(JSON_REPINFO_ACL_CAPABILITIES, convert(repositoryInfo.getAclCapabilities()), result);
        result.put(JSON_REPINFO_CHANGE_LOG_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()) {
                if (type != null) {
                    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 (isNotEmpty(repositoryInfo.getExtensionFeatures())) {
            JSONArray extendedFeatures = new JSONArray();

            for (ExtensionFeature feature : repositoryInfo.getExtensionFeatures()) {
                extendedFeatures.add(convert(feature));
            }

            result.put(JSON_REPINFO_EXTENDED_FEATURES, extendedFeatures);
        }

        if (addExtendedDatetimeExtensionFeature) {
            JSONArray extendedFeatures = (JSONArray) result.get(JSON_REPINFO_EXTENDED_FEATURES);
            if (extendedFeatures == null) {
                extendedFeatures = new JSONArray();
                result.put(JSON_REPINFO_EXTENDED_FEATURES, extendedFeatures);
            }

            extendedFeatures.add(convert(ExtensionFeatures.EXTENDED_DATETIME_FORMAT));
        }

        result.put(JSON_REPINFO_REPOSITORY_URL, repositoryUrl);
        result.put(JSON_REPINFO_ROOT_FOLDER_URL, rootUrl);

        convertExtension(repositoryInfo, result);

        return result;
    }
View Full Code Here

    private static JSONObject convert(final ExtensionFeature feature) {
        if (feature == null) {
            return null;
        }

        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 (isNotEmpty(feature.getFeatureData())) {
            JSONObject data = new JSONObject();
            data.putAll(feature.getFeatureData());
            jsonFeature.put(JSON_FEATURE_DATA, data);
        }

        convertExtension(feature, jsonFeature);
View Full Code Here

    public static JSONObject convert(final RepositoryCapabilities capabilities) {
        if (capabilities == null) {
            return null;
        }

        JSONObject result = new JSONObject();

        result.put(JSON_CAP_CONTENT_STREAM_UPDATABILITY,
                getJSONEnumValue(capabilities.getContentStreamUpdatesCapability()));
        result.put(JSON_CAP_CHANGES, getJSONEnumValue(capabilities.getChangesCapability()));
        result.put(JSON_CAP_RENDITIONS, getJSONEnumValue(capabilities.getRenditionsCapability()));
        result.put(JSON_CAP_GET_DESCENDANTS, capabilities.isGetDescendantsSupported());
        result.put(JSON_CAP_GET_FOLDER_TREE, capabilities.isGetFolderTreeSupported());
        result.put(JSON_CAP_MULTIFILING, capabilities.isMultifilingSupported());
        result.put(JSON_CAP_UNFILING, capabilities.isUnfilingSupported());
        result.put(JSON_CAP_VERSION_SPECIFIC_FILING, capabilities.isVersionSpecificFilingSupported());
        result.put(JSON_CAP_PWC_SEARCHABLE, capabilities.isPwcSearchableSupported());
        result.put(JSON_CAP_PWC_UPDATABLE, capabilities.isPwcUpdatableSupported());
        result.put(JSON_CAP_ALL_VERSIONS_SEARCHABLE, capabilities.isAllVersionsSearchableSupported());
        result.put(JSON_CAP_ORDER_BY, getJSONEnumValue(capabilities.getOrderByCapability()));
        result.put(JSON_CAP_QUERY, getJSONEnumValue(capabilities.getQueryCapability()));
        result.put(JSON_CAP_JOIN, getJSONEnumValue(capabilities.getJoinCapability()));
        result.put(JSON_CAP_ACL, getJSONEnumValue(capabilities.getAclCapability()));

        if (capabilities.getCreatablePropertyTypes() != null) {
            CreatablePropertyTypes creatablePropertyTypes = capabilities.getCreatablePropertyTypes();

            JSONObject creatablePropertyTypesJson = new JSONObject();

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

            convertExtension(creatablePropertyTypes, creatablePropertyTypesJson);

            result.put(JSON_CAP_CREATABLE_PROPERTY_TYPES, creatablePropertyTypesJson);
        }

        if (capabilities.getNewTypeSettableAttributes() != null) {
            NewTypeSettableAttributes newTypeSettableAttributes = capabilities.getNewTypeSettableAttributes();

            JSONObject newTypeSettableAttributesJson = new JSONObject();
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_ID,
                    newTypeSettableAttributes.canSetId());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAME,
                    newTypeSettableAttributes.canSetLocalName());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAMESPACE,
                    newTypeSettableAttributes.canSetLocalNamespace());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DISPLAYNAME,
                    newTypeSettableAttributes.canSetDisplayName());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYNAME,
                    newTypeSettableAttributes.canSetQueryName());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DESCRIPTION,
                    newTypeSettableAttributes.canSetDescription());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CREATEABLE,
                    newTypeSettableAttributes.canSetCreatable());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FILEABLE,
                    newTypeSettableAttributes.canSetFileable());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYABLE,
                    newTypeSettableAttributes.canSetQueryable());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FULLTEXTINDEXED,
                    newTypeSettableAttributes.canSetFulltextIndexed());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_INCLUDEDINSUPERTYTPEQUERY,
                    newTypeSettableAttributes.canSetIncludedInSupertypeQuery());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEPOLICY,
                    newTypeSettableAttributes.canSetControllablePolicy());
            newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEACL,
                    newTypeSettableAttributes.canSetControllableAcl());

            convertExtension(newTypeSettableAttributes, newTypeSettableAttributesJson);

            result.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES, newTypeSettableAttributesJson);
View Full Code Here

            response.addCookie(transactionCookie);
        }
    }

    public static String createCookieValue(int code, String objectId, String ex, String message) {
        JSONObject result = new JSONObject();

        result.put("code", code);
        result.put("objectId", objectId == null ? "" : objectId);
        result.put("exception", ex == null ? "" : ex);
        result.put("message", message == null ? "" : message);

        return result.toJSONString();
    }
View Full Code Here

            throw new CmisRuntimeException("PWC is null!");
        }

        // return object
        TypeCache typeCache = new ServerTypeCacheImpl(repositoryId, service);
        JSONObject jsonObject = JSONConverter.convert(object, typeCache, false, succinct);

        // set headers
        String location = compileUrl(compileBaseUrl(request, repositoryId), RESOURCE_CONTENT, object.getId());

        setStatus(request, response, HttpServletResponse.SC_CREATED);
View Full Code Here

        if (object == null) {
            throw new CmisRuntimeException("New version is null!");
        }

        // return object
        JSONObject jsonObject = JSONConverter.convert(object, typeCache, false, succinct);

        String location = compileUrl(compileBaseUrl(request, repositoryId), RESOURCE_CONTENT, object.getId());

        setStatus(request, response, HttpServletResponse.SC_CREATED);
        response.setHeader("Location", location);
View Full Code Here

    public static void getRepositories(CallContext context, CmisService service, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        // execute
        List<RepositoryInfo> infoDataList = service.getRepositoryInfos(null);

        JSONObject result = new JSONObject();
        for (RepositoryInfo ri : infoDataList) {
            String repositoryUrl = BrowserBindingUtils.compileRepositoryUrl(request, ri.getId()).toString();
            String rootUrl = BrowserBindingUtils.compileRootUrl(request, ri.getId()).toString();

            result.put(ri.getId(), JSONConverter.convert(ri, repositoryUrl, rootUrl));
        }

        response.setStatus(HttpServletResponse.SC_OK);
        BrowserBindingUtils.writeJSON(result, request, response);
    }
View Full Code Here

TOP

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

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.