Example usage for java.net URI toASCIIString

List of usage examples for java.net URI toASCIIString

Introduction

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

Prototype

public String toASCIIString() 

Source Link

Document

Returns the content of this URI as a US-ASCII string.

Usage

From source file:org.apache.olingo.fit.rest.ResolvingReferencesInterceptor.java

@Override
public void handleMessage(final Message message) throws Fault {
    final String path = (String) message.get(Message.PATH_INFO);
    final String query = (String) message.get(Message.QUERY_STRING);

    try {/*from   w w  w.  j a  va  2  s .  co m*/
        if (path.endsWith("$entity") && StringUtils.isNotBlank(query)
                && URLDecoder.decode(query, "UTF-8").contains("$id=")) {

            final String id = URLDecoder.decode(query, "UTF-8");
            final String newURL = id.substring(id.indexOf("$id=") + 4);

            final URI uri = URI.create(newURL);

            message.put(Message.REQUEST_URL, uri.toASCIIString());
            message.put(Message.REQUEST_URI, uri.getPath());
            message.put(Message.PATH_INFO, uri.getPath());
        }
    } catch (UnsupportedEncodingException ignore) {
        // ignore
    }
}

From source file:org.apache.taverna.scufl2.translator.t2flow.t23activities.XPathActivityParser.java

@Override
public boolean canHandlePlugin(URI activityURI) {
    String activityUriStr = activityURI.toASCIIString();
    return (activityUriStr.startsWith(xpathRavenURI.toASCIIString())
            || activityUriStr.startsWith(ravenUIURI.toASCIIString())) && activityUriStr.endsWith(className);
}

From source file:org.jclouds.vfs.provider.blobstore.BlobStoreFileNameParser.java

public FileName parseUri(final VfsComponentContext context, FileName base, String filename)
        throws FileSystemException {

    // if there are unencoded characters in the password, things break.
    URI uri = HttpUtils.createUri(filename);

    filename = uri.toASCIIString();

    Credentials creds = Credentials.parse(uri);

    StringBuffer name = new StringBuffer();

    // Extract the scheme and authority parts
    Authority auth = extractToPath(filename, name);

    // Decode and adjust separators
    UriParser.canonicalizePath(name, 0, name.length(), this);
    UriParser.fixSeparators(name);/* w w w .  ja  va  2  s . c  o m*/

    // Extract the container
    String container = UriParser.extractFirstElement(name);
    if (container == null || container.length() == 0) {
        throw new FileSystemException("vfs.provider.blobstore/missing-container-name.error", filename);
    }

    // Normalise the path. Do this after extracting the container name
    FileType fileType = UriParser.normalisePath(name);
    String path = name.toString();

    return new BlobStoreFileName(auth.hostName, creds.identity, creds.credential, path, fileType, container);
}

From source file:com.jaeksoft.searchlib.remote.UriWriteObject.java

public UriWriteObject(URI uri, Externalizable object) throws IOException {
    HttpPut httpPut = new HttpPut(uri.toASCIIString());
    httpPut.setConfig(requestConfig);/*from   w w  w  .ja  v a  2 s  .co  m*/
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    swo = new StreamWriteObject(baos);
    swo.write(object);
    swo.close(true);
    swo = null;
    sro = null;
    httpPut.setEntity(new ByteArrayEntity(baos.toByteArray()));
    execute(httpPut);
}

From source file:com.almende.eve.algorithms.test.agents.EventAgent.java

/**
 * Report event received.//from  w  w  w .  j  a v a2  s.  c  o m
 *
 * @param sender
 *            the sender
 */
@Access(AccessType.PUBLIC)
public void reportEventReceived(@Sender URI sender) {
    getState().put(sender.toASCIIString().replace("local:", ""), true);
}

From source file:org.apache.taverna.scufl2.translator.t2flow.defaultdispatchstack.LoopParser.java

@Override
public boolean canHandlePlugin(URI pluginURI) {
    String uriStr = pluginURI.toASCIIString();
    return uriStr.startsWith(modelRavenURI.toASCIIString()) && uriStr.endsWith(className);
}

From source file:com.msopentech.odatajclient.engine.data.json.JSONLinkCollection.java

/**
 * {@inheritDoc }//from w  ww.  j a  v  a 2s  . co  m
 */
@JsonIgnore
@Override
public void setNext(final URI next) {
    this.next = next == null ? null : next.toASCIIString();
}

From source file:org.openlegacy.rpc.mvc.web.LoginController.java

@RequestMapping(value = "Login", method = RequestMethod.POST)
public String login(Model uiModel, HttpServletRequest request,
        @RequestParam(value = "partial", required = false) String partial,
        @RequestParam(value = "requestedUrl", required = false) String requestedUrl) throws URISyntaxException {

    rpcSession.disconnect();/*  w  ww.  j av a  2 s. c  o m*/
    LoginModel loginModel = new LoginModel();
    ServletRequestDataBinder binder = new ServletRequestDataBinder(loginModel);
    binder.bind(request);

    try {
        rpcSession.login(loginModel.getUser(), loginModel.getPassword());
        request.getSession().setAttribute("ol_loggedInUser", loginModel.getUser());
    } catch (Exception e) {
        rpcSession.disconnect();
        loginModel.setErrorMessage(e.getMessage());
        uiModel.addAttribute(MvcConstants.LOGIN_MODEL, loginModel);
        return MvcConstants.LOGIN_VIEW;
    }

    if (StringUtils.isNotEmpty(requestedUrl)) {
        URI uri = new URI(requestedUrl);
        return MvcConstants.REDIRECT + uri.toASCIIString();
    }

    return MvcConstants.REDIRECT + afterLoginURL;
}

From source file:ca.ualberta.physics.cssdp.util.JSONURISerializer.java

@Override
public void serialize(URI value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    jgen.writeString(value.toASCIIString());
}

From source file:com.easarrive.aws.plugins.common.service.impl.TestS3Service.java

@Test
public void getObject() {
    S3Object object = s3Service.getObject(client, bucketName, key);
    System.out.println(object);//from   www .j a  v a  2 s.  c o  m
    URI uri = object.getObjectContent().getHttpRequest().getURI();
    String url = uri.toASCIIString();
    System.out.println(url);
    String url2 = uri.toString();
    System.out.println(url2);
}