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:se.vgregion.pubsub.push.impl.DefaultPolledPublisher.java

public DefaultPolledPublisher(URI url) {
    id = UUID.randomUUID();

    Assert.notNull(url);
    this.url = url.toString();
}

From source file:com.art4ul.jcoon.bean.RestClientInterfaceInvocationHandler.java

@Override
public Object invoke(Object object, Method method, Object[] params) throws Throwable {
    LOG.trace("invoke(method = [{}], params = [{}])", new Object[] { method.getName(), params });

    Context context = new RestClientContext(object, method, params, restTemplate);

    if (method.isAnnotationPresent(BaseUrl.class)) {
        baseUrl = retrieveBaseUrl(context);
        return null;
    }/*from   ww w  .  jav a2 s  . com*/
    context.setBaseUrl(baseUrl);

    AnnotationProcessor annotationProcessor = AnnotationProcessor.getInstance();

    // Process class annotations
    annotationProcessor.processAnnotationsBefore(context, originalClass.getAnnotations());

    // Process method annotations
    annotationProcessor.processAnnotationsBefore(context, method.getAnnotations());

    // Process method params
    for (int i = 0; i < params.length; i++) {
        Annotation[] annotations = method.getParameterAnnotations()[i];
        Object paramValue = params[i];
        annotationProcessor.processAnnotationsBefore(context, annotations, paramValue);
    }

    URI uri = context.buildUri();

    LOG.debug("URI= {}", uri.toString());

    HttpEntity httpEntity = context.createHttpEntity();

    Class<?> returnType = null;
    if (!method.getReturnType().equals(Void.TYPE)) {
        returnType = method.getReturnType();
    }

    ResponseEntity responseEntity = context.getRestTemplate().exchange(uri, context.getHttpMethod(), httpEntity,
            returnType);

    context.setResponseEntity(responseEntity);

    // Process method params after invocation
    for (int i = 0; i < params.length; i++) {
        Annotation[] annotations = method.getParameterAnnotations()[i];
        Object paramValue = params[i];
        annotationProcessor.processAnnotationsAfter(context, annotations, paramValue);
    }

    LOG.debug("responseEntity= {}", responseEntity.getBody());
    return responseEntity.getBody();
}

From source file:cool.pandora.modeller.ui.handlers.iiif.PatchManifestHandler.java

private static InputStream getManifestMetadata(final URI collectionIdURI, final URI sequenceIdURI,
        final Map<String, BagInfoField> map) {

    final MetadataTemplate metadataTemplate;
    final List<ManifestScope.Prefix> prefixes = Arrays.asList(new ManifestScope.Prefix(FedoraPrefixes.RDFS),
            new ManifestScope.Prefix(FedoraPrefixes.MODE));

    final String label = getMapValue(map, ManifestPropertiesImpl.FIELD_LABEL);
    final String attribution = getMapValue(map, ManifestPropertiesImpl.FIELD_ATTRIBUTION);
    final String license = getMapValue(map, ManifestPropertiesImpl.FIELD_LICENSE);
    final String rendering = getMapValue(map, ManifestPropertiesImpl.FIELD_RENDERING);
    final String logo = getMapValue(map, ManifestPropertiesImpl.FIELD_INSTITUTION_LOGO_URI);
    final String author = getMapValue(map, ManifestPropertiesImpl.FIELD_AUTHOR);
    final String published = getMapValue(map, ManifestPropertiesImpl.FIELD_PUBLISHED);

    final ManifestScope scope = new ManifestScope().fedoraPrefixes(prefixes)
            .collectionURI(collectionIdURI.toString()).sequenceURI(sequenceIdURI.toString()).label(label)
            .attribution(attribution).license(license).logo(logo).rendering(rendering).author(author)
            .published(published);/*from  w  ww  .jav  a2 s .  co  m*/

    metadataTemplate = MetadataTemplate.template().template("template/sparql-update-manifest" + ".mustache")
            .scope(scope).throwExceptionOnFailure().build();

    final String metadata = unescapeXml(metadataTemplate.render());
    return IOUtils.toInputStream(metadata, UTF_8);
}

From source file:de.otto.jsonhome.generator.HrefVarsGenerator.java

/**
 * Constructs the URI of a var-type as a fragment or sub-resource of a base URI.
 * @param varTypeBaseUri the base URI used to construct the URI of the var type.
 * @param varName the name of the variable
 * @param asFragment create resultung URI as a fragment (#varName) or sub-resource (/varName)
 * @return URI of the varType/*  w  w  w  .ja  v  a  2s.c  o m*/
 */
