Package org.apache.chemistry.opencmis.server.impl

Examples of org.apache.chemistry.opencmis.server.impl.CallContextImpl


        String repositoryId = null;
        if (pathFragments.length > 0) {
            repositoryId = pathFragments[0];
        }

        CallContextImpl context = new CallContextImpl(binding, repositoryId, true);

        // call call context handler
        if (callContextHandler != null) {
            Map<String, String> callContextMap = callContextHandler.getCallContextMap(request);
            if (callContextMap != null) {
                for (Map.Entry<String, String> e : callContextMap.entrySet()) {
                    context.put(e.getKey(), e.getValue());
                }
            }
        }

        // servlet context and HTTP servlet request and response
        context.put(CallContext.SERVLET_CONTEXT, servletContext);
        context.put(CallContext.HTTP_SERVLET_REQUEST, request);
        context.put(CallContext.HTTP_SERVLET_RESPONSE, response);

        // decode range
        String rangeHeader = request.getHeader("Range");
        if (rangeHeader != null) {
            rangeHeader = rangeHeader.trim();
            BigInteger offset = null;
            BigInteger length = null;

            int eq = rangeHeader.indexOf('=');
            int ds = rangeHeader.indexOf('-');
            if ((eq > 0) && (ds > eq)) {
                String offsetStr = rangeHeader.substring(eq + 1, ds).trim();
                if (offsetStr.length() > 0) {
                    offset = new BigInteger(offsetStr);
                }

                if (ds < rangeHeader.length()) {
                    String lengthStr = rangeHeader.substring(ds + 1).trim();
                    if (lengthStr.length() > 0) {
                        if (offset == null) {
                            length = new BigInteger(lengthStr);
                        } else {
                            length = (new BigInteger(lengthStr)).subtract(offset);
                        }
                    }

                    if (offset != null) {
                        context.put(CallContext.OFFSET, offset);
                    }
                    if (length != null) {
                        context.put(CallContext.LENGTH, length);
                    }
                }
            }
        }

        // get locale
        String acceptLanguage = request.getHeader("Accept-Language");
        if (acceptLanguage != null) {
            String[] locale = acceptLanguage.split("-");
            context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0].trim());
            if (locale.length > 1) {
                int x = locale[1].indexOf(',');
                if (x == -1) {
                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].trim());
                } else {
                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].substring(0, x).trim());
                }
            }
        }

        return context;
View Full Code Here


    /**
     * Returns the object id of the current request.
     */
    public static void prepareContext(CallContext context, CallUrl callUrl, CmisService service, String repositoryId,
            String objectId, String transaction, HttpServletRequest request) {
        CallContextImpl contextImpl = null;
        if (context instanceof CallContextImpl) {
            contextImpl = (CallContextImpl) context;
            contextImpl.put(CONTEXT_TRANSACTION, transaction);
        }

        if (callUrl != CallUrl.ROOT) {
            return;
        }

        ObjectData object = null;

        if (objectId != null) {
            object = service.getObject(repositoryId, objectId, "cmis:objectId,cmis:objectTypeId,cmis:baseTypeId",
                    false, IncludeRelationships.NONE, "cmis:none", false, false, null);
        } else {
            object = service.getObjectByPath(repositoryId, getPath(request),
                    "cmis:objectId,cmis:objectTypeId,cmis:baseTypeId", false, IncludeRelationships.NONE, "cmis:none",
                    false, false, null);
        }

        if (contextImpl != null) {
            contextImpl.put(CONTEXT_OBJECT_ID, object.getId());
            contextImpl.put(CONTEXT_OBJECT_TYPE_ID, getProperty(object, PropertyIds.OBJECT_TYPE_ID, String.class));
            contextImpl.put(CONTEXT_BASETYPE_ID, getProperty(object, PropertyIds.BASE_TYPE_ID, String.class));
        }
    }
