Example usage for java.net URI isAbsolute

List of usage examples for java.net URI isAbsolute

Introduction

In this page you can find the example usage for java.net URI isAbsolute.

Prototype

public boolean isAbsolute() 

Source Link

Document

Tells whether or not this URI is absolute.

Usage

From source file:it.staiger.jmeter.protocol.http.sampler.HTTPHC4DynamicFilePost.java

/**
 * Parses the result and fills the SampleResult with its info
 * @param httpRequest the executed request
 * @param localContext the Http context which was used
 * @param res the SampleResult which is to be filled
 * @param httpResponse the response which is to be parsed
 * @throws IllegalStateException//from   w  w w  .ja v  a  2  s . co m
 * @throws IOException
 */
private void parseResponse(HttpRequestBase httpRequest, HttpContext localContext, HTTPSampleResult res,
        HttpResponse httpResponse) throws IllegalStateException, IOException {

    // Needs to be done after execute to pick up all the headers
    final HttpRequest request = (HttpRequest) localContext.getAttribute(ExecutionContext.HTTP_REQUEST);
    // We've finished with the request, so we can add the LocalAddress to it for display
    final InetAddress localAddr = (InetAddress) httpRequest.getParams()
            .getParameter(ConnRoutePNames.LOCAL_ADDRESS);
    if (localAddr != null) {
        request.addHeader(HEADER_LOCAL_ADDRESS, localAddr.toString());
    }
    res.setRequestHeaders(getConnectionHeaders(request));

    Header contentType = httpResponse.getLastHeader(HTTPConstants.HEADER_CONTENT_TYPE);
    if (contentType != null) {
        String ct = contentType.getValue();
        res.setContentType(ct);
        res.setEncodingAndType(ct);
    }
    HttpEntity entity = httpResponse.getEntity();
    if (entity != null) {
        InputStream instream = entity.getContent();
        res.setResponseData(readResponse(res, instream, (int) entity.getContentLength()));
    }

    res.sampleEnd(); // Done with the sampling proper.
    currentRequest = null;

    // Now collect the results into the HTTPSampleResult:
    StatusLine statusLine = httpResponse.getStatusLine();
    int statusCode = statusLine.getStatusCode();
    res.setResponseCode(Integer.toString(statusCode));
    res.setResponseMessage(statusLine.getReasonPhrase());
    res.setSuccessful(isSuccessCode(statusCode));

    res.setResponseHeaders(getResponseHeaders(httpResponse));
    if (res.isRedirect()) {
        final Header headerLocation = httpResponse.getLastHeader(HTTPConstants.HEADER_LOCATION);
        if (headerLocation == null) { // HTTP protocol violation, but avoids NPE
            throw new IllegalArgumentException(
                    "Missing location header in redirect for " + httpRequest.getRequestLine());
        }
        String redirectLocation = headerLocation.getValue();
        res.setRedirectLocation(redirectLocation);
    }

    // record some sizes to allow HTTPSampleResult.getBytes() with different options
    HttpConnectionMetrics metrics = (HttpConnectionMetrics) localContext.getAttribute(CONTEXT_METRICS);
    long headerBytes = res.getResponseHeaders().length() // condensed length (without \r)
            + httpResponse.getAllHeaders().length // Add \r for each header
            + 1 // Add \r for initial header
            + 2; // final \r\n before data
    long totalBytes = metrics.getReceivedBytesCount();
    res.setHeadersSize((int) headerBytes);
    res.setBodySize((int) (totalBytes - headerBytes));
    if (log.isDebugEnabled()) {
        log.debug("ResponseHeadersSize=" + res.getHeadersSize() + " Content-Length=" + res.getBodySize()
                + " Total=" + (res.getHeadersSize() + res.getBodySize()));
    }

    // If we redirected automatically, the URL may have changed
    if (getAutoRedirects()) {
        HttpUriRequest req = (HttpUriRequest) localContext.getAttribute(ExecutionContext.HTTP_REQUEST);
        HttpHost target = (HttpHost) localContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        URI redirectURI = req.getURI();
        if (redirectURI.isAbsolute()) {
            res.setURL(redirectURI.toURL());
        } else {
            res.setURL(new URL(new URL(target.toURI()), redirectURI.toString()));
        }
    }
}

