Package com.volantis.xml.pipeline.sax

Examples of com.volantis.xml.pipeline.sax.XMLPipelineException


    private void obtainAuthenticationToken() throws SAXException {

        //if there was no data in cache
        if (!canRequestGoogle()) {
            XMLPipelineException error = new XMLPipelineException(EXCEPTION_LOCALIZER.format("gdocs-authentication-too-many-attempts", googleRequestCounter), null);
            error.initErrorInfo(id, null, null, null);
            dynamicProcess.fatalError(error);
        }
       
        if (authData.needsRequest()) {
            googleRequestCounter++;
View Full Code Here


        if (config == null ||
                !(config instanceof AbsoluteToRelativeURLConfiguration)) {
            // cannot get hold of the configuration. As this is fatal
            // deliver a fatal error down the pipeline
            XMLPipelineException error = new XMLPipelineException(
                    "Could not retrieve the Absolute to Relative URL " +
                    "converter configuration",
                    context.getCurrentLocator());

            try {
View Full Code Here

                        // We create a URL with the port
                        altBaseURL = new URL(bURL.getProtocol(), bURL.
                                                                 getHost(), bURL.getFile()).toExternalForm();
                    }
                } catch (MalformedURLException mue) {
                    throw new XMLPipelineException("The specified URL was " +
                                                   "not valid", getPipelineContext().
                                                                getCurrentLocator(), mue);
                }

                boolean match = false;

                if (result.startsWith(updatedBaseURL)) {
                    length = updatedBaseURL.length();
                    match = true;
                }

                if (altBaseURL != null && result.startsWith(altBaseURL)) {
                    length = altBaseURL.length();
                    match = true;
                }

                if (match) {
                    int fromPos = (result.charAt(length - 1) != '/' ?
                            length - 1 : length);
                    result = result.substring(fromPos);
                    if (substitutePath != null) {
                        result = substitutePath + result;
                    }
                }

            } else if (result.startsWith("/")) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Identified Local Abs URL " + result);
                }

                // If the prefix path of this URL matches the target mount
                // for this service then we also rewrite this local abs
                //
                try {
                    URL baseURIurl = new URL(baseURL);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Checking prefix for target mount " +
                                     baseURIurl.getFile());
                    }

                    // So if the base URL does not include a path
                    // or if the path matches the specified baseURI path
                    // then we replace it with the substitute path.
                    //
                    String path = baseURIurl.getPath();
                    if ((path.length() == 0) || (result.startsWith(path))) {

                        if (substitutePath != null) {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Added substiute prefix "
                                             + substitutePath + " instead of "
                                             + path);
                            }

                            if (path.length() > 0 &&
                                    path.charAt(path.length() - 1) == '/') {
                                path = path.substring(0, path.length() - 1);
                            }

                            result = substitutePath +
                                    result.substring(path.length() + 1);
                        }
                    }

                } catch (MalformedURLException e) {
                    throw new XMLPipelineException("The specified base URL " +
                                                   "was not valid",
                                                   getPipelineContext().getCurrentLocator(), e);
                }
            } else {
                if (logger.isDebugEnabled()) {
View Full Code Here

        HashMap<String, String> atts = new HashMap<String, String>();

        String href = attributes.getValue(ATTRIBUTE_HREF);

        if (href == null) {
            throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("attribute-invalid", ATTRIBUTE_HREF), null);
        }

        try {
            new URL(href);
        } catch (MalformedURLException e) {
            LOGGER.debug("MalformedURLException on parsing: " + href, e);
            throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("attribute-invalid", ATTRIBUTE_HREF), null);
        }
       
        //store attributes
        atts.put(ATTRIBUTE_HREF, href);
View Full Code Here

        for (String vc: VALID_ATTRIBUTE_CATEGORIES) {
            if (vc.equals(category)) {
                return;
            }
        }
        throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("attribute-invalid", ATTRIBUTE_CATEGORY), null);
    }
View Full Code Here

    private void validatePageSizeAttribute(String pageSize) throws XMLPipelineException {
        try {
            int pSize = Integer.valueOf(pageSize);
            if (pSize > ATTRIBUTE_PAGE_SIZE_MAX_VALUE || pSize < ATTRIBUTE_PAGE_SIZE_MIN_VALUE) {
                throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("attribute-size-exceeded", ATTRIBUTE_PAGE_SIZE), null);
            }
        } catch (NumberFormatException e) {
            throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("attribute-numeric-invalid", ATTRIBUTE_PAGE_SIZE), null, e);
        }
    }
View Full Code Here

    private void validatePageIndexAttribute(String pageIndex) throws XMLPipelineException {
        try {
            int pIndex = Integer.valueOf(pageIndex);
            if (pIndex < ATTRIBUTE_PAGE_SIZE_MIN_VALUE) {
                throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("attribute-size-exceeded",ATTRIBUTE_PAGE_INDEX), null);
            }
        } catch (NumberFormatException e) {
            throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("attribute-numeric-invalid",ATTRIBUTE_PAGE_INDEX), null, e);
        }
    }
