Package org.jahia.exceptions

Examples of org.jahia.exceptions.JahiaBadRequestException


        Locale locale = LanguageCodeConverters.languageCodeToLocale(params[1]);

        if (StringUtils.isEmpty(request.getParameter("path"))
                && StringUtils.isEmpty(request.getParameter("nodeuuid"))
                && StringUtils.isEmpty(request.getParameter("type"))) {
            throw new JahiaBadRequestException("One of therequired parameters is missing");
        }

        ExtendedNodeType type = null;
        JCRSessionWrapper session = JCRSessionFactory.getInstance().getCurrentUserSession(
                workspace, locale);
        JCRNodeWrapper node = null;
        try {
            if (request.getParameter("path") != null) {
                node = session.getNode(request.getParameter("path"));
                type = node.getPrimaryNodeType();
            } else if (request.getParameter("nodeuuid") != null) {
                node = session.getNodeByUUID(request.getParameter("nodeuuid"));
                type = node.getPrimaryNodeType();
            } else {
                node = null;
                type = NodeTypeRegistry.getInstance().getNodeType(request.getParameter("type"));
            }
        } catch (PathNotFoundException e) {
            throw new JahiaBadRequestException(e);
        } catch (ItemNotFoundException e) {
            throw new JahiaBadRequestException(e);
        } catch (NoSuchNodeTypeException e) {
            throw new JahiaBadRequestException(e);
        }

        if (type == null) {
            throw new JahiaBadRequestException("Cannot determine node type");
        }

        ExtendedPropertyDefinition definition = type.getPropertyDefinition(name);
        if (definition == null) {
            throw new JahiaBadRequestException("Unable to find property defintion with the name '"
                    + name + "'");
        }

        JSONArray results = new JSONArray();
View Full Code Here


                }
            }
        }
        if (!JCRContentUtils.isValidWorkspace(workspace, true)) {
            // unknown workspace
            throw new JahiaBadRequestException("Unknown workspace '" + workspace + "'");
        }

        return new String[] { StringUtils.defaultIfEmpty(workspace, defaultWorkspace),
                StringUtils.defaultIfEmpty(lang, defaultLocale) };
    }
View Full Code Here

     */
    public final static String getParameter(final HttpServletRequest request, final String name)
            throws JahiaBadRequestException {
        final String value = request.getParameter(name);
        if (value == null) {
            throw new JahiaBadRequestException("Missing required '" + name
                    + "' parameter in request.");
        }
        return value;
    }
View Full Code Here

            Cache<?, ?> cache = cacheService.getCache(name);
            if (cache != null) {
                cache.flush(Boolean.valueOf(getParameter(request, "propagate", "true")));
                logger.info("Content of the cache '{}' successfully flushed.", name);
            } else {
                throw new JahiaBadRequestException("Unable to find cache for name '" + name + "'");
            }
            response.setStatus(HttpServletResponse.SC_OK);
        } catch (JahiaUnauthorizedException ue) {
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED, ue.getMessage());
        } catch (Exception e) {
View Full Code Here

        checkUserLoggedIn();
        checkUserAuthorized();

        String queryTerm = getParameter(request, "q");
        if (queryTerm.length() < 1 || queryTerm.replace("*", "").trim().length() < 1) {
            throw new JahiaBadRequestException("Please specify more exact term for user search");
        }
        Properties searchCriterias = buildSearchCriteria(queryTerm);

        if (logger.isDebugEnabled()) {
            logger.debug("Performing user search using criteria: {}", searchCriterias);
View Full Code Here

        try {
            checkUserLoggedIn();

            Matcher m = StringUtils.isNotEmpty(request.getPathInfo()) ? URI_PATTERN.matcher(request.getPathInfo()) : null;
            if (m == null || !m.matches()) {
                throw new JahiaBadRequestException("Requested URI '" + request.getRequestURI()
                        + "' is malformed");
            }
            String workspace = m.group(1);
            String nodePath = "/" + m.group(2);
            String exportFormat = m.group(3);
View Full Code Here

        try {
            String token = getParameter(request, "token");
            @SuppressWarnings("unchecked")
            Map<String,Map<String,List<String>>> toks = (Map<String,Map<String,List<String>>>) request.getSession().getAttribute("form-tokens");
            if (toks == null || !toks.containsKey(token)) {
                throw new JahiaBadRequestException("Unknown form token.");
            }
            // return a jpeg
            response.setContentType("image/jpeg");
   
            WebUtils.setNoCacheHeaders(response);
View Full Code Here

TOP

Related Classes of org.jahia.exceptions.JahiaBadRequestException

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.