From source file:org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.java

protected void rewriteRequestURI(final RequestWrapper request, final HttpRoute route) throws ProtocolException {
    try {//from   w  w w  .  j  av  a2  s.co  m
        URI uri = request.getURI();
        if (route.getProxyHost() != null && !route.isTunnelled()) {
            // Make sure the request URI is absolute
            if (!uri.isAbsolute()) {
                final HttpHost target = route.getTargetHost();
                uri = URIUtils.rewriteURI(uri, target);
                request.setURI(uri);
            }
        } else {
            // Make sure the request URI is relative
            if (uri.isAbsolute()) {
                uri = URIUtils.rewriteURI(uri, null);
                request.setURI(uri);
            }
        }
    } catch (final URISyntaxException ex) {
        throw new ProtocolException("Invalid URI: " + request.getRequestLine().getUri(), ex);
    }
}

From source file:org.apache.streams.plugins.cassandra.StreamsCassandraResourceGenerator.java

protected StringBuilder appendArrayItems(StringBuilder builder, Schema schema, String fieldId,
        ObjectNode itemsNode, Character seperator) {
    // not safe to append nothing
    Objects.requireNonNull(builder);
    if (itemsNode == null) {
        return builder;
    }/*from  www . j av  a2s .  c o m*/
    if (itemsNode.has("type")) {
        try {
            FieldType itemType = FieldUtil.determineFieldType(itemsNode);
            switch (itemType) {
            case OBJECT:
                Schema objectSchema = null;
                URI parentUri = null;
                if (itemsNode.has("$ref") || itemsNode.has("extends")) {
                    JsonNode refNode = itemsNode.get("$ref");
                    JsonNode extendsNode = itemsNode.get("extends");
                    if (refNode != null && refNode.isValueNode()) {
                        parentUri = URI.create(refNode.asText());
                    } else if (extendsNode != null && extendsNode.isObject()) {
                        parentUri = URI.create(extendsNode.get("$ref").asText());
                    }
                    URI absoluteUri;
                    if (parentUri.isAbsolute()) {
                        absoluteUri = parentUri;
                    } else {
                        absoluteUri = schema.getUri().resolve(parentUri);
                        if (!absoluteUri.isAbsolute() || (absoluteUri.isAbsolute()
                                && !schemaStore.getByUri(absoluteUri).isPresent())) {
                            absoluteUri = schema.getParentUri().resolve(parentUri);
                        }
                    }
                    if (absoluteUri != null && absoluteUri.isAbsolute()) {
                        Optional<Schema> schemaLookup = schemaStore.getByUri(absoluteUri);
                        if (schemaLookup.isPresent()) {
                            objectSchema = schemaLookup.get();
                        }
                    }
                }
                // have to resolve schema here

                builder = appendArrayObject(builder, objectSchema, fieldId, seperator);
                break;
            case ARRAY:
                ObjectNode subArrayItems = (ObjectNode) itemsNode.get("items");
                builder = appendArrayItems(builder, schema, fieldId, subArrayItems, seperator);
                break;
            default:
                builder = appendArrayField(builder, schema, fieldId, itemType, seperator);
            }
        } catch (Exception ex) {
            LOGGER.warn("No item type resolvable for {}", fieldId);
        }
    }
    Objects.requireNonNull(builder);
    return builder;
}

From source file:org.dita.dost.module.reader.AbstractReaderModule.java

