Example usage for java.net URISyntaxException getMessage

List of usage examples for java.net URISyntaxException getMessage

Introduction

In this page you can find the example usage for java.net URISyntaxException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns a string describing the parse error.

Usage

From source file:ph.com.globe.connect.Authentication.java

/**
 * Returns the Oauth dialog url./*w  w w.  j a v a  2 s  .  c om*/
 * 
 * @return String
 * @throws ApiException api exception
 */
public String getDialogUrl() throws ApiException {
    // try parsing url
    try {
        // build url
        String url = this.API_HOST + this.DIALOG_URL;
        // initialize url builder
        URIBuilder builder = new URIBuilder(url);

        // set app_id parameter
        builder.setParameter("app_id", this.appId);

        // build the url
        url = builder.build().toString();

        return url;
    } catch (URISyntaxException e) {
        // throw exception
        throw new ApiException(e.getMessage());
    }
}

From source file:com.orange.mmp.dao.flf.MidletDaoFlfImpl.java

public Midlet createOrUdpdate(Midlet midlet) throws MMPDaoException {
    if (midlet == null || midlet.getJadLocation() == null || midlet.getJarLocation() == null
            || midlet.getType() == null) {
        throw new MMPDaoException("missing or bad data access object");
    }/*w  w w .j  a v  a  2  s .c  o  m*/

    try {
        this.lock.lock();
        File typeFolder = new File(this.path, midlet.getType());
        if (!typeFolder.isDirectory())
            FileUtils.forceMkdir(typeFolder);
        File jadFile = new File(new URI(midlet.getJadLocation()));
        FileUtils.copyFileToDirectory(jadFile, typeFolder);
        File jarFile = new File(new URI(midlet.getJarLocation()));
        FileUtils.copyFileToDirectory(jarFile, typeFolder);
        FileUtils.touch(new File(this.path));
    } catch (IOException ioe) {
        throw new MMPDaoException("failed to add PFM : " + ioe.getMessage());
    } catch (URISyntaxException use) {
        throw new MMPDaoException("failed to add PFM : " + use.getMessage());
    } finally {
        this.lock.unlock();
    }

    return midlet;
}

From source file:org.dataconservancy.ui.it.support.UpdateCollectionRequest.java