View Full Code Here

        String repositoryId = null;
        if (pathFragments.length > 0) {
            repositoryId = pathFragments[0];
        }

        CallContextImpl context = new CallContextImpl(binding, repositoryId, true);

        // call call context handler
        if (callContextHandler != null) {
            Map<String, String> callContextMap = callContextHandler.getCallContextMap(request);
            if (callContextMap != null) {
                for (Map.Entry<String, String> e : callContextMap.entrySet()) {
                    context.put(e.getKey(), e.getValue());
                }
            }
        }

        // servlet context and HTTP servlet request and response
        context.put(CallContext.SERVLET_CONTEXT, servletContext);
        context.put(CallContext.HTTP_SERVLET_REQUEST, request);
        context.put(CallContext.HTTP_SERVLET_RESPONSE, response);

        // temp files
        context.put(CallContext.TEMP_DIR, tempDir);
        context.put(CallContext.MEMORY_THRESHOLD, memoryThreshold);

        // decode range
        String rangeHeader = request.getHeader("Range");
        if (rangeHeader != null) {
            rangeHeader = rangeHeader.trim();
            BigInteger offset = null;
            BigInteger length = null;

            int eq = rangeHeader.indexOf('=');
            int ds = rangeHeader.indexOf('-');
            if ((eq > 0) && (ds > eq)) {
                String offsetStr = rangeHeader.substring(eq + 1, ds).trim();
                if (offsetStr.length() > 0) {
                    offset = new BigInteger(offsetStr);
                }

                if (ds < rangeHeader.length()) {
                    String lengthStr = rangeHeader.substring(ds + 1).trim();
                    if (lengthStr.length() > 0) {
                        if (offset == null) {
                            length = new BigInteger(lengthStr);
                        } else {
                            length = (new BigInteger(lengthStr)).subtract(offset);
                        }
                    }

                    if (offset != null) {
                        context.put(CallContext.OFFSET, offset);
                    }
                    if (length != null) {
                        context.put(CallContext.LENGTH, length);
                    }
                }
            }
        }

        // get locale
        String acceptLanguage = request.getHeader("Accept-Language");
        if (acceptLanguage != null) {
            String[] locale = acceptLanguage.split("-");
            context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0].trim());
            if (locale.length > 1) {
                int x = locale[1].indexOf(',');
                if (x == -1) {
                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].trim());
                } else {
                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].substring(0, x).trim());
                }
            }
        }

        return context;
View Full Code Here

    /**
     * Returns the object id of the current request.
     */
    public static void prepareContext(CallContext context, CallUrl callUrl, CmisService service, String repositoryId,
            String objectId, String transaction, HttpServletRequest request) {
        CallContextImpl contextImpl = null;
        if (context instanceof CallContextImpl) {
            contextImpl = (CallContextImpl) context;
            contextImpl.put(CONTEXT_TRANSACTION, transaction);
        }

        if (callUrl != CallUrl.ROOT) {
            return;
        }

        ObjectData object = null;

        if (objectId != null) {
            object = service.getObject(repositoryId, objectId, "cmis:objectId,cmis:objectTypeId,cmis:baseTypeId",
                    false, IncludeRelationships.NONE, "cmis:none", false, false, null);
        } else {
            object = service.getObjectByPath(repositoryId, getPath(request),
                    "cmis:objectId,cmis:objectTypeId,cmis:baseTypeId", false, IncludeRelationships.NONE, "cmis:none",
                    false, false, null);
        }

        if (contextImpl != null) {
            contextImpl.put(CONTEXT_OBJECT_ID, object.getId());
            contextImpl.put(CONTEXT_OBJECT_TYPE_ID, getProperty(object, PropertyIds.OBJECT_TYPE_ID, String.class));
            contextImpl.put(CONTEXT_BASETYPE_ID, getProperty(object, PropertyIds.BASE_TYPE_ID, String.class));
        }
    }
View Full Code Here

    /**
     * Creates a CallContext object for the Web Service context.
     */
    @SuppressWarnings("unchecked")
    protected CallContext createContext(WebServiceContext wsContext, String repositoryId) {
        CallContextImpl context = new CallContextImpl(CallContext.BINDING_WEBSERVICES, repositoryId, false);

        MessageContext mc = wsContext.getMessageContext();
        Map<String, String> callContextMap = (Map<String, String>) mc.get(CALL_CONTEXT_MAP);
        if (callContextMap != null) {
            for (Map.Entry<String, String> e : callContextMap.entrySet()) {
                context.put(e.getKey(), e.getValue());
            }
        }

        ServletContext servletContext = (ServletContext) wsContext.getMessageContext().get(
                MessageContext.SERVLET_CONTEXT);
        context.put(CallContext.SERVLET_CONTEXT, servletContext);

        Map<String, List<String>> headers = (Map<String, List<String>>) wsContext.getMessageContext().get(
                MessageContext.HTTP_REQUEST_HEADERS);
        if (headers != null) {
            for (Map.Entry<String, List<String>> header : headers.entrySet()) {
                if (header.getKey().equalsIgnoreCase("Accept-Language") && (header.getValue() != null)) {
                    String acceptLanguage = header.getValue().get(0);
                    if (acceptLanguage != null) {
                        String[] locale = acceptLanguage.split("-");
                        context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0].trim());
                        if (locale.length > 1) {
                            int x = locale[1].indexOf(',');
                            if (x == -1) {
                                context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].trim());
                            } else {
                                context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].substring(0, x).trim());
                            }
                        }
                    }
                    break;
                }