void parseInputParameters(final AbstractPipelineInput input) {
    ditaDir = toFile(input.getAttribute(ANT_INVOKER_EXT_PARAM_DITADIR));
    if (!ditaDir.isAbsolute()) {
        throw new IllegalArgumentException("DITA-OT installation directory " + ditaDir + " must be absolute");
    }//from  w w  w .  jav  a 2s .  co  m
    validate = Boolean.valueOf(input.getAttribute(ANT_INVOKER_EXT_PARAM_VALIDATE));
    transtype = input.getAttribute(ANT_INVOKER_EXT_PARAM_TRANSTYPE);
    gramcache = "yes".equalsIgnoreCase(input.getAttribute(ANT_INVOKER_EXT_PARAM_GRAMCACHE));
    processingMode = Optional.ofNullable(input.getAttribute(ANT_INVOKER_EXT_PARAM_PROCESSING_MODE))
            .map(String::toUpperCase).map(Mode::valueOf).orElse(Mode.LAX);
    genDebugInfo = Boolean.valueOf(input.getAttribute(ANT_INVOKER_EXT_PARAM_GENERATE_DEBUG_ATTR));

    // For the output control
    job.setGeneratecopyouter(input.getAttribute(ANT_INVOKER_EXT_PARAM_GENERATECOPYOUTTER));
    job.setOutterControl(input.getAttribute(ANT_INVOKER_EXT_PARAM_OUTTERCONTROL));
    job.setOnlyTopicInMap(Boolean.valueOf(input.getAttribute(ANT_INVOKER_EXT_PARAM_ONLYTOPICINMAP)));
    job.setCrawl(Optional.ofNullable(input.getAttribute(ANT_INVOKER_EXT_PARAM_CRAWL))
            .orElse(ANT_INVOKER_EXT_PARAM_CRAWL_VALUE_TOPIC));

    // Set the OutputDir
    final File path = toFile(input.getAttribute(ANT_INVOKER_EXT_PARAM_OUTPUTDIR));
    if (path.isAbsolute()) {
        job.setOutputDir(path);
    } else {
        throw new IllegalArgumentException("Output directory " + path + " must be absolute");
    }

    final File basedir = toFile(input.getAttribute(ANT_INVOKER_PARAM_BASEDIR));

    final URI ditaInputDir = toURI(input.getAttribute(ANT_INVOKER_EXT_PARAM_INPUTDIR));
    if (ditaInputDir != null) {
        if (ditaInputDir.isAbsolute()) {
            baseInputDir = ditaInputDir;
        } else if (ditaInputDir.getPath() != null && ditaInputDir.getPath().startsWith(URI_SEPARATOR)) {
            baseInputDir = setScheme(ditaInputDir, "file");
        } else {
            // XXX Shouldn't this be resolved to current directory, not Ant script base directory?
            baseInputDir = basedir.toURI().resolve(ditaInputDir);
        }
        assert baseInputDir.isAbsolute();
    }

    URI ditaInput = toURI(input.getAttribute(ANT_INVOKER_PARAM_INPUTMAP));
    ditaInput = ditaInput != null ? ditaInput : job.getInputFile();
    if (ditaInput.isAbsolute()) {
        rootFile = ditaInput;
    } else if (ditaInput.getPath() != null && ditaInput.getPath().startsWith(URI_SEPARATOR)) {
        rootFile = setScheme(ditaInput, "file");
    } else if (baseInputDir != null) {
        rootFile = baseInputDir.resolve(ditaInput);
    } else {
        rootFile = basedir.toURI().resolve(ditaInput);
    }
    job.setInputFile(rootFile);

    if (baseInputDir == null) {
        baseInputDir = rootFile.resolve(".");
    }
    job.setInputDir(baseInputDir);

    profilingEnabled = Optional.ofNullable(input.getAttribute(ANT_INVOKER_PARAM_PROFILING_ENABLED))
            .map(Boolean::parseBoolean).orElse(true);
    if (profilingEnabled) {
        ditavalFile = Optional.of(new File(job.tempDir, FILE_NAME_MERGED_DITAVAL)).filter(File::exists)
                .orElse(null);
    }
}

From source file:org.apache.streams.util.schema.SchemaStoreImpl.java

/**
 * resolve full definition of 'items'./*  w w  w . j a va  2 s.c o m*/
 * @param schema Schema
 * @param fieldNode ObjectNode
 * @param resourceId resourceId
 * @return ObjectNode
 */
