Example usage for java.net URI toString

List of usage examples for java.net URI toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns the content of this URI as a string.

Usage

From source file:com.github.brandtg.pantopod.crawler.DbiBasedCrawlingEventHandler.java

@Override
protected boolean shouldExplore(URI url) {
    try (Handle handle = dbi.open()) {
        Integer count = handle.createQuery("SELECT COUNT(*) FROM `pantopod_crawler` WHERE `url` = :url")
                .bind("url", url.toString()).map(IntegerMapper.FIRST).first();
        return count == 0;
    }// www. ja  v a  2 s  .c o  m
}

From source file:org.fcrepo.client.MoveBuilder.java

/**
 * Instantiate builder/*from   www  .  j a va2s  . c  o m*/
 * 
 * @param sourceUrl uri of the resource
 * @param destinationUrl uri for the new path for the moved resource
 * @param client the client
 */
protected MoveBuilder(final URI sourceUrl, final URI destinationUrl, final FcrepoClient client) {
    super(sourceUrl, client);
    Args.notNull(destinationUrl, "Destination URL");
    // Add the required destination header to the request
    request.addHeader(DESTINATION, destinationUrl.toString());
}

From source file:org.geosdi.geoplatform.experimental.openam.support.config.connector.search.OpenAMSearchConnector.java

/**
 * @param uid//from w  w w  .j av  a  2  s .com
 * @return {@link OpenAMSearchUsersResult}
 * @throws Exception
 */
@Override
public OpenAMSearchUsersResult searchOpenAMUserByUid(String uid) throws Exception {
    Preconditions.checkArgument((uid != null) && !(uid.isEmpty()),
            "The UID Parameter must not be " + "null or an empty String.");
    logger.debug("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@TRYING TO Search USER by UID : {}  WITH "
            + "OPENAM_CONNECTOR_SETTINGS : {} \n", uid, this.openAMConnectorSettings);

    OpenAMSearchUsersRequest openAMSearchUsersRequest = this.openAMRequestMediator.getRequest(SEARCH_USERS);
    URIBuilder uriBuilder = super.buildURI(this.openAMConnectorSettings, openAMSearchUsersRequest);
    SearchUserByUidParameter parameter = new SearchUserByUidParameter(uid);
    uriBuilder.setParameter(parameter.getkey(), URLDecoder.decode(parameter.getValue(), "UTF-8"));

    URI searchURI = uriBuilder.build();
    logger.debug("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@OPENAM_SEARCH_USER_CONNECTOR_URI : {}\n",
            URLDecoder.decode(searchURI.toString(), "UTF-8"));

    IOpenAMAuthenticate openAMAuthenticate = this.authenticate();
    logger.debug("::::::::::::::::::::::::::::::AUTHENTICATE_FOR_SEARCH_USER : {}\n", openAMAuthenticate);

    HttpGet httpGet = new HttpGet(searchURI);
    httpGet.addHeader("Content-Type", "application/json");
    httpGet.addHeader(this.openAMCookieInfo.getOpenAMCookie(), openAMAuthenticate.getTokenId());

    CloseableHttpResponse response = this.httpClient.execute(httpGet);

    if (response.getStatusLine().getStatusCode() != 200) {
        throw new IllegalStateException(
                "OpenAMSearchUser Error Code : " + response.getStatusLine().getStatusCode());
    }
    this.logout(openAMAuthenticate.getTokenId());
    OpenAMSearchUsersResult result = this.openAMReader.readValue(response.getEntity().getContent(),
            OpenAMSearchUsersResult.class);
    logger.trace(":::::::::::::::::::::::::::OPENAM_SEARCH_USERS_RESULT_AS_STRING : \n{}\n",
            this.openAMReader.writeValueAsString(result));
    return result;
}

From source file:com.recomdata.transmart.data.export.util.ExportImageProcessor.java

private String getFilename(URI imageURI) {
    String filename = null;/*from   w  ww  .j  a  v a2 s.c  o  m*/
    if (StringUtils.equalsIgnoreCase("file", imageURI.getScheme())) {
        filename = (new File(imageURI.toString())).getName();
    } else {
        if (null != imageURI) {
            String imageURIStr = imageURI.toString();
            if (StringUtils.isNotEmpty(imageURIStr)) {
                int loc = imageURIStr.lastIndexOf("/");
                if (loc == imageURIStr.length() - 1) {
                    loc = (imageURIStr.substring(0, loc - 1)).lastIndexOf("/");
                }
                filename = imageURIStr.substring(loc + 1, imageURIStr.length());
            }
        }
    }

    return filename;
}

