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:net.sourceforge.seqware.common.metadata.MetadataWSTest.java

/**
 * Test of addWorkflow method, of class MetadataWS.
 * dyuen asks: Why was this commented out?
 *///from www . j a  va 2  s. c om
@Test
public void testAddWorkflow() {
    logger.info("addWorkflow");
    String name = "GATKRecalibrationAndVariantCalling";
    String version = "1.3.16";
    String description = "GATKRecalibrationAndVariantCalling";
    String baseCommand = "java -jar /u/seqware/provisioned-bundles/sqwprod/"
            + "Workflow_Bundle_GATKRecalibrationAndVariantCalling_1.2.29_"
            + "SeqWare_0.10.0/GATKRecalibrationAndVariantCalling/1.x.x/lib/"
            + "seqware-pipeline-0.10.0.jar --plugin net.sourceforge.seqware."
            + "pipeline.plugins.WorkflowLauncher -- --bundle /u/seqware/"
            + "provisioned-bundles/sqwprod/Workflow_Bundle_GATKRecalibration"
            + "AndVariantCalling_1.2.29_SeqWare_0.10.0 --workflow GATK"
            + "RecalibrationAndVariantCalling --version 1.3.16";
    java.io.File configFile = null, templateFile = null;
    try {
        configFile = new java.io.File(
                MetadataWSTest.class.getResource("GATKRecalibrationAndVariantCalling_1.3.16.ini").toURI());
        templateFile = new java.io.File(
                MetadataWSTest.class.getResource("GATKRecalibrationAndVariantCalling_1.3.16.ftl").toURI());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    java.io.File provisionDir = new java.io.File("/u/seqware/provisioned-bundles"
            + "/sqwprod/Workflow_Bundle_GATKRecalibrationAndVariantCalling_" + "1.2.29_SeqWare_0.10.0/");
    int expResult = ReturnValue.SUCCESS;
    ReturnValue result = instance.addWorkflow(name, version, description, baseCommand,
            configFile.getAbsolutePath(), templateFile.getAbsolutePath(), provisionDir.getAbsolutePath(), true,
            "", false, null, null, null);
    Assert.assertEquals(expResult, result.getExitStatus());

    // test certain properties of the workflow parameters in relation to SEQWARE-1444
    String workflow_id = result.getAttribute("sw_accession");
    Workflow workflow = instance.getWorkflow(Integer.valueOf(workflow_id));
    Assert.assertTrue("workflow retrieved is invalid", workflow.getWorkflowId() == result.getReturnValue());
    SortedSet<WorkflowParam> workflowParams = instance.getWorkflowParams(workflow_id);
    Assert.assertTrue("invalid number of workflow params retrieved", workflowParams.size() == 33);
    // check out the values of some long values
    for (WorkflowParam param : workflowParams) {
        if (param.getKey().equals("bam_inputs")) {
            Assert.assertTrue("bam_inputs invalid", param.getDefaultValue().equals(
                    "${workflow_bundle_dir}/GATKRecalibrationAndVariantCalling/1.x.x/data/test/PCSI0022P.val.bam,${workflow_bundle_dir}/GATKRecalibrationAndVariantCalling/1.x.x/data/test/PCSI0022R.val.bam,${workflow_bundle_dir}/GATKRecalibrationAndVariantCalling/1.x.x/data/test/PCSI0022X.val.bam,${workflow_bundle_dir}/GATKRecalibrationAndVariantCalling/1.x.x/data/test/PCSI0022C.val.bam"));
        } else if (param.getKey().equals("chr_sizes")) {
            Assert.assertTrue("chr_sizes invalid", param.getDefaultValue().equals(
                    "chr1:249250621,chr2:243199373,chr3:198022430,chr4:191154276,chr5:180915260,chr6:171115067,chr7:159138663,chr8:146364022,chr9:141213431,chr10:135534747,chr11:135006516,chr12:133851895,chr13:115169878,chr14:107349540,chr15:102531392,chr16:90354753,chr17:81195210,chr18:78077248,chr19:59128983,chr20:63025520,chr21:48129895,chr22:51304566,chrX:155270560,chrY:59373566,chrM:16571"));
        }
    }
}

From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java

private void connectWebSocket() {
    URI uri;/*from w  w w. j av  a  2 s  . c  om*/
    try {
        //uri = new URI("ws://192.168.0.105:6437/");
        uri = new URI("ws://172.20.10.4:6437/");
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return;
    }

    mWebSocketClient = new WebSocketClient(uri) {
        @Override
        public void onOpen(ServerHandshake serverHandshake) {
            Log.i("Websocket", "Opened");
        }

        @Override
        public void onMessage(String s) {
            final String message = s;
            //Log.i("Websocket_message", s);
            try {
                JSONObject obj = new JSONObject(s);
                JSONArray pos = obj.getJSONArray("hands").getJSONObject(0).getJSONArray("palmPosition");
                handPos[0] = (float) pos.getDouble(0);
                handPos[1] = (float) pos.getDouble(1);
                handPos[2] = (float) pos.getDouble(2);
                Log.i("Websocket_json", String.format("(%f, %f, %f)", handPos[0], handPos[1], handPos[2]));
            } catch (JSONException e) {
                Log.i("Websocket_json", "Not the right json obj");
            }
        }

        @Override
        public void onClose(int i, String s, boolean b) {
            Log.i("Websocket", "Closed " + s);
        }

        @Override
        public void onError(Exception e) {
            Log.i("Websocket", "Error " + e.getMessage());
        }
    };
    mWebSocketClient.connect();
}

From source file:org.apache.manifoldcf.crawler.connectors.hdfs.HDFSRepositoryConnector.java

/** Check if a file or directory should be included, given a document specification.
 *@param fileName is the canonical file name.
 *@param documentSpecification is the specification.
 *@return true if it should be included.
 *//*from  w  ww  .ja v a  2 s.  co  m*/
protected static boolean checkInclude(String nameNode, FileStatus fileStatus, String fileName,
        Specification documentSpecification) throws ManifoldCFException {
    if (Logging.connectors.isDebugEnabled()) {
        Logging.connectors.debug("Checking whether to include file '" + fileName + "'");
    }

    String pathPart;
    String filePart;
    if (fileStatus.isDirectory()) {
        pathPart = fileName;
        filePart = null;
    } else {
        pathPart = fileStatus.getPath().getParent().toString();
        filePart = fileStatus.getPath().getName();
    }

    // Scan until we match a startpoint
    int i = 0;
    while (i < documentSpecification.getChildCount()) {
        SpecificationNode sn = documentSpecification.getChild(i++);
        if (sn.getType().equals("startpoint")) {
            String path = null;
            try {
                path = new URI(nameNode).resolve(sn.getAttributeValue("path")).toString();
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
            if (Logging.connectors.isDebugEnabled()) {
                Logging.connectors.debug("Checking path '" + path + "' against canonical '" + pathPart + "'");
            }
            // Compare with filename
            int matchEnd = matchSubPath(path, pathPart);
            if (matchEnd == -1) {
                if (Logging.connectors.isDebugEnabled()) {
                    Logging.connectors
                            .debug("Match check '" + path + "' against canonical '" + pathPart + "' failed");
                }

                continue;
            }
            // matchEnd is the start of the rest of the path (after the match) in fileName.
            // We need to walk through the rules and see whether it's in or out.
            int j = 0;
            while (j < sn.getChildCount()) {
                SpecificationNode node = sn.getChild(j++);
                String flavor = node.getType();
                String match = node.getAttributeValue("match");
                String type = node.getAttributeValue("type");
                // If type is "file", then our match string is against the filePart.
                // If filePart is null, then this rule is simply skipped.
                String sourceMatch;
                int sourceIndex;
                if (type.equals("file")) {
                    if (filePart == null) {
                        continue;
                    }
                    sourceMatch = filePart;
                    sourceIndex = 0;
                } else {
                    if (filePart != null) {
                        continue;
                    }
                    sourceMatch = pathPart;
                    sourceIndex = matchEnd;
                }

                if (flavor.equals("include")) {
                    if (checkMatch(sourceMatch, sourceIndex, match)) {
                        return true;
                    }
                } else if (flavor.equals("exclude")) {
                    if (checkMatch(sourceMatch, sourceIndex, match)) {
                        return false;
                    }
                }
            }
        }
    }
    if (Logging.connectors.isDebugEnabled()) {
        Logging.connectors.debug("Not including '" + fileName + "' because no matching rules");
    }

    return false;
}

From source file:de.uni_potsdam.hpi.bpt.bp2014.jcore.rest.RestInterface.java

/**
 * Returns a JSON-Object containing information about all activity
 * instances of a specified scenario instance.
 * The JSON-Object will group the activities regarding their state.
 * If the scenario instance does not exist, the response code will
 * specify the error which occurred./*  w w w .ja  v  a 2 s .c o  m*/
 *
 * @param uriInfo      The context object. It provides information
 *                     the server context.
 * @param scenarioID   The id of the scenario
 * @param instanceID   The id of the instance.
 * @param filterString Defines a search strings. Only activities
 *                     with a label containing this String will be
 *                     shown.
 * @return A Response with the status and content of the request.
 * A 200 (OK) implies that the instance was found and the
 * result contains the JSON-Object.
 * If only the scenario ID is incorrect a 301 (REDIRECT)
 * will point to the correct URL.
 * If the instance ID is incorrect a 404 (NOT_FOUND) will
 * be returned.
 */
@GET
@Path("scenario/{scenarioID}/instance/{instanceID}/activity")
@Produces(MediaType.APPLICATION_JSON)
public Response getActivitiesOfInstance(@Context UriInfo uriInfo, @PathParam("scenarioID") int scenarioID,
        @PathParam("instanceID") int instanceID, @QueryParam("filter") String filterString,
        @QueryParam("state") String state) {
    ExecutionService executionService = new ExecutionService();
    if (!executionService.existScenarioInstance(instanceID)) {
        return Response.status(Response.Status.NOT_FOUND).type(MediaType.APPLICATION_JSON)
                .entity("{\"message\":\"There is no instance with id " + instanceID + "\"}").build();
    } else if (!executionService.existScenario(scenarioID)) {
        try {
            return Response.seeOther(new URI(
                    "interface/v2/scenario/" + executionService.getScenarioIDForScenarioInstance(instanceID)
                            + "/instance/" + instanceID + "/activity"))
                    .build();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }
    if ((filterString == null || filterString.isEmpty()) && (state == null || state.isEmpty())) {
        return getAllActivitiesOfInstance(scenarioID, instanceID, uriInfo);
    } else if ((filterString == null || filterString.isEmpty())) {
        return getAllActivitiesOfInstanceWithState(scenarioID, instanceID, state, uriInfo);
    } else if ((state == null || state.isEmpty())) {
        return getAllActivitiesOfInstanceWithFilter(scenarioID, instanceID, filterString, uriInfo);
    } else {
        return getAllActivitiesWithFilterAndState(scenarioID, instanceID, filterString, state, uriInfo);
    }
}

From source file:com.cloud.network.resource.NccHttpCode.java

private void keepSessionAlive() throws ExecutionException {
    URI agentUri = null;/*from w  w w .  j a  va2 s  .co  m*/
    try {
        agentUri = new URI("https", null, _ip, DEFAULT_PORT, "/cs/cca/v1/cloudstacks", null, null);
        org.json.JSONObject jsonBody = new JSONObject();
        getHttpRequest(jsonBody.toString(), agentUri, _sessionid);
        s_logger.debug("Keeping Session Alive");
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
}

From source file:com.cloud.network.resource.NccHttpCode.java

private String getLBHealthChecks(long networkid) throws ExecutionException {
    URI agentUri = null;//from   w ww.j a v a  2s .co  m
    String response = null;
    try {
        agentUri = new URI("https", null, _ip, DEFAULT_PORT,
                "/cs/adcaas/v1/networks/" + networkid + "/lbhealthstatus", null, null);
        org.json.JSONObject jsonBody = new JSONObject();
        response = getHttpRequest(jsonBody.toString(), agentUri, _sessionid);
        s_logger.debug("LBHealthcheck Response :" + response);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return response;
}

From source file:org.opendatakit.dwc.server.GreetingServiceImpl.java

@Override
public String obtainOauth2Code(String destinationUrl) throws IllegalArgumentException {
    URI nakedUri;//from ww w  .  j a  va  2  s .  c  o m
    try {
        nakedUri = new URI(authUrl);
    } catch (URISyntaxException e2) {
        e2.printStackTrace();
        logger.error(e2.toString());
        return getSelfUrl();
    }
    addCredentials(CLIENT_ID, CLIENT_SECRET, nakedUri.getHost());
    Context ctxt = new Context();
    stateMap.put(ctxt.getKey(), ctxt);
    ctxtKey = ctxt.getKey();

    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("response_type", "code"));
    qparams.add(new BasicNameValuePair("client_id", CLIENT_ID));
    qparams.add(new BasicNameValuePair("scope", scope));
    qparams.add(new BasicNameValuePair("redirect_uri", getOauth2CallbackUrl()));
    qparams.add(new BasicNameValuePair("state", ctxt.getKey()));
    URI uri;
    try {
        uri = URIUtils.createURI(nakedUri.getScheme(), nakedUri.getHost(), nakedUri.getPort(),
                nakedUri.getPath(), URLEncodedUtils.format(qparams, "UTF-8"), null);
    } catch (URISyntaxException e1) {
        e1.printStackTrace();
        logger.error(e1.toString());
        return getSelfUrl();
    }

    String toString = uri.toString();
    return toString;
}

From source file:org.openqa.selendroid.server.model.SelendroidNativeDriver.java

public void get(String url) {
    URI dest;//from   w  w  w.ja v  a  2  s . c om
    try {
        dest = new URI(url);
    } catch (URISyntaxException exception) {
        throw new IllegalArgumentException(exception);
    }

    if (!"and-activity".equals(dest.getScheme())) {
        throw new SelendroidException("Unrecognized scheme in URI: " + dest.toString());
    } else if (dest.getPath() != null && !dest.getPath().equals("")) {
        throw new SelendroidException("Unrecognized path in URI: " + dest.toString());
    }

    URI currentUri = getCurrentURI();

    if (currentUri != null && dest.getAuthority().endsWith(currentUri.getAuthority())) {
        // ignore request, activity is already open
        return;
    }

    Class<?> clazz;
    try {
        clazz = Class.forName(dest.getAuthority());
    } catch (ClassNotFoundException exception) {
        exception.printStackTrace();
        throw new SelendroidException("The specified Activity class does not exist: " + dest.getAuthority(),
                exception);
    }

    serverInstrumentation.startActivity(clazz);
    DefaultSelendroidDriver.sleepQuietly(500);
}

From source file:com.material.katha.wifidirectmp3.DeviceDetailFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    // User has picked an image. Transfer it to group owner i.e peer using
    // FileTransferService.

    if (requestCode >= 0 && resultCode == -1 && data != null) {

        // count++;
        Uri uri = data.getData();/*w  w  w  .ja  va 2  s. co  m*/
        String abc = uri.toString();
        // System.out.println(abc);
        Log.d("katha", abc + "abc");
        try {
            datapath = getPath(getActivity(), uri);
            Log.d("WiFiDirectActivity", datapath.substring(datapath.lastIndexOf("/") + 1, datapath.length()));
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        String filename = abc.substring(abc.lastIndexOf("/") + 1);
        pd = new ProgressDialog(getActivity());
        pd.setMessage("Sending:" + datapath);
        pd.setButton(DialogInterface.BUTTON_NEGATIVE, "Pause", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                Log.d("WiFiDirectActivity", "pause pressed");
                resetafterdismiss(0);
                pause++;
                //pd.show();
            }
        });
        pd.show();

        File f = new File(uri.getPath());
        //long file_size = f.length();
        ContentResolver cr = getActivity().getContentResolver();
        InputStream is = null;
        int fsize = 0;
        try {
            //is=cr.openInputStream(Uri.parse(new File("DCIM/Camera/IMG_20160118_090231.jpg").toString()));
            is = cr.openInputStream(uri);
            fsize = is.available();

            Log.d("WiFiDirectActivity", "File size is:" + is.available() + "               " + f.getName()
                    + "uri  " + uri + "f  " + f + "file name " + f.getName());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            Log.d("WifiDirectActivity", "here " + e);
        } catch (IOException e) {
            Log.d("WifiDirectActivity", "here " + e);
            e.printStackTrace();
        }

        //Log.d("katha", fileext + "fileext");
        //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;change fileext = abc.substring(abc.lastIndexOf('.'));

        /*progressDialog = new ProgressDialog(getActivity());
        progressDialog.setMessage("Sending file:"+abc);
        progressDialog.show();
        */

        // progressDialog = ProgressDialog.show(getActivity(), "Sending","Copying file :" + fileext, true, true);
        // makeText(getActivity(), fileext, LENGTH_LONG).show();
        TextView statusText = (TextView) mContentView.findViewById(R.id.status_text);
        //  statusText.setText("Sending: " + uri);
        // String devicename = "abc";
        //            devicename = device.deviceName;
        // Toast.makeText(getActivity(),devicename,Toast.LENGTH_LONG).show();

        Log.d("WiFiDirectActivity", "Intent----------- " + uri);
        Intent serviceIntent = new Intent(getActivity(), FileTransferService.class);
        serviceIntent.setAction(FileTransferService.ACTION_SEND_FILE);
        Log.d("WiFiDirectActivity", "Action" + FileTransferService.ACTION_SEND_FILE + "\n\n\n\n");
        ////////////////////serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH, uri.toString());
        serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH, datapath);

        serviceIntent.putExtra(FileTransferService.FILE_SIZE, fsize);

        //serviceIntent.putExtra(FileTransferService.device_name,devicename);
        serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_PORT, 8988);
        String localip = getDottedDecimalIP(getLocalIPAddress());
        Localip = localip;
        Log.d("WiFiDirectActivity", "DEVICE_NAME: " + devicename);
        serviceIntent.putExtra(FileTransferService.DEVICE_NAME, devicename);

        if (localip.equals("192.168.49.1")) {
            Log.d("WiFiDirectActivity", "Flag is 0.");
            //  devicename = device.deviceName;
            serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_ADDRESS, client_ip);
            serviceIntent.putExtra(FileTransferService.Client_add, client_ip);
            ;
        } else {
            Log.d("WiFiDirectActivity", "Flag is 1.");
            //devicename = device.deviceName;
            // Toast.makeText(getActivity(),devicename,Toast.LENGTH_LONG).show();
            try {
                serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_ADDRESS,
                        info.groupOwnerAddress.getHostAddress());
                serviceIntent.putExtra(FileTransferService.Client_add, localip);
            } catch (Exception e) {
                Toast.makeText(getActivity(), "Error!!", LENGTH_LONG).show();
                Log.d("WiFiDirectActivity", "error in catch!!");
                return;
            }
        }
        getActivity().startService(serviceIntent);
        Log.d("WiFiDirectActivity", "here");
    } else {
        return;
    }

}