public ObjectNode resolveItems(Schema schema, ObjectNode fieldNode, String resourceId) {
    ObjectNode schemaItems = NODE_FACTORY.objectNode();
    ObjectNode parentItems = NODE_FACTORY.objectNode();
    if (fieldNode == null) {
        ObjectNode schemaContent = (ObjectNode) schema.getContent();
        if (schemaContent.has("items")) {
            schemaItems = (ObjectNode) schemaContent.get("items");
            if (schema.getParentContent() != null) {
                ObjectNode parentContent = (ObjectNode) schema.getParentContent();
                if (parentContent.has("items")) {
                    parentItems = (ObjectNode) parentContent.get("items");
                }
            }
        }
    } else if (fieldNode.size() > 0) {
        if (fieldNode.has("items") && fieldNode.get("items").isObject() && fieldNode.get("items").size() > 0) {
            schemaItems = (ObjectNode) fieldNode.get("items");
        }
        URI parentUri = null;
        if (fieldNode.has("$ref") || fieldNode.has("extends")) {
            JsonNode refNode = fieldNode.get("$ref");
            JsonNode extendsNode = fieldNode.get("extends");
            if (refNode != null && refNode.isValueNode()) {
                parentUri = URI.create(refNode.asText());
            } else if (extendsNode != null && extendsNode.isObject()) {
                parentUri = URI.create(extendsNode.get("$ref").asText());
            }
            ObjectNode parentContent = null;
            URI absoluteUri;
            if (parentUri.isAbsolute()) {
                absoluteUri = parentUri;
            } else {
                absoluteUri = schema.getUri().resolve(parentUri);
                if (!absoluteUri.isAbsolute()
                        || (absoluteUri.isAbsolute() && !getByUri(absoluteUri).isPresent())) {
                    absoluteUri = schema.getParentUri().resolve(parentUri);
                }
            }
            if (absoluteUri.isAbsolute()) {
                if (getByUri(absoluteUri).isPresent()) {
                    parentContent = (ObjectNode) getByUri(absoluteUri).get().getContent();
                }
                if (parentContent != null && parentContent.isObject() && parentContent.has("items")) {
                    parentItems = (ObjectNode) parentContent.get("items");
                } else if (absoluteUri.getPath().endsWith("#items")) {
                    absoluteUri = URI.create(absoluteUri.toString().replace("#items", ""));
                    parentItems = (ObjectNode) getByUri(absoluteUri).get().getContent().get("items");
                }
            }
        }
    }

    ObjectNode resolvedItems = NODE_FACTORY.objectNode();
    if (parentItems != null && parentItems.size() > 0) {
        resolvedItems = SchemaUtil.mergeProperties(schemaItems, parentItems);
    } else {
        resolvedItems = schemaItems.deepCopy();
    }

    return resolvedItems;
}

From source file:org.kitodo.production.services.data.LdapServerService.java

/**
 * Retrieve home directory of given user.
 *
 * @param user// www  . ja va  2  s.  c o m
 *            User object
 * @return path as URI
 */
public URI getUserHomeDirectory(User user) {
    String userFolderBasePath = ConfigCore.getParameter(ParameterCore.DIR_USERS);

    if (ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.LDAP_USE_LOCAL_DIRECTORY)) {
        return Paths.get(userFolderBasePath, user.getLogin()).toUri();
    }
    Hashtable<String, String> env = initializeWithLdapConnectionSettings(user.getLdapGroup().getLdapServer());
    if (ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.LDAP_USE_TLS)) {
        return getUserHomeDirectoryWithTLS(env, userFolderBasePath, user);
    }

    if (ConfigCore.getBooleanParameter(ParameterCore.LDAP_USE_SIMPLE_AUTH, false)) {
        env.put(Context.SECURITY_AUTHENTICATION, "none");
    }
    DirContext ctx;
    URI userFolderPath = null;
    try {
        ctx = new InitialDirContext(env);
        Attributes attrs = ctx.getAttributes(buildUserDN(user));
        Attribute ldapAttribute = attrs.get("homeDirectory");
        userFolderPath = URI.create((String) ldapAttribute.get(0));
        ctx.close();
    } catch (NamingException e) {
        logger.error(e.getMessage(), e);
    }

    if (Objects.nonNull(userFolderPath) && !userFolderPath.isAbsolute()) {
        if (userFolderPath.getPath().startsWith("/")) {
            userFolderPath = ServiceManager.getFileService().deleteFirstSlashFromPath(userFolderPath);
        }
        return Paths.get(userFolderBasePath, userFolderPath.getRawPath()).toUri();
    } else {
        return userFolderPath;
    }
}