View Full Code Here

        String repositoryId = null;
        if (pathFragments.length > 0) {
            repositoryId = pathFragments[0];
        }

        CallContextImpl context = new CallContextImpl(binding, repositoryId, true);

        // call call context handler
        if (callContextHandler != null) {
            Map<String, String> callContextMap = callContextHandler.getCallContextMap(request);
            if (callContextMap != null) {
                for (Map.Entry<String, String> e : callContextMap.entrySet()) {
                    context.put(e.getKey(), e.getValue());
                }
            }
        }

        // servlet context
        context.put(CallContext.SERVLET_CONTEXT, servletContext);

        // decode range
        String rangeHeader = request.getHeader("Range");
        if (rangeHeader != null) {
            rangeHeader = rangeHeader.trim();
            BigInteger offset = null;
            BigInteger length = null;

            int eq = rangeHeader.indexOf('=');
            int ds = rangeHeader.indexOf('-');
            if ((eq > 0) && (ds > eq)) {
                String offsetStr = rangeHeader.substring(eq + 1, ds).trim();
                if (offsetStr.length() > 0) {
                    offset = new BigInteger(offsetStr);
                }

                if (ds < rangeHeader.length()) {
                    String lengthStr = rangeHeader.substring(ds + 1).trim();
                    if (lengthStr.length() > 0) {
                        if (offset == null) {
                            length = new BigInteger(lengthStr);
                        } else {
                            length = (new BigInteger(lengthStr)).subtract(offset);
                        }
                    }

                    if (offset != null) {
                        context.put(CallContext.OFFSET, offset);
                    }
                    if (length != null) {
                        context.put(CallContext.LENGTH, length);
                    }
                }
            }
        }

        // get locale
        String acceptLanguage = request.getHeader("Accept-Language");
        if (acceptLanguage != null) {
            String[] locale = acceptLanguage.split("-");
            context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0].trim());
            if (locale.length > 1) {
                int x = locale[1].indexOf(',');
                if (x == -1) {
                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].trim());
                } else {
                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].substring(0, x).trim());
                }
            }
        }

        return context;
View Full Code Here

        String repositoryId = null;
        if (pathFragments.length > 0) {
            repositoryId = pathFragments[0];
        }

        CallContextImpl context = new CallContextImpl(CallContext.BINDING_ATOMPUB, repositoryId, true);

        // call call context handler
        if (callContextHandler != null) {
            Map<String, String> callContextMap = callContextHandler.getCallContextMap(request);
            if (callContextMap != null) {
                for (Map.Entry<String, String> e : callContextMap.entrySet()) {
                    context.put(e.getKey(), e.getValue());
                }
            }
        }

        // decode range
        String rangeHeader = request.getHeader("Range");
        if (rangeHeader != null) {
            rangeHeader = rangeHeader.trim();
            BigInteger offset = null;
            BigInteger length = null;

            int eq = rangeHeader.indexOf('=');
            int ds = rangeHeader.indexOf('-');
            if ((eq > 0) && (ds > eq)) {
                String offsetStr = rangeHeader.substring(eq + 1, ds).trim();
                if (offsetStr.length() > 0) {
                    offset = new BigInteger(offsetStr);
                }

                if (ds < rangeHeader.length()) {
                    String lengthStr = rangeHeader.substring(ds + 1).trim();
                    if (lengthStr.length() > 0) {
                        if (offset == null) {
                            length = new BigInteger(lengthStr);
                        } else {
                            length = (new BigInteger(lengthStr)).subtract(offset);
                        }
                    }

                    if (offset != null) {
                        context.put(CallContext.OFFSET, offset.toString());
                    }
                    if (length != null) {
                        context.put(CallContext.LENGTH, length.toString());
                    }
                }
            }
        }