public HttpPost asHttpPost() {
    if (!collectionSet) {
        throw new IllegalStateException("Collection not set: call setCollection(Collection) first.");
    }/*from  w ww  .ja  v  a  2 s.  c om*/
    if (collectionId == null) {
        throw new IllegalStateException("CollectionId must be set. call setCollectionId(id) first.");
    }

    HttpPost post = null;
    try {
        post = new HttpPost(urlConfig.getUpdateCollectionUrl().toURI());
    } catch (URISyntaxException e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("collectionId", collectionId));
    params.add(new BasicNameValuePair("collection.title", title));
    params.add(new BasicNameValuePair("collection.summary", summary));
    params.add(new BasicNameValuePair("collection.id", id));
    for (int i = 0; i < alternateIds.size(); i++) {
        params.add(new BasicNameValuePair("collection.alternateIds[" + i + "]", alternateIds.get(i)));
    }
    for (int i = 0; i < creators.size(); i++) {
        params.add(new BasicNameValuePair("collection.creators[" + i + "].prefixes",
                creators.get(i).getPrefixes()));
        params.add(new BasicNameValuePair("collection.creators[" + i + "].givenNames",
                creators.get(i).getGivenNames()));
        params.add(new BasicNameValuePair("collection.creators[" + i + "].middleNames",
                creators.get(i).getMiddleNames()));
        params.add(new BasicNameValuePair("collection.creators[" + i + "].familyNames",
                creators.get(i).getFamilyNames()));
        params.add(new BasicNameValuePair("collection.creators[" + i + "].suffixes",
                creators.get(i).getSuffixes()));
    }
    for (int i = 0; i < contactInfos.size(); i++) {
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].name",
                contactInfos.get(i).getName()));
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].role",
                contactInfos.get(i).getRole()));
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].physicalAddress.streetAddress",
                contactInfos.get(i).getPhysicalAddress().getStreetAddress()));
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].physicalAddress.city",
                contactInfos.get(i).getPhysicalAddress().getCity()));
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].physicalAddress.state",
                contactInfos.get(i).getPhysicalAddress().getState()));
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].physicalAddress.zipCode",
                contactInfos.get(i).getPhysicalAddress().getZipCode()));
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].physicalAddress.country",
                contactInfos.get(i).getPhysicalAddress().getCountry()));
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].emailAddress",
                contactInfos.get(i).getEmailAddress()));
        params.add(new BasicNameValuePair("collection.contactInfoList[" + i + "].phoneNumber",
                contactInfos.get(i).getPhoneNumber()));
    }
    params.add(new BasicNameValuePair(STRIPES_EVENT, "Update Collection"));

    HttpEntity entity = null;
    try {
        entity = new UrlEncodedFormEntity(params, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    post.setEntity(entity);

    return post;
}

From source file:org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.java

public static Set<URI> getURISetProperty(final String prop, final PropertyContainer container,
        final URI defaultValue) {
    final Set<URI> result = new HashSet<URI>();

    if (container.hasProperty(prop)) {
        final String[] uris = (String[]) container.getProperty(prop);
        for (final String uri : uris) {
            try {
                final URI u = new URI(uri);
                if (!result.contains(u)) {
                    result.add(u);/*from   ww  w  . j a v  a2  s . c om*/
                }
            } catch (final URISyntaxException e) {
                Logger logger = LoggerFactory.getLogger(Conversions.class);
                logger.warn(String.format("Failed to construct URI from: %s\nContainer: %s\nReason: %s",
                        container, uri, e.getMessage()), e);
            }
        }
    }

    if (defaultValue != null && result.isEmpty()) {
        result.add(defaultValue);
    }

    return result;
}

From source file:com.jkoolcloud.jesl.net.socket.SocketClient.java

/**
 * {@inheritDoc}/*from  www . ja  v  a2s.  c o  m*/
 */
@Override
public URI getURI() {
    try {
        return new URI("tcp" + (isSecure() ? "s" : "") + "://" + host + ":" + port);
    } catch (URISyntaxException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.ml.core.impl.BAMInputAdapter.java

/**
 * Read a data set from a table in BAM/*from w ww .jav a  2 s.com*/
 * 
 * @param tableResourcePath     Resource path of the table. Takes the format: {tableName}/{from}/{to}/{start}/{count}
 *                              where {tableName}   Name of the table from which, the records are retrieved
                                  {from}        The starting time to retrieve records from (optional)
                                  {to}          The ending time to get records to (optional)
                                  {start}       The paginated index from value (optional)
                                  {count}       The paginated records count to be read (optional)
                            pass -1 for optional fields if they are not used.
 * @return                      the given data-set as an {@link InputStream}
 * @throws                      MLInputAdapterException
 */
public InputStream readDataset(String tableResourcePath) throws MLInputAdapterException {
    String tableUri = MLCoreServiceValueHolder.getInstance().getBamServerUrl() + "/analytics/tables/"
            + tableResourcePath;
    try {
        URI uri = new URI(tableUri);
        return readDataset(uri);
    } catch (URISyntaxException e) {
        throw new MLInputAdapterException("Invalid URI Syntax: " + tableUri + " : " + e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.sample.service.EventsManagerService.java

@GET
@Path("/authenticate")
public Response auth() {
    StringBuilder oauthUrlBuilder = new StringBuilder().append("https://accounts.google.com/o/oauth2/auth")
            .append("?client_id=").append(EventManagerConstants.CLIENT_ID) // the client id from the api console registration
            .append("&response_type=code").append("&scope=")
            .append(URLEncoder// w  ww .  ja  va2  s  . c  o  m
                    .encode("openid email https://docs.google.com/feeds https://spreadsheets.google.com/feeds")) // scope is the api permissions we are requesting
            .append("&redirect_uri=").append(URLEncoder.encode(EventManagerConstants.OAUTH_REDIRECT_URL)) // the servlet that google redirects to after authorization
            .append("&state=").append(URLEncoder.encode("success")).append("&access_type=offline") // here we are asking to access to user's data while they are not signed in
            .append("&approval_prompt=force"); // this requires them to verify which account to use, if they are already signed in

    URI oauthUrl = null;

    try {
        oauthUrl = new URI(oauthUrlBuilder.toString());
    } catch (URISyntaxException e) {
        return Response.status(500).entity(e.getMessage()).build();
    }

    if (oauthUrl != null) {
        return Response.seeOther(oauthUrl).build();
    } else {
        throw new EventsManagerWebAppException(Response.Status.INTERNAL_SERVER_ERROR);
    }
}

From source file:com.silverpeas.attachment.web.AttachmentEntity.java

private URI string2URI(String str) {
    URI uri;/*from   ww  w.  j  a  v a2  s  . com*/
    try {
        uri = new URI(str);
    } catch (URISyntaxException ex) {
        Logger.getLogger(NodeEntity.class.getName()).log(Level.SEVERE, null, ex);
        throw new RuntimeException(ex.getMessage(), ex);
    }
    return uri;
}

From source file:com.turn.ttorrent.client.tracker.HTTPTrackerClient.java

/**
 * Build, send and process a tracker announce request.
 *
 * <p>/* w  w w.j av a  2  s .  c o  m*/
 * This function first builds an announce request for the specified event
 * with all the required parameters. Then, the request is made to the
 * tracker and the response analyzed.
 * </p>
 *
 * <p>
 * All registered {@link AnnounceResponseListener} objects are then fired
 * with the decoded payload.
 * </p>
 *
 * @param event The announce event type (can be AnnounceEvent.NONE for
 * periodic updates).
 * @param inhibitEvents Prevent event listeners from being notified.
 */
@Override
public void announce(AnnounceResponseListener listener, TorrentMetadataProvider torrent, URI tracker,
        TrackerMessage.AnnounceEvent event, boolean inhibitEvents) throws AnnounceException {
    LOG.info("Announcing{} to tracker with {}U/{}D/{}L bytes...",
            new Object[] { TrackerClient.formatAnnounceEvent(event), torrent.getUploaded(),
                    torrent.getDownloaded(), torrent.getLeft() });

    try {
        HTTPAnnounceRequestMessage message = new HTTPAnnounceRequestMessage(torrent.getInfoHash(),
                getEnvironment().getLocalPeerId(), getPeerAddress(), torrent.getUploaded(),
                torrent.getDownloaded(), torrent.getLeft(), true, false, event,
                AnnounceRequestMessage.DEFAULT_NUM_WANT);
        URI target = message.toURI(tracker);
        HttpGet request = new HttpGet(target);
        HttpResponseCallback callback = new HttpResponseCallback(listener, request, tracker);
        httpclient.execute(request, callback);
    } catch (URISyntaxException mue) {
        throw new AnnounceException("Invalid announce URI (" + mue.getMessage() + ")", mue);
    } catch (IOException ioe) {
        throw new AnnounceException("Error building announce request (" + ioe.getMessage() + ")", ioe);
    }
}

From source file:org.apache.hadoop.hdfs.notifier.server.ServerLogReaderAvatar.java

public ServerLogReaderAvatar(IServerCore core) throws IOException {

    super(core, null);

    // append the service name to each avatar meta directory name
    String serviceName = core.getServiceName();
    if (serviceName != null && !serviceName.equals("")) {
        AvatarNode.adjustMetaDirectoryNames(conf, serviceName);
    } else {/*from w w w.  j  a v  a2s. c  o  m*/
        serviceName = "";
    }

    // edits directory uri
    String editsStringZero = core.getConfiguration().get(AvatarNode.DFS_SHARED_EDITS_DIR0_KEY);
    String editsStringOne = core.getConfiguration().get(AvatarNode.DFS_SHARED_EDITS_DIR1_KEY);

    editsUriZero = Util.stringAsURI(editsStringZero);
    editsUriOne = Util.stringAsURI(editsStringOne);

    remoteJournalManagerZero = constructJournalManager(editsUriZero);
    remoteJournalManagerOne = constructJournalManager(editsUriOne);

    try {
        this.logicalName = new URI("hdfs://" + conf.get(
                NameNode.DFS_NAMENODE_RPC_ADDRESS_KEY + (serviceName.isEmpty() ? "" : "." + serviceName), ""));

        this.avatarZeroURI = addrToURI(conf.get(
                AvatarNode.DFS_NAMENODE_RPC_ADDRESS0_KEY + (serviceName.isEmpty() ? "" : "." + serviceName),
                ""));
        this.avatarOneURI = addrToURI(conf.get(
                AvatarNode.DFS_NAMENODE_RPC_ADDRESS1_KEY + (serviceName.isEmpty() ? "" : "." + serviceName),
                ""));

        zk = new CachingAvatarZooKeeperClient(conf, null);

        LOG.info("Initializing input stream");
        initialize();
        LOG.info("Initialization completed");
    } catch (URISyntaxException e) {
        throwIOException(e.getMessage(), e);
    }
}