private URI varTypeUriFrom(final URI varTypeBaseUri, final String varName, final boolean asFragment) {
    final String s = varTypeBaseUri.toString();
    if (asFragment) {
        return s.endsWith("/") ? create(s.substring(0, s.length() - 1) + "#" + varName)
                : create(s + "#" + varName);
    } else {
        return varTypeBaseUri.toString().endsWith("/") ? create(s + varName) : create(s + "/" + varName);
    }
}

From source file:se.vgregion.pubsub.repository.jpa.JpaTopicRepository.java

@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public Topic find(URI url) {
    try {//from w  w w  .j  a  v a 2  s . c o m
        return (Topic) entityManager.createQuery("select l from DefaultTopic l where l.url = :url")
                .setParameter("url", url.toString()).getSingleResult();

    } catch (NoResultException e) {
        return null;
    }
}

From source file:edu.unc.lib.dl.services.FolderManager.java

/**
 * Given a repository path string, creates any folders that do not yet exist along this path.
 * //from  w  w  w.  ja  va2 s  .  com
 * @param path
 *           the desired folder path
 * @throws IngestException
 *            if the path cannot be created
 */
public PID createPath(String path, String owner, String user) throws IngestException {
    log.debug("attempting to create path: " + path);
    if (path.endsWith("/")) {
        path = path.substring(0, path.length() - 1);
    }
    if (!PathUtil.isValidPathString(path)) {
        throw new IngestException("The proposed path is not valid: " + path);
    }
    List<String> slugs = new ArrayList<String>();
    slugs.addAll(Arrays.asList(path.split("/")));
    slugs.remove(0);
    Stack<String> createFolders = new Stack<String>();
    String containerPath = null;
    for (int i = slugs.size(); i >= 0; i--) {
        String test = "/" + StringUtils.join(slugs.subList(0, i), "/");
        PID pid = this.getTripleStoreQueryService().fetchByRepositoryPath(test);
        if (pid == null) {
            // does not exist yet, must create it
            createFolders.add(slugs.get(i - 1));
        } else {
            List<URI> types = this.getTripleStoreQueryService().lookupContentModels(pid);
            if (!types.contains(ContentModelHelper.Model.CONTAINER.getURI())) {
                StringBuffer s = new StringBuffer();
                for (URI type : types) {
                    s.append(type.toString()).append("\t");
                }
                throw new IngestException("The object at the path '" + test
                        + "' is not a folder.  It has these content models:\n" + s.toString());
            }
            containerPath = test;
            break;
        }
    }

    // add folders
    PID lastpid = null;
    while (createFolders.size() > 0) {
        String slug = createFolders.pop();
        SingleFolderSIP sip = new SingleFolderSIP();
        PID containerPID = this.getTripleStoreQueryService().fetchByRepositoryPath(containerPath);
        sip.setContainerPID(containerPID);
        if ("/".equals(containerPath)) {
            containerPath = containerPath + slug;
        } else {
            containerPath = containerPath + "/" + slug;
        }
        sip.setSlug(slug);
        sip.setAllowIndexing(true);
        DepositRecord record = new DepositRecord(user, owner, DepositMethod.Unspecified);
        record.setMessage("creating a new folder path");
        IngestResult result = this.getDigitalObjectManager().addWhileBlocking(sip, record);
        lastpid = result.derivedPIDs.iterator().next();
    }
    return lastpid;
}

From source file:api.BaiduFolkMusicApi.java

public String getDefaultRateBySongId(String songId) {

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("id", songId));
    parameters.add(new BasicNameValuePair("action", "listSongRate"));
    URI rateRequestUri = this.getRequestUri(parameters);

    String data = this.httpClient.doGet(rateRequestUri.toString());
    if (data != null) {
        String rates[] = data.split(this.dataSeparator);
        return rates[0];
    }//from  w w  w  .  java 2  s. c o  m

    return null;
}

From source file:com.microsoft.alm.plugin.context.ServerContextBuilder.java

public ServerContextBuilder uri(final URI newUri) {
    this.uri = newUri;
    if (!UrlHelper.isGitRemoteUrl(newUri.toString())) {
        this.serverUri = this.uri;
    }/*from  ww w. j  a  va2 s .c o  m*/
    return this;
}

From source file:org.nekorp.workflow.desktop.data.access.rest.AutoDAOImp.java

@Override
public void guardar(Auto dato) {
    URI resource = factory.getTemplate().postForLocation(factory.getRootUlr() + "/autos", dato);
    String[] uri = StringUtils.split(resource.toString(), '/');
    String id = uri[uri.length - 1];
    dato.setNumeroSerie(id);//from w  ww  .  j  a  v  a 2  s.c  om
}

From source file:io.curly.commons.web.hateoas.ZuulAwareMappingResolver.java

public String resolve(URI hostUri, String... fragments) {
    return this.resolve(hostUri.toString(), fragments);
}