View Full Code Here

        String repositoryId = null;
        if (pathFragments.length > 0) {
            repositoryId = pathFragments[0];
        }

        CallContextImpl context = new CallContextImpl(binding, repositoryId, true);

        // call call context handler
        if (callContextHandler != null) {
            Map<String, String> callContextMap = callContextHandler.getCallContextMap(request);
            if (callContextMap != null) {
                for (Map.Entry<String, String> e : callContextMap.entrySet()) {
                    context.put(e.getKey(), e.getValue());
                }
            }
        }

        // servlet context
        context.put(CallContext.SERVLET_CONTEXT, servletContext);

        // decode range
        String rangeHeader = request.getHeader("Range");
        if (rangeHeader != null) {
            rangeHeader = rangeHeader.trim();
            BigInteger offset = null;
            BigInteger length = null;

            int eq = rangeHeader.indexOf('=');
            int ds = rangeHeader.indexOf('-');
            if ((eq > 0) && (ds > eq)) {
                String offsetStr = rangeHeader.substring(eq + 1, ds).trim();
                if (offsetStr.length() > 0) {
                    offset = new BigInteger(offsetStr);
                }

                if (ds < rangeHeader.length()) {
                    String lengthStr = rangeHeader.substring(ds + 1).trim();
                    if (lengthStr.length() > 0) {
                        if (offset == null) {
                            length = new BigInteger(lengthStr);
                        } else {
                            length = (new BigInteger(lengthStr)).subtract(offset);
                        }
                    }

                    if (offset != null) {
                        context.put(CallContext.OFFSET, offset);
                    }
                    if (length != null) {
                        context.put(CallContext.LENGTH, length);
                    }
                }
            }
        }

        // get locale
        String acceptLanguage = request.getHeader("Accept-Language");
        if (acceptLanguage != null) {
            String[] locale = acceptLanguage.split("-");
            context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0].trim());
            if (locale.length > 1) {
                int x = locale[1].indexOf(',');
                if (x == -1) {
                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].trim());
                } else {
                    context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].substring(0, x).trim());
                }
            }
        }

        return context;
View Full Code Here

    /**
     * Creates a CallContext object for the Web Service context.
     */
    @SuppressWarnings("unchecked")
    protected CallContext createContext(WebServiceContext wsContext, String repositoryId) {
        CallContextImpl context = new CallContextImpl(CallContext.BINDING_WEBSERVICES, repositoryId, false);

        MessageContext mc = wsContext.getMessageContext();
        Map<String, String> callContextMap = (Map<String, String>) mc.get(CALL_CONTEXT_MAP);
        if (callContextMap != null) {
            for (Map.Entry<String, String> e : callContextMap.entrySet()) {
                context.put(e.getKey(), e.getValue());
            }
        }

        ServletContext servletContext = (ServletContext) wsContext.getMessageContext().get(
                MessageContext.SERVLET_CONTEXT);
        context.put(CallContext.SERVLET_CONTEXT, servletContext);

        Map<String, List<String>> headers = (Map<String, List<String>>) wsContext.getMessageContext().get(
                MessageContext.HTTP_REQUEST_HEADERS);
        if (headers != null) {
            for (Map.Entry<String, List<String>> header : headers.entrySet()) {
                if (header.getKey().equalsIgnoreCase("Accept-Language") && (header.getValue() != null)) {
                    String acceptLanguage = header.getValue().get(0);
                    if (acceptLanguage != null) {
                        String[] locale = acceptLanguage.split("-");
                        context.put(CallContext.LOCALE_ISO639_LANGUAGE, locale[0].trim());
                        if (locale.length > 1) {
                            int x = locale[1].indexOf(',');
                            if (x == -1) {
                                context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].trim());
                            } else {
                                context.put(CallContext.LOCALE_ISO3166_COUNTRY, locale[1].substring(0, x).trim());
                            }
                        }
                    }
                    break;
                }
View Full Code Here

    /**
     * Creates a CallContext object for the Web Service context.
     */
    @SuppressWarnings("unchecked")
    protected CallContext createContext(WebServiceContext wsContext, String repositoryId) {
        CallContextImpl context = new CallContextImpl(CallContext.BINDING_WEBSERVICES, repositoryId, false);

        MessageContext mc = wsContext.getMessageContext();
        Map<String, String> callContextMap = (Map<String, String>) mc.get(CALL_CONTEXT_MAP);
        if (callContextMap != null) {
            for (Map.Entry<String, String> e : callContextMap.entrySet()) {
                context.put(e.getKey(), e.getValue());
            }
        }

        return context;
    }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.server.impl.CallContextImpl

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.