View Full Code Here

        String albumName = attributes.getValue(ALBUM_NAME_ATTRIBUTE);
        String albumId = attributes.getValue(ALBUM_ID_ATTRIBUTE);

        if (albumName != null && albumId != null) {
            Locator locator = pipeline.getPipelineContext().getCurrentLocator();
            XMLPipelineException e =
                        new XMLPipelineException(
                                "not allowed to use both album and album-id attributes",
                                locator);
            getTargetProcess(pipeline).fatalError(e);
            return null;
        }

        if (albumName != null) {
            if (userId == null) {
                Locator locator = pipeline.getPipelineContext().getCurrentLocator();
                XMLPipelineException e =
                        new XMLPipelineException(
                                "not allowed to use album attribute without specifying user-id attribute",
                                locator);
                getTargetProcess(pipeline).fatalError(e);
                return null;
            }
            hrefAttr.append(MessageFormat.format(
                            PICASA_ALBUM_NAME_FRAGMENT, albumName));
        } else if (albumId != null) {
            if (userId == null) {
                Locator locator = pipeline.getPipelineContext().getCurrentLocator();
                XMLPipelineException e =
                        new XMLPipelineException(
                                "not allowed to use album-id attribute without specifying user-id attribute",
                                locator);
                getTargetProcess(pipeline).fatalError(e);
                return null;
            }
            hrefAttr.append(MessageFormat.format(
                            PICASA_ALBUM_ID_FRAGMENT, albumId));
        }

        String photoId = attributes.getValue(PHOTO_ID_ATTRIBUTE);        

        if (photoId != null) {
            if (albumName == null && albumId == null) {
                Locator locator = pipeline.getPipelineContext().getCurrentLocator();
                XMLPipelineException e =
                        new XMLPipelineException(
                                "not allowed to use photo-id attribute without specifying album or album-id attribute",
                                locator);
                getTargetProcess(pipeline).fatalError(e);
                return null;
            }
            hrefAttr.append(MessageFormat.format(
                            PICASA_PHOTO_ID_FRAGMENT, photoId));
        } else {
            queryString.append(PICASA_KIND_PHOTO_FRAGMENT);
        }

        // tags restriction/constraint can be user-, album- or photo-based
        String tags = attributes.getValue(TAGS_ATTRIBUTE);
        if (tags != null) {
            // convert space separated list to comma separated list
            String commaSeparatedTags = tags.trim().replaceAll("\\s+", ",");
            if (!"".equals(queryString)) {
                queryString.append("&");               
            }
            queryString.append(MessageFormat.format(
                            PICASA_TAG_FRAGMENT, commaSeparatedTags));
        } else if (attributes.getValue(QUERY_ATTRIBUTE) != null) {
            if (!"".equals(queryString)) {
                queryString.append("&");
            }
            queryString.append(MessageFormat.format(
                            PICASA_QUERY_FRAGMENT,
                            attributes.getValue(QUERY_ATTRIBUTE)));
        }

        // pagination parameters
        String pageSize = attributes.getValue(PAGE_SIZE_ATTRIBUTE);
        String pageIndex = attributes.getValue(PAGE_INDEX_ATTRIBUTE);   

        if (pageSize != null) {
            Integer pageSizeInt = null;
            try {
                pageSizeInt = Integer.parseInt(pageSize);
            } catch(NumberFormatException nfe) {
                Locator locator = pipeline.getPipelineContext().getCurrentLocator();
                XMLPipelineException e =
                        new XMLPipelineException(
                                "page-size attribute should be of integer value",
                                locator);
                getTargetProcess(pipeline).fatalError(e);
                return null;
          }

            if (pageSizeInt < 1 || pageSizeInt > 500) {
                Locator locator = pipeline.getPipelineContext().getCurrentLocator();
                XMLPipelineException e =
                        new XMLPipelineException(
                                "page-size attribute value should be in the range of [1,500]",
                                locator);
                getTargetProcess(pipeline).fatalError(e);
                return null;
            }
            pageSize = pageSizeInt.toString();
        } else {
            pageSize = DEFAULT_PAGE_SIZE;
        }

        if (!"".equals(queryString)) {
            queryString.append("&");               
        }

        queryString.append(MessageFormat.format(
                PICASA_MAX_RESULTS_FRAGMENT, pageSize));

        if (pageIndex != null) {
            Integer pageIndexInt = null;
            try {
                pageIndexInt = Integer.parseInt(pageIndex);
            } catch(NumberFormatException nfe) {
                Locator locator = pipeline.getPipelineContext().getCurrentLocator();
                XMLPipelineException e =
                        new XMLPipelineException(
                                "page-index attribute should be of integer value",
                                locator);
                getTargetProcess(pipeline).fatalError(e);
                return null;
            }

            if (pageIndexInt < 1) {
                Locator locator = pipeline.getPipelineContext().getCurrentLocator();
                XMLPipelineException e =
                        new XMLPipelineException(
                                "page-index attribute value should be in the range of [1,...]",
                                locator);
                getTargetProcess(pipeline).fatalError(e);
                return null;
            }
View Full Code Here

            DynamicProcess dynamicProcess, ExpandedName element,
            Attributes attributes) throws SAXException {
        HashMap<String, String> atts = gatherAndValidateAttributes(attributes);
        String id = attributes.getValue(ATTRIBUTE_ID);
        if (id == null) {
            throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("attribute-invalid", ATTRIBUTE_ID), null);
        }
        atts.put(ATTRIBUTE_ID, id);
        return atts;
    }
View Full Code Here

            XMLPipeline pipeline = dynamicProcess.getPipeline();
            context = dynamicProcess.getPipelineContext();
            authData = AuthData.retrieve(context);
            this.id = ((HashMap<String,String>)object).get(ATTRIBUTE_ID);
            if (authData == null) {
                throw new XMLPipelineException(EXCEPTION_LOCALIZER.format("gdocs-authentication-data-missing"),null);
            }

            authenticator = new Authenticator(dynamicProcess, authData, id);
            authenticator.authenticate();
            final String requestUrl = prepareRequestUrl((HashMap)object);
View Full Code Here

TOP

Related Classes of com.volantis.xml.pipeline.sax.XMLPipelineException

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.