List of usage examples for java.net URISyntaxException printStackTrace
public void printStackTrace()
From source file:edu.uah.itsc.aws.S3.java
public void addWorkflowSharePolicy(String groupName, String policyName, String workflowPath) { // 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 . j av a2s . c o m*/ policy = new URI(policy).getPath().toString(); JSONObject policyObject = new JSONObject(policy); JSONArray policyStatementsArray = policyObject.getJSONArray("Statement"); // We are going to add new bucket in the Resource array list in the json format for (int i = 0; i < policyStatementsArray.length(); i++) { JSONObject statementObject = (JSONObject) policyStatementsArray.get(i); JSONArray actionArray = (JSONArray) statementObject.getJSONArray("Action"); if (actionArray.length() == 3) { HashSet<String> set = new HashSet<String>(3); set.add(actionArray.getString(0)); set.add(actionArray.getString(1)); set.add(actionArray.getString(2)); if (set.contains("s3:Get*") && set.contains("s3:Put*") && set.contains("s3:List*")) { JSONArray resourceArray = (JSONArray) statementObject.getJSONArray("Resource"); resourceArray.put(resourceArray.length(), "arn:aws:s3:::" + workflowPath + "/*"); } } } 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:edu.uah.itsc.aws.S3.java
public void addBucketGroupPolicy(String groupName, String policyName, String bucketName) { // 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 {//www. j ava2 s . co m policy = new URI(policy).getPath().toString(); JSONObject policyObject = new JSONObject(policy); JSONArray policyStatementsArray = policyObject.getJSONArray("Statement"); // We are going to add new bucket in the Resource array list in the json format for (int i = 0; i < policyStatementsArray.length(); i++) { JSONObject statementObject = (JSONObject) policyStatementsArray.get(i); JSONArray actionArray = (JSONArray) statementObject.getJSONArray("Action"); if (actionArray.length() == 1 && actionArray.getString(0).equalsIgnoreCase("s3:List*")) { JSONArray resourceArray = (JSONArray) statementObject.getJSONArray("Resource"); resourceArray.put(resourceArray.length(), "arn:aws:s3:::" + bucketName); } else if (actionArray.length() == 3) { HashSet<String> set = new HashSet<String>(3); set.add(actionArray.getString(0)); set.add(actionArray.getString(1)); set.add(actionArray.getString(2)); if (set.contains("s3:Get*") && set.contains("s3:Put*") && set.contains("s3:List*")) { JSONArray resourceArray = (JSONArray) statementObject.getJSONArray("Resource"); resourceArray.put(resourceArray.length(), "arn:aws:s3:::" + bucketName + "/${aws:username}/*"); } } } 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.rifidi.designer.library.basemodels.pusharm.PusharmEntity.java
@Override public void init() { BinaryPattern pattern = new BinaryPattern(); pattern.setPattern(/* w w w . j av a2 s . co m*/ new boolean[][] { { true, true, true, true, true, true }, { true, true, true, true, true, true }, { true, true, true, true, true, true }, { true, true, true, true, true, true } }); setPattern(pattern); Node node = new Node(); try { URI body = null; URI arm = null; try { arm = getClass().getClassLoader() .getResource("org/rifidi/designer/library/basemodels/pusharm/pusher_arm.jme").toURI(); body = getClass().getClassLoader() .getResource("org/rifidi/designer/library/basemodels/pusharm/pusher_body.jme").toURI(); } catch (URISyntaxException e) { e.printStackTrace(); } Node bodyNode = (Node) BinaryImporter.getInstance().load(body.toURL()); bodyNode.setModelBound(new BoundingBox()); bodyNode.updateModelBound(); for (Spatial sp : bodyNode.getChildren()) { System.out.println("sp: " + sp); sp.clearRenderState(RenderState.RS_TEXTURE); } bodyNode.updateRenderState(); Node armNode = (Node) BinaryImporter.getInstance().load(arm.toURL()); armPhysics = physicsSpace.createStaticNode(); armPhysics.attachChild(armNode); armPhysics.setName("armPhysics"); armPhysics.generatePhysicsGeometry(); armPhysics.setLocalTranslation(minpos); armNode.setModelBound(new BoundingBox()); armNode.updateModelBound(); node.attachChild(bodyNode); node.attachChild(armPhysics); node.updateModelBound(); setNode(node); // store pusharm dimensions for ease of calculation float xCent = armPhysics.getWorldBound().getCenter().x; float yCent = armPhysics.getWorldBound().getCenter().y; float xExt = ((BoundingBox) armPhysics.getWorldBound()).xExtent; float yExt = ((BoundingBox) armPhysics.getWorldBound()).yExtent; float len = 2.5f; // length of the trigger area // Create the material and alpha states for the trigger area MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState(); ms.setDiffuse(new ColorRGBA(1, 1, 1, .6f)); AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState(); as.setBlendEnabled(true); as.setSrcFunction(AlphaState.SB_SRC_ALPHA); as.setDstFunction(AlphaState.DB_ONE); as.setEnabled(true); // create the trigger area Box irGeom = new Box("triggerSpace_geom", new Vector3f(-xExt - len + xCent, yCent, 0f).add(minpos), len, yExt, .15f); irGeom.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT); irGeom.setRenderState(ms); irGeom.setRenderState(as); triggerSpace = physicsSpace.createStaticNode(); triggerSpace.setName("triggerSpace"); triggerSpace.attachChild(irGeom); triggerSpace.setModelBound(new BoundingBox()); triggerSpace.updateModelBound(); triggerSpace.updateRenderState(); getNode().attachChild(triggerSpace); } catch (IOException e) { logger.error("Unable to load jme: " + e); } prepare(); // initialize controller for moving the pusharm initController(); }
From source file:org.rifidi.designer.library.basemodels.gate.GateEntity.java
private void prepare() { if (model == null) { URI modelpath = null;/* w w w. j a va 2s . c o m*/ try { modelpath = getClass().getClassLoader() .getResource("org/rifidi/designer/library/basemodels/gate/gateway.jme").toURI(); } catch (URISyntaxException e) { e.printStackTrace(); } try { model = (Node) BinaryImporter.getInstance().load(modelpath.toURL()); } catch (MalformedURLException e) { logger.fatal(e); } catch (IOException e) { logger.fatal(e); } } try { readerModuleManagerInterface = rmimanager.createReader(reader.getGeneralReaderPropertyHolder()); // getReaderName(), getReaderClassName(), getNumAntennas(), // getNumGPIs(), getNumGPOs(), getPropertiesMap()); } catch (ClassNotFoundException e) { logger.fatal("Unable to create reader: " + e); } catch (InstantiationException e) { logger.fatal("Unable to create reader: " + e); } catch (IllegalAccessException e) { logger.fatal("Unable to create reader: " + e); } catch (MalformedURLException e) { logger.fatal("Unable to create reader: " + e); } catch (NotBoundException e) { logger.fatal("Unable to create reader: " + e); } catch (RemoteException e) { logger.fatal("Unable to create reader: " + e); } catch (IOException e) { logger.fatal("Unable to create reader: " + e); } }
From source file:org.opennms.poller.remote.Main.java
private void parseArguments(String[] args) throws ParseException { Options options = new Options(); options.addOption("h", "help", false, "this help"); options.addOption("d", "debug", false, "write debug messages to the log"); options.addOption("g", "gui", false, "start a GUI (default: false)"); options.addOption("i", "disable-icmp", false, "disable ICMP/ping (overrides -Dorg.opennms.netmgt.icmp.pingerClass=)"); options.addOption("l", "location", true, "the location name of this remote poller"); options.addOption("u", "url", true, "the URL for OpenNMS (example: https://server-name/opennms-remoting)"); options.addOption("n", "name", true, "the name of the user to connect as"); options.addOption("p", "password", true, "the password to use when connecting"); options.addOption("s", "scan-report", false, "perform a single scan report instead of running the polling engine"); CommandLineParser parser = new PosixParser(); CommandLine cl = parser.parse(options, args); if (cl.hasOption("h")) { usage(options);//from w w w. j a va 2s. co m System.exit(1); } if (cl.hasOption("d")) { } if (cl.hasOption("i")) { m_disableIcmp = true; } if (cl.hasOption("l")) { m_locationName = cl.getOptionValue("l"); } if (cl.hasOption("u")) { String arg = cl.getOptionValue("u").toLowerCase(); try { m_uri = new URI(arg); } catch (URISyntaxException e) { usage(options); e.printStackTrace(); System.exit(2); } } else { usage(options); System.exit(3); } if (cl.hasOption("g")) { m_gui = true; } if (cl.hasOption("s")) { m_scanReport = true; } if (cl.hasOption("n")) { m_username = cl.getOptionValue("n"); m_password = cl.getOptionValue("p"); if (m_password == null) { m_password = ""; } } // If we cannot obtain the username/password from the command line, attempt // to optionally get it from system properties if (m_username == null) { m_username = System.getProperty("opennms.poller.server.username"); if (m_username != null) { m_password = System.getProperty("opennms.poller.server.password"); if (m_password == null) { m_password = ""; } } } }
From source file:org.apache.hadoop.mapred.YTPoolManager.java
public YTPoolManager(Configuration conf) throws IOException, SAXException, YTAllocationConfigurationException, ParserConfigurationException { this.poolNameProperty = conf.get("mapred.yunti3scheduler.poolnameproperty", "mapred.job.queue.name"); this.allocFile = conf.get("mapred.yunti3scheduler.allocation.file"); if (allocFile == null) { LOG.warn("No mapred.yunti3scheduler.allocation.file given in jobconf - " + "the fair scheduler will not use any queues."); }//from w ww . j ava 2 s . c o m reloadAllocs(); lastSuccessfulReload = System.currentTimeMillis(); lastReloadAttempt = System.currentTimeMillis(); lastSuccessfulReloadSiteConf = System.currentTimeMillis(); try { siteConf = conf.getResource("hadoop-site.xml").toURI(); } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:org.occiware.clouddesigner.occi.linkeddata.connector.LdprojectConnector.java
/** * Constructs a LDProject connector./* w w w.j av a 2 s. c om*/ */ LdprojectConnector() { // getOrBuildDatacoreClient() { if ctx == null or ldContainerUrlString != LDNode.url... LOGGER.debug("Constructor called on " + this); //System.setProperty("datacoreApiClient.containerUrl", "blabla"); // then LDNode.url synchronized (LdprojectConnector.class) { if (ctx == null) { ctx = new ClassPathXmlApplicationContext("oasis-datacore-rest-client-custom-context.xml"); } } ldc = (DatacoreCachedClient) ctx.getBean("datacoreApiCachedJsonClient"); ldContainerUrlString = ctx.getBeanFactory().resolveEmbeddedValue("${datacoreApiClient.containerUrl}"); String ldBaseUrlString = ctx.getBeanFactory().resolveEmbeddedValue("${datacoreApiClient.baseUrl}"); try { ldContainerUrl = new URI(ldContainerUrlString); LOGGER.warn("Starting connector, using Linked Data Core at " + ldBaseUrlString + " with containerUrl " + ldContainerUrlString); } catch (URISyntaxException e) { LOGGER.error("bad conf " + ldContainerUrlString, e); e.printStackTrace(); } }
From source file:me.trashout.fragment.EventDetailFragment.java
private void setupEventData(Event event) { if (user == null || mEvent.getUserId() == user.getId()) { eventDetailJoinBtn.setVisibility(View.GONE); } else {//from w w w.ja v a 2 s . c o m int visibility = View.VISIBLE; for (User usr : event.getUsers()) { if (usr.getId() == user.getId()) { visibility = View.GONE; break; } } eventDetailJoinBtn.setVisibility(visibility); } eventDetailName.setText(event.getName()); if (event.getStart() != null) eventDetailTime.setText(String.format("%s, %s", DateTimeUtils.DATE_TIME_FORMAT.format(event.getStart()), DateTimeUtils.getDurationTimeString(getContext(), event.getDuration() * 60 * 1000))); else eventDetailTime.setText("?"); eventDetailDescription.setText(event.getDescription()); eventDetailPhone.setText(event.getContact().getPhone()); eventDetailEmail.setText(event.getContact().getEmail()); eventDetailWeHave.setText(event.getHave()); eventDetailBring.setText(event.getBring()); if (event.getGps() != null && event.getGps().getArea() != null && !TextUtils.isEmpty(event.getGps().getArea().getFormatedLocation())) { eventDetailPlace.setText(event.getGps().getArea().getFormatedLocation()); } else { Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault()); new GeocoderTask(geocoder, event.getGps().getLat(), event.getGps().getLng(), new GeocoderTask.Callback() { @Override public void onAddressComplete(GeocoderTask.GeocoderResult geocoderResult) { if (!TextUtils.isEmpty(geocoderResult.getFormattedAddress())) { eventDetailPlace.setText(geocoderResult.getFormattedAddress()); } else { eventDetailPlace.setVisibility(View.GONE); } } }).execute(); } eventDetailPosition.setText( PositionUtils.getFormattedLocation(getContext(), event.getGps().getLat(), event.getGps().getLng())); String mapUrl = PositionUtils.getStaticMapUrl(getActivity(), event.getGps().getLat(), event.getGps().getLng()); try { URI mapUri = new URI(mapUrl.replace("|", "%7c")); Log.d(TAG, "setupDumpData: mapUrl = " + String.valueOf(mapUri.toURL())); GlideApp.with(this).load(String.valueOf(mapUri.toURL())).centerCrop().dontTransform() .into(eventDetailMap); } catch (URISyntaxException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } if (event.getTrashPoints() != null && !event.getTrashPoints().isEmpty()) { eventDetailListOfTrashTitle.setVisibility(View.VISIBLE); eventDetailTrashlispCardView.setVisibility(View.VISIBLE); eventDetailTrashListContainer.removeAllViews(); for (TrashPoint trashPoint : event.getTrashPoints()) { if (eventDetailTrashListContainer.getChildCount() > 0) eventDetailTrashListContainer.addView(ViewUtils.getDividerView(getContext())); eventDetailTrashListContainer.addView(getTrashView(trashPoint)); } } else { eventDetailListOfTrashTitle.setVisibility(View.GONE); eventDetailTrashlispCardView.setVisibility(View.GONE); } }
From source file:org.mahasen.util.PutUtil.java
/** * @param part/*from w ww. jav a 2s.com*/ * @param parentFileName * @param partName * @throws MahasenConfigurationException * @throws PastException * @throws InterruptedException */ public void replicateFilePart(File part, String parentFileName, String partName) throws MahasenConfigurationException, PastException, InterruptedException, MahasenException { Vector<String> nodeIpsToPut = getNodeIpsToPut(); String resourcePath = MahasenConstants.ROOT_REGISTRY_PATH + parentFileName; Id parentFileId = Id.build(String.valueOf(resourcePath.hashCode())); while (mahasenManager.lookupDHT(parentFileId) == null) { Thread.sleep(1000); } MahasenResource mahasenResourceToUpdate = mahasenManager.lookupDHT(parentFileId); getReplicaReference().put(partName, 0); Random random = new Random(); Hashtable<String, Vector<String>> spittedPartsStoredIps = mahasenResourceToUpdate.getSplittedPartsIpTable(); Vector<String> currentPartStoredIps = spittedPartsStoredIps.get(partName); List<String> replicateIds = new ArrayList<String>(); final BlockFlag blockFlag = new BlockFlag(true, 3000); while (true) { if (nodeIpsToPut.size() >= MahasenConstants.NUMBER_OF_REPLICAS + 1) { if (getReplicaReference().get(partName) == MahasenConstants.NUMBER_OF_REPLICAS) { log.info("Success in replicating :" + getReplicaReference().get(partName) + " parts"); break; } String nodeIp = nodeIpsToPut.get(random.nextInt(nodeIpsToPut.size())); if (!currentPartStoredIps.contains(nodeIp) && !replicateIds.contains(nodeIp)) { replicateIds.add(nodeIp); try { sendReplicateRequest(nodeIp, part, partName, mahasenResourceToUpdate, parentFileId); } catch (URISyntaxException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } } else { for (String ip : nodeIpsToPut) { if (!currentPartStoredIps.contains(ip)) { try { sendReplicateRequest(ip, part, partName, mahasenResourceToUpdate, parentFileId); } catch (URISyntaxException e) { e.printStackTrace(); } } } blockFlag.unblock(); break; } if (blockFlag.isBlocked()) { mahasenManager.getNode().getEnvironment().getTimeSource().sleep(10); } else { throw new MahasenException("Time out in storing " + part.getName()); } Thread.sleep(100); } }