From source file:org.apache.streams.plugins.elasticsearch.StreamsElasticsearchResourceGenerator.java

protected StringBuilder appendArrayItems(StringBuilder builder, Schema schema, String fieldId,
        ObjectNode itemsNode, Character seperator) {
    // not safe to append nothing
    Objects.requireNonNull(builder);
    if (itemsNode == null) {
        return builder;
    }/*from w w  w .j  a  v  a 2 s. co m*/
    if (itemsNode.has("type")) {
        try {
            FieldType itemType = FieldUtil.determineFieldType(itemsNode);
            switch (itemType) {
            case OBJECT:
                Schema objectSchema = null;
                URI parentUri = null;
                if (itemsNode.has("$ref") || itemsNode.has("extends")) {
                    JsonNode refNode = itemsNode.get("$ref");
                    JsonNode extendsNode = itemsNode.get("extends");
                    if (refNode != null && refNode.isValueNode()) {
                        parentUri = URI.create(refNode.asText());
                    } else if (extendsNode != null && extendsNode.isObject()) {
                        parentUri = URI.create(extendsNode.get("$ref").asText());
                    }
                    URI absoluteUri;
                    if (parentUri.isAbsolute()) {
                        absoluteUri = parentUri;
                    } else {
                        absoluteUri = schema.getUri().resolve(parentUri);
                        if (!absoluteUri.isAbsolute() || (absoluteUri.isAbsolute()
                                && !schemaStore.getByUri(absoluteUri).isPresent())) {
                            absoluteUri = schema.getParentUri().resolve(parentUri);
                        }
                    }
                    if (absoluteUri.isAbsolute()) {
                        Optional<Schema> schemaLookup = schemaStore.getByUri(absoluteUri);
                        if (schemaLookup.isPresent()) {
                            objectSchema = schemaLookup.get();
                        }
                    }
                }
                // have to resolve schema here

                builder = appendArrayObject(builder, objectSchema, fieldId, seperator);
                break;
            case ARRAY:
                ObjectNode subArrayItems = (ObjectNode) itemsNode.get("items");
                builder = appendArrayItems(builder, schema, fieldId, subArrayItems, seperator);
                break;
            default:
                builder = appendArrayField(builder, schema, fieldId, itemType, seperator);
            }
        } catch (Exception ex) {
            LOGGER.warn("No item type resolvable for {}", fieldId);
        }
    }
    Objects.requireNonNull(builder);
    return builder;
}

From source file:org.apache.streams.util.schema.SchemaStoreImpl.java