From source file:com.github.brandtg.pantopod.crawler.DbiBasedCrawlingEventHandler.java

@Override
protected boolean hasError(URI url) {
    try (Handle handle = dbi.open()) {
        Boolean isError = handle.createQuery("SELECT `error` FROM `pantopod_crawler` WHERE `url` = :url")
                .bind("url", url.toString()).map(BooleanMapper.FIRST).first();
        return isError != null;
    }/*from  w  w w.  j  a  v a 2  s .  c o m*/
}

From source file:ch.sentric.URL.java

/**
 * The constructor, initializing a url from {@link URI}.
 * /*  w ww  .ja v a2 s .c o m*/
 * @param uri
 *            as URI
 * @throws MalformedURLException
 *             when url could not be parsed
 */
public URL(final URI uri) throws MalformedURLException {
    this.givenInputUrl = uri.toString();
    parse(uri.toString());
}

From source file:net.ripe.rpki.validator.util.UriToFileMapper.java

public File map(URI uri, ValidationResult result) {
    Validate.notNull(result);/*  ww  w  .j a v a  2 s .c om*/
    Validate.notNull(uri);
    result.rejectIfFalse(RSYNC_SCHEME.equalsIgnoreCase(uri.getScheme()), VALIDATOR_URI_RSYNC_SCHEME,
            uri.toString());
    result.rejectIfNull(uri.getHost(), VALIDATOR_URI_HOST, uri.toString());
    result.rejectIfNull(uri.getRawPath(), VALIDATOR_URI_PATH, uri.toString());
    String s = uri.toString();
    result.rejectIfTrue(s.contains("/../") || s.endsWith("/.."), VALIDATOR_URI_SAFETY, uri.toString());
    if (result.hasFailureForCurrentLocation()) {
        return null;
    }
    return new File(new File(targetDirectory, getHostPortAsString(uri)), uri.getRawPath());
}

From source file:org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipSerializer.java

@SuppressWarnings("incomplete-switch")
@Override// w  w  w .ja va  2s.  c  om
public void serialize(final T value, final JsonGenerator gen, final SerializerProvider provider)
        throws IOException, JsonGenerationException {
    gen.writeStartObject();
    gen.writeStringField(RELATIONSHIP_TYPE, value.getType().name());
    gen.writeStringField(POM_LOCATION_URI, value.getPomLocation().toString());
    gen.writeBooleanField(INHERITED, value.isInherited());

    Set<URI> sources = value.getSources();
    if (sources != null) {
        for (Iterator<URI> iter = sources.iterator(); iter.hasNext();) {
            if (iter.next() == null) {
                iter.remove();
            }
        }
        if (!sources.isEmpty()) {
            gen.writeArrayFieldStart(SOURCE_URIS);
            for (URI uri : sources) {
                if (uri == null) {
                    continue;
                }
                gen.writeString(uri.toString());
            }
            gen.writeEndArray();
        }
    }
    provider.defaultSerializeField(DECLARING_REF, value.getDeclaring(), gen);
    provider.defaultSerializeField(TARGET_REF, value.getTarget(), gen);

    switch (value.getType()) {
    case BOM:
        gen.writeBooleanField(MIXIN, value.isMixin());
        break;
    case DEPENDENCY: {
        gen.writeStringField(SCOPE, ((DependencyRelationship) value).getScope().realName());
        gen.writeBooleanField(MANAGED, value.isManaged());
        gen.writeBooleanField(OPTIONAL, ((DependencyRelationship) value).isOptional());
        break;
    }
    case PLUGIN_DEP: {
        provider.defaultSerializeField(PLUGIN_REF, ((PluginDependencyRelationship) value).getPlugin(), gen);
        gen.writeBooleanField(MANAGED, value.isManaged());
        break;
    }
    case PLUGIN: {

        gen.writeBooleanField(MANAGED, value.isManaged());
        gen.writeBooleanField(REPORTING, ((PluginRelationship) value).isReporting());
        break;
    }
    }

    gen.writeNumberField(INDEX, value.getIndex());
    gen.writeEndObject();
}

From source file:com.vmware.appfactory.common.InputFile.java

/**
 * Set the full URI to this file.//from   ww  w.  java 2  s  . c  om
 * @param uri
 */
public void setURI(URI uri) {
    if (uri != null) {
        _uriStr = uri.toString().trim();
    } else {
        _uriStr = null;
    }
}