From source file:com.srotya.collectd.storm.StormNimbusMetrics.java

@Override
public int read() {
    Gson gson = new Gson();
    login();/*from   ww w.  j a  v  a 2 s .co  m*/
    for (String nimbus : nimbusAddresses) {
        Subject.doAs(subject, new PrivilegedAction<Void>() {

            @Override
            public Void run() {
                HttpGet request = new HttpGet(nimbus + "/api/v1/topology/summary");
                CloseableHttpClient client = builder.build();
                try {
                    HttpResponse response = client.execute(request, context);
                    if (response.getStatusLine().getStatusCode() == 200) {
                        HttpEntity entity = response.getEntity();
                        String result = EntityUtils.toString(entity);
                        JsonObject topologySummary = gson.fromJson(result, JsonObject.class);
                        List<String> ids = extractTopologyIds(
                                topologySummary.get("topologies").getAsJsonArray());
                        if (ids.isEmpty()) {
                            Collectd.logInfo("No storm topologies deployed");
                        }
                        for (String id : ids) {
                            PluginData pd = new PluginData();
                            pd.setPluginInstance(id);
                            pd.setTime(System.currentTimeMillis());
                            try {
                                pd.setHost(new URI(nimbus).getHost());
                            } catch (URISyntaxException e) {
                                continue;
                            }
                            ValueList values = new ValueList(pd);
                            fetchTopologyMetrics(nimbus, id, values, builder, gson);
                        }
                    } else {
                        Collectd.logError("Unable to fetch Storm metrics:" + response.getStatusLine() + "\t"
                                + EntityUtils.toString(response.getEntity()));
                    }
                    client.close();
                } catch (Exception e) {
                    e.printStackTrace();
                    Collectd.logError(
                            "Failed to fetch metrics from Nimbus:" + nimbus + "\treason:" + e.getMessage());
                }
                return null;
            }
        });
    }
    return 0;
}