@Override
public ObjectNode resolveProperties(Schema schema, ObjectNode fieldNode, String resourceId) {
    // this should return something more suitable like:
    //   Map<String, Pair<Schema, ObjectNode>>
    ObjectNode schemaProperties = NODE_FACTORY.objectNode();
    ObjectNode parentProperties = NODE_FACTORY.objectNode();
    if (fieldNode == null) {
        ObjectNode schemaContent = (ObjectNode) schema.getContent();
        if (schemaContent.has("properties")) {
            schemaProperties = (ObjectNode) schemaContent.get("properties");
            if (schema.getParentContent() != null) {
                ObjectNode parentContent = (ObjectNode) schema.getParentContent();
                if (parentContent.has("properties")) {
                    parentProperties = (ObjectNode) parentContent.get("properties");
                }/*  w  ww .  ja va 2  s . c om*/
            }
        }
    } else if (fieldNode.size() > 0) {
        if (fieldNode.has("properties") && fieldNode.get("properties").isObject()
                && fieldNode.get("properties").size() > 0) {
            schemaProperties = (ObjectNode) fieldNode.get("properties");
        }
        URI parentUri = null;
        if (fieldNode.has("$ref") || fieldNode.has("extends")) {
            JsonNode refNode = fieldNode.get("$ref");
            JsonNode extendsNode = fieldNode.get("extends");
            if (refNode != null && refNode.isValueNode()) {
                parentUri = URI.create(refNode.asText());
            } else if (extendsNode != null && extendsNode.isObject()) {
                parentUri = URI.create(extendsNode.get("$ref").asText());
            }
            ObjectNode parentContent = null;
            URI absoluteUri;
            if (parentUri.isAbsolute()) {
                absoluteUri = parentUri;
            } else {
                absoluteUri = schema.getUri().resolve(parentUri);
                if (!absoluteUri.isAbsolute()
                        || (absoluteUri.isAbsolute() && !getByUri(absoluteUri).isPresent())) {
                    absoluteUri = schema.getParentUri().resolve(parentUri);
                }
            }
            if (absoluteUri.isAbsolute()) {
                if (getByUri(absoluteUri).isPresent()) {
                    parentContent = (ObjectNode) getByUri(absoluteUri).get().getContent();
                }
                if (parentContent != null && parentContent.isObject() && parentContent.has("properties")) {
                    parentProperties = (ObjectNode) parentContent.get("properties");
                } else if (absoluteUri.getPath().endsWith("#properties")) {
                    absoluteUri = URI.create(absoluteUri.toString().replace("#properties", ""));
                    parentProperties = (ObjectNode) getByUri(absoluteUri).get().getContent().get("properties");
                }
            }
        }

    }

    ObjectNode resolvedProperties = NODE_FACTORY.objectNode();
    if (parentProperties != null && parentProperties.size() > 0) {
        resolvedProperties = SchemaUtil.mergeProperties(schemaProperties, parentProperties);
    } else {
        resolvedProperties = schemaProperties.deepCopy();
    }

    return resolvedProperties;
}

From source file:org.dita.dost.module.reader.AbstractReaderModule.java

/**
 * Read a file and process it for list information.
 *
 * @param ref system path of the file to process
 * @param parseFile file to parse, may be {@code null}
 * @throws DITAOTException if processing failed
 *//*from   ww  w  .  j a va2s . c  o  m*/
