Example usage for java.net URISyntaxException printStackTrace

List of usage examples for java.net URISyntaxException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.xwiki.android.rest.HttpConnector.java

/**
 * Gets raw data from the response as a InputStream
 * /*from  ww  w  .  ja  va2s .c  o  m*/
 * @param Uri URL of XWiki RESTful API
 * @return InputStream of the HTTP Get method execution
 */
public InputStream getResponseAttachment(String Uri) {
    initialize();

    HttpGet request = new HttpGet();

    try {
        requestUri = new URI(Uri);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    setCredentials();

    request.setURI(requestUri);
    Log.d("Request URL", Uri);
    try {

        response = client.execute(request);
        Log.d("Response status", response.getStatusLine().toString());

        // in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

        return response.getEntity().getContent();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return null;
}

From source file:org.xwiki.android.rest.HttpConnector.java

/**
 * Perform HTTP Put method with the raw data file
 * // w  ww .  j  a  v  a 2s .  com
 * @param Uri URL of XWiki RESTful API
 * @param filePath path of the file name which to be sent over the HTTP connection
 * @return status of the HTTP Put method execution
 */
public String putRaw(String Uri, String filePath) {
    initialize();

    HttpPut request = new HttpPut();

    try {
        requestUri = new URI(Uri);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    setCredentials();

    request.setURI(requestUri);
    Log.d("Request URL", Uri);

    try {

        File file = new File(filePath);
        FileEntity fe = new FileEntity(file, "/");

        request.setEntity(fe);
        // request.setHeader("Content-Type","application/xml;charset=UTF-8");

        response = client.execute(request);
        Log.d("Response status", response.getStatusLine().toString());
        return response.getStatusLine().toString();

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return "error";
}

From source file:org.xwiki.android.rest.HttpConnector.java

/**
 * Checks whether user credentials are valid in the provided remote XWiki
 * // w  ww.  j  a  va 2 s . c om
 * @param username username of the XWiki user account
 * @param password password of the XWiki user account
 * @param Url URL of the XWiki instance
 * @return HTTP response code of the connection
 */
public int checkLogin(String username, String password, String Url) {

    initialize();

    HttpGet request = new HttpGet();

    String Uri;
    int responseCode = 0;

    Uri = "http://" + Url + "/xwiki/rest/";

    try {
        requestUri = new URI(Uri);

    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    setCredentials();

    request.setURI(requestUri);
    Log.d("Request URL", Uri);
    try {

        response = client.execute(request);
        Log.d("Response status", response.getStatusLine().toString());

        String[] responseParts = response.getStatusLine().toString().split(" ");
        responseCode = Integer.parseInt(responseParts[1]);

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Log.d("response code", String.valueOf(responseCode));
    return responseCode;
}

From source file:org.xwiki.android.rest.HttpConnector.java

/**
 * Perform HTTP Post method execution and return its response status
 * //from w ww .  j  ava  2s . co m
 * @param Uri URL of XWiki RESTful API
 * @param content content to be posted to the server
 * @return status code of the Post method execution
 */
public String postRequest(String Uri, String content) {
    initialize();

    HttpPost request = new HttpPost();

    try {
        requestUri = new URI(Uri);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    setCredentials();

    request.setURI(requestUri);
    Log.d("Request URL", Uri);

    try {
        Log.d("Post content", "content=" + content);
        StringEntity se = new StringEntity(content, "UTF-8");

        se.setContentType("application/xml");
        // se.setContentType("text/plain");
        request.setEntity(se);
        request.setHeader("Content-Type", "application/xml;charset=UTF-8");

        response = client.execute(request);
        Log.d("Response status", response.getStatusLine().toString());
        return response.getStatusLine().toString();

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return "error";
}

From source file:org.xwiki.android.rest.HttpConnector.java

/**
 * Perform HTTP Put method execution and return its response status
 * //from  w w  w . j  av  a 2s .  c  o  m
 * @param Uri URL of XWiki RESTful API
 * @param content content to be posted to the server
 * @return status code of the Put method execution
 */
public String putRequest(String Uri, String content) {
    initialize();

    HttpPut request = new HttpPut();

    try {
        requestUri = new URI(Uri);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    setCredentials();

    request.setURI(requestUri);
    Log.d("Request URL", Uri);

    try {
        Log.d("Put content", "content=" + content);
        StringEntity se = new StringEntity(content, "UTF-8");

        se.setContentType("application/xml");
        // se.setContentType("text/plain");
        request.setEntity(se);
        request.setHeader("Content-Type", "application/xml;charset=UTF-8");

        response = client.execute(request);
        Log.d("Response status", response.getStatusLine().toString());
        return response.getStatusLine().toString();

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return "error";
}

From source file:eu.planets_project.tb.impl.model.exec.ServiceRecordImpl.java

/** */
private ServiceDescription serviceDescriptionFromRecord() {
    ServiceDescription.Builder sdb = new ServiceDescription.Builder(this.serviceName, this.serviceType);
    sdb.description("This old service is not longer available.");
    sdb.version(this.serviceVersion);
    // The endpoint:
    try {//from w  w  w  .  j a  va 2 s .c om
        sdb.endpoint(new URL(this.endpoint));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    // Tool info:
    URI toolUri = null;
    try {
        if (this.toolIdentifier != null) {
            toolUri = new URI(this.toolIdentifier);
        }
    } catch (URISyntaxException e1) {
        e1.printStackTrace();
    }
    sdb.tool(new Tool(toolUri, this.toolName, this.toolVersion, null, null));
    return sdb.build();
}

From source file:edu.uah.itsc.aws.S3.java

public void addGroupPolicy(String groupName, String policyName, String policyToAdd) {
    // Create ami with proper credentials
    AmazonIdentityManagementClient ami = new AmazonIdentityManagementClient(
            new BasicAWSCredentials(awsAdminAccessKey, awsAdminSecretKey));
    GetGroupPolicyRequest ggpRequest = new GetGroupPolicyRequest(groupName, policyName);
    GetGroupPolicyResult ggpResult = ami.getGroupPolicy(ggpRequest);
    String policy = ggpResult.getPolicyDocument();
    try {/* w w  w  .ja  v a 2s .co m*/
        policy = new URI(policy).getPath().toString();
        JSONObject policyObject = new JSONObject(policy);
        JSONArray policyStatementsArray = policyObject.getJSONArray("Statement");
        JSONArray policyToAddArray = new JSONArray("[" + policyToAdd + "]");
        for (int i = 0; i < policyToAddArray.length(); i++) {
            policyStatementsArray.put(policyToAddArray.get(i));
        }
        policyObject.put("Statement", policyStatementsArray);
        policy = policyObject.toString(4);
        // if (1 == 1 ) return;
    } catch (URISyntaxException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();

    }
    // Add new policy as required
    PutGroupPolicyRequest pgpRequest = new PutGroupPolicyRequest(groupName, policyName, policy);
    ami.putGroupPolicy(pgpRequest);

}

From source file:org.xwiki.android.rest.HttpConnector.java

/**
 * Perform HTTP Get method execution and return the response as a String
 * /*from w  w  w  .  ja  v a  2  s. c o  m*/
 * @param Uri URL of XWiki RESTful API
 * @return Response data of the HTTP connection as a String
 */
public String getResponse(String Uri) {
    initialize();

    BufferedReader in = null;
    HttpGet request = new HttpGet();
    String responseText = new String();

    try {
        requestUri = new URI(Uri);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    setCredentials();

    request.setURI(requestUri);
    Log.d("Request URL", Uri);
    try {

        response = client.execute(request);
        Log.d("Response status", response.getStatusLine().toString());

        in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        StringBuffer sb = new StringBuffer("");
        String line = "";
        String NL = System.getProperty("line.separator");
        while ((line = in.readLine()) != null) {
            sb.append(line + NL);
        }
        in.close();
        responseText = sb.toString();
        Log.d("Response", "response: " + responseText);

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return responseText;
}

From source file:org.bbaw.pdr.ae.view.identifiers.internal.ConcurrenceSearchController.java

private void searchPersons(Object personsContainer, IConcurrenceSearchService concurrenceSearchService,
        HashMap<PdrId, ConcurrenceDataHead> conMap, IProgressMonitor monitor) {
    if (conMap == null) {
        conMap = new HashMap<PdrId, ConcurrenceDataHead>();
    }//from w w w.j a v a  2 s. c  om
    Vector<ConcurrenceData> conDatas;
    ConcurrenceDataHead conHead;
    if (personsContainer instanceof ArrayList) {
        @SuppressWarnings("unchecked")
        ArrayList<Person> selection = (ArrayList<Person>) personsContainer;
        monitor.beginTask("Searching for Identifiers", selection.size());

        for (Person p : selection) {
            conHead = conMap.get(p.getPdrId());
            if (conHead == null) {
                conHead = new ConcurrenceDataHead();
                conMap.put(p.getPdrId(), conHead);
            }
            conHead.addService(concurrenceSearchService.getLabel());
            try {
                conDatas = searchConcurrence(p, concurrenceSearchService);
                conHead.addConcurrenceDatas(conDatas);
            } catch (URISyntaxException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            monitor.worked(1);
            if (monitor.isCanceled()) {
                break;
            }
        }
    }
    if (personsContainer instanceof PdrObject[]) {
        PdrObject[] objects = (PdrObject[]) personsContainer;
        monitor.beginTask("Searching for Identifiers", objects.length);

        for (PdrObject o : objects) {
            if (o instanceof Person) {
                Person p = (Person) o;
                conHead = conMap.get(p.getPdrId());
                if (conHead == null) {
                    conHead = new ConcurrenceDataHead();
                    conMap.put(p.getPdrId(), conHead);
                }
                conHead.addService(concurrenceSearchService.getLabel());
                try {
                    conDatas = searchConcurrence(p, concurrenceSearchService);
                    conHead.addConcurrenceDatas(conDatas);
                } catch (URISyntaxException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                monitor.worked(1);
                if (monitor.isCanceled()) {
                    break;
                }
            }

        }
    } else if (personsContainer instanceof HashMap<?, ?>) {
        @SuppressWarnings("unchecked")
        HashMap<PdrId, Person> personsMap = (HashMap<PdrId, Person>) personsContainer;
        {
            monitor.beginTask("Searching for Identifiers", personsMap.size());

            for (PdrId id : personsMap.keySet()) {
                Person p = personsMap.get(id);
                conHead = conMap.get(p.getPdrId());
                if (conHead == null) {
                    conHead = new ConcurrenceDataHead();
                    conMap.put(p.getPdrId(), conHead);
                }
                conHead.addService(concurrenceSearchService.getLabel());
                try {
                    conDatas = searchConcurrence(p, concurrenceSearchService);
                    conHead.addConcurrenceDatas(conDatas);
                } catch (URISyntaxException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                monitor.worked(1);
                if (monitor.isCanceled()) {
                    break;
                }
            }
        }
    }
}

From source file:org.mobicents.servlet.restcomm.sms.SmsService.java

private Notification notification(final int log, final int error, final String message) {
    String version = configuration.subset("runtime-settings").getString("api-version");
    Sid accountId = new Sid("ACae6e420f425248d6a26948c17a9e2acf");
    //        Sid callSid = new Sid("CA00000000000000000000000000000000");
    final Notification.Builder builder = Notification.builder();
    final Sid sid = Sid.generate(Sid.Type.NOTIFICATION);
    builder.setSid(sid);/*from  w ww  .  ja  v  a  2  s  .  c om*/
    // builder.setAccountSid(accountId);
    builder.setAccountSid(accountId);
    //        builder.setCallSid(callSid);
    builder.setApiVersion(version);
    builder.setLog(log);
    builder.setErrorCode(error);
    final String base = configuration.subset("runtime-settings").getString("error-dictionary-uri");
    StringBuilder buffer = new StringBuilder();
    buffer.append(base);
    if (!base.endsWith("/")) {
        buffer.append("/");
    }
    buffer.append(error).append(".html");
    final URI info = URI.create(buffer.toString());
    builder.setMoreInfo(info);
    builder.setMessageText(message);
    final DateTime now = DateTime.now();
    builder.setMessageDate(now);
    try {
        builder.setRequestUrl(new URI(""));
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    /**
     * if (response != null) { builder.setRequestUrl(request.getUri()); builder.setRequestMethod(request.getMethod());
     * builder.setRequestVariables(request.getParametersAsString()); }
     **/

    builder.setRequestMethod("");
    builder.setRequestVariables("");
    buffer = new StringBuilder();
    buffer.append("/").append(version).append("/Accounts/");
    buffer.append(accountId.toString()).append("/Notifications/");
    buffer.append(sid.toString());
    final URI uri = URI.create(buffer.toString());
    builder.setUri(uri);
    return builder.build();
}