void readFile(final Reference ref, final URI parseFile) throws DITAOTException {
    currentFile = ref.filename;
    assert currentFile.isAbsolute();
    final URI src = parseFile != null ? parseFile : currentFile;
    assert src.isAbsolute();
    final URI rel = tempFileNameScheme.generateTempFileName(currentFile);
    outputFile = new File(job.tempDirURI.resolve(rel));
    final File outputDir = outputFile.getParentFile();
    if (!outputDir.exists() && !outputDir.mkdirs()) {
        logger.error("Failed to create output directory " + outputDir.getAbsolutePath());
        return;
    }
    validateMap = Collections.emptyMap();
    defaultValueMap = Collections.emptyMap();
    logger.info("Processing " + currentFile + " to " + outputFile.toURI());
    final String[] params = { currentFile.toString() };

    // Verify stub for current file is in Job
    final FileInfo fi = job.getFileInfo(currentFile);
    if (fi == null) {
        final FileInfo stub = new FileInfo.Builder().src(currentFile).uri(rel).result(currentFile)
                .isInput(currentFile.equals(rootFile)).build();
        job.add(stub);
    }

    //        InputSource in = null;
    Result out = null;
    try {
        final TransformerFactory tf = TransformerFactory.newInstance();
        final SAXTransformerFactory stf = (SAXTransformerFactory) tf;
        final TransformerHandler serializer = stf.newTransformerHandler();

        XMLReader parser = getXmlReader(ref.format);
        XMLReader xmlSource = parser;
        for (final XMLFilter f : getProcessingPipe(currentFile)) {
            f.setParent(xmlSource);
            f.setEntityResolver(CatalogUtils.getCatalogResolver());
            xmlSource = f;
        }

        try {
            final LexicalHandler lexicalHandler = new DTDForwardHandler(xmlSource);
            parser.setProperty("http://xml.org/sax/properties/lexical-handler", lexicalHandler);
            parser.setFeature("http://xml.org/sax/features/lexical-handler", true);
        } catch (final SAXNotRecognizedException e) {
        }

        //            in = new InputSource(src.toString());
        out = new StreamResult(new FileOutputStream(outputFile));
        serializer.setResult(out);
        xmlSource.setContentHandler(serializer);
        xmlSource.parse(src.toString());

        if (listFilter.isValidInput()) {
            processParseResult(currentFile);
            categorizeCurrentFile(ref);
        } else if (!currentFile.equals(rootFile)) {
            logger.warn(MessageUtils.getMessage("DOTJ021W", params).toString());
            failureList.add(currentFile);
        }
    } catch (final RuntimeException e) {
        throw e;
    } catch (final SAXParseException sax) {
        final Exception inner = sax.getException();
        if (inner != null && inner instanceof DITAOTException) {
            throw (DITAOTException) inner;
        }
        if (currentFile.equals(rootFile)) {
            throw new DITAOTException(
                    MessageUtils.getMessage("DOTJ012F", params).toString() + ": " + sax.getMessage(), sax);
        } else if (processingMode == Mode.STRICT) {
            throw new DITAOTException(
                    MessageUtils.getMessage("DOTJ013E", params).toString() + ": " + sax.getMessage(), sax);
        } else {
            logger.error(MessageUtils.getMessage("DOTJ013E", params).toString() + ": " + sax.getMessage(), sax);
        }
        failureList.add(currentFile);
    } catch (final FileNotFoundException e) {
        if (!exists(currentFile)) {
            if (currentFile.equals(rootFile)) {
                throw new DITAOTException(MessageUtils.getMessage("DOTA069F", params).toString(), e);
            } else if (processingMode == Mode.STRICT) {
                throw new DITAOTException(MessageUtils.getMessage("DOTX008E", params).toString(), e);
            } else {
                logger.error(MessageUtils.getMessage("DOTX008E", params).toString());
            }
        } else if (currentFile.equals(rootFile)) {
            throw new DITAOTException(MessageUtils.getMessage("DOTJ078F", params).toString()
                    + " Cannot load file: " + e.getMessage(), e);
        } else if (processingMode == Mode.STRICT) {
            throw new DITAOTException(MessageUtils.getMessage("DOTJ079E", params).toString()
                    + " Cannot load file: " + e.getMessage(), e);
        } else {
            logger.error(MessageUtils.getMessage("DOTJ079E", params).toString() + " Cannot load file: "
                    + e.getMessage());
        }
        failureList.add(currentFile);
    } catch (final Exception e) {
        if (currentFile.equals(rootFile)) {
            throw new DITAOTException(
                    MessageUtils.getMessage("DOTJ012F", params).toString() + ": " + e.getMessage(), e);
        } else if (processingMode == Mode.STRICT) {
            throw new DITAOTException(
                    MessageUtils.getMessage("DOTJ013E", params).toString() + ": " + e.getMessage(), e);
        } else {
            logger.error(MessageUtils.getMessage("DOTJ013E", params).toString() + ": " + e.getMessage(), e);
        }
        failureList.add(currentFile);
    } finally {
        if (out != null) {
            try {
                close(out);
            } catch (final IOException e) {
                logger.error(e.getMessage(), e);
            }
        }
        if (failureList.contains(currentFile)) {
            FileUtils.deleteQuietly(outputFile);
        }
    }

    if (!listFilter.isValidInput() && currentFile.equals(rootFile)) {
        if (validate) {
            // stop the build if all content in the input file was filtered out.
            throw new DITAOTException(MessageUtils.getMessage("DOTJ022F", params).toString());
        } else {
            // stop the build if the content of the file is not valid.
            throw new DITAOTException(MessageUtils.getMessage("DOTJ034F", params).toString());
        }
    }

    doneList.add(currentFile);
    listFilter.reset();
    keydefFilter.reset();

}

From source file:org.restcomm.connect.interpreter.SmsInterpreter.java

protected URI resolve(final URI base, final URI uri) {
    if (base.equals(uri)) {
        return uri;
    } else {/*w  ww .  j a  va 2  s  .c om*/
        if (!uri.isAbsolute()) {
            return base.resolve(uri);
        } else {
            return uri;
        }
    }
}