List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:com.thinkberg.webdav.DeleteHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = VFSBackend.resolveFile(request.getPathInfo()); try {/*from w ww. j av a 2 s . c om*/ String fragment = new URI(request.getRequestURI()).getFragment(); if (fragment != null) { response.sendError(HttpServletResponse.SC_FORBIDDEN); return; } } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } try { if (!LockManager.getInstance().evaluateCondition(object, getIf(request)).result) { response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return; } } catch (LockException e) { response.sendError(SC_LOCKED); return; } catch (ParseException e) { response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return; } if (object.exists()) { int deletedObjects = object.delete(ALL_FILES_SELECTOR); LOG.debug("deleted " + deletedObjects + " objects"); if (deletedObjects > 0) { response.setStatus(HttpServletResponse.SC_OK); } else { response.sendError(HttpServletResponse.SC_FORBIDDEN); } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }
From source file:com.jkoolcloud.jesl.simulator.tnt4j.JKCloudConnection.java
public synchronized void open() throws IOException { if (isOpen()) return;/*w w w . j a v a 2 s .com*/ try { jkHandle = new JKClient(gwUrl, getEventSink()); jkHandle.connect(accessToken); } catch (URISyntaxException e) { close(); throw new IOException(e.getMessage(), e); } }
From source file:com.orange.ngsi.model.SubscribeContextModelTest.java
@Test public void serializationSimpleSubscribeContext() throws IOException { SubscribeContext subscribeContext = null; try {// www. java 2 s .com subscribeContext = createSubscribeContextTemperature(); } catch (URISyntaxException e) { Assert.fail(e.getMessage()); } ObjectMapper mapper = new ObjectMapper(); ObjectWriter writer = mapper.writer(new DefaultPrettyPrinter()); String json = writer.writeValueAsString(subscribeContext); List<EntityId> entityIdList = JsonPath.read(json, "$.entities[*]"); assertEquals(1, entityIdList.size()); assertEquals("Room1", JsonPath.read(json, "$.entities[0].id")); assertEquals("Room", JsonPath.read(json, "$.entities[0].type")); assertEquals(false, JsonPath.read(json, "$.entities[0].isPattern")); assertEquals("P1M", JsonPath.read(json, "$.duration")); List<String> attributes = JsonPath.read(json, "$.attributes[*]"); assertEquals(1, attributes.size()); assertEquals("temperature", JsonPath.read(json, "$.attributes[0]")); assertEquals("http://localhost:1028/accumulate", JsonPath.read(json, "$.reference")); List<NotifyCondition> notifyConditionList = JsonPath.read(json, "$.notifyConditions[*]"); assertEquals(1, notifyConditionList.size()); assertEquals(NotifyConditionEnum.ONTIMEINTERVAL.getLabel(), JsonPath.read(json, "$.notifyConditions[0].type")); List<String> condValues = JsonPath.read(json, "$.notifyConditions[0].condValues[*]"); assertEquals(1, condValues.size()); assertEquals("PT10S", JsonPath.read(json, "$.notifyConditions[0].condValues[0]")); }
From source file:gov.nih.nci.cacis.openxds.service.XdsRepositoryProxy.java
/** * provideAndRegisterDocumentSetRequest//w w w .j a v a2s .c o m * * @param request OMElement * @return OMElement * @throws AxisFault fault */ public OMElement provideAndRegisterDocumentSetRequest(OMElement request) throws AxisFault { LOG.debug("in Proxy provideAndRegisterDocumentSetRequest"); OMElement response = null; try { final ServiceClient sender = getServiceClientFactory() .getRepositoryServiceClient("urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b"); response = sender.sendReceive(request); } catch (URISyntaxException e) { throw new AxisFault(e.getMessage()); //NOPMD needs to throw AxisFault } catch (IOException e) { throw new AxisFault(e.getMessage()); //NOPMD needs to throw AxisFault } return response; }
From source file:gov.nih.nci.cacis.openxds.service.XdsRepositoryProxy.java
/** * RetrieveDocumentSetRequest operation * @param request retrieveDocumentSetRequest * @return Response// w w w . j ava 2 s . c o m * @throws AxisFault Fault */ public OMElement retrieveDocumentSetRequest(OMElement request) throws AxisFault { LOG.debug("in Proxy retrieveDocumentSetRequest"); OMElement response = null; try { final ServiceClient sender = getServiceClientFactory() .getRepositoryServiceClient("urn:ihe:iti:2007:RetrieveDocumentSet"); response = sender.sendReceive(request); } catch (URISyntaxException e) { throw new AxisFault(e.getMessage()); //NOPMD needs to throw AxisFault } catch (IOException e) { throw new AxisFault(e.getMessage()); //NOPMD needs to throw AxisFault } return response; }
From source file:ch.cyberduck.core.azure.AzureDirectoryFeature.java
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try {//from w w w .ja va2 s .c om final BlobRequestOptions options = new BlobRequestOptions(); if (containerService.isContainer(folder)) { // Container name must be lower case. final CloudBlobContainer container = session.getClient() .getContainerReference(containerService.getContainer(folder).getName()); container.create(options, context); } else { if (Checksum.NONE == status.getChecksum()) { status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status)); } final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType()); type.add(Path.Type.placeholder); final Path placeholder = new Path(folder.getParent(), folder.getName(), type, new PathAttributes(folder.attributes())); new DefaultStreamCloser() .close(writer.write(placeholder, status, new DisabledConnectionCallback())); return placeholder; } } catch (URISyntaxException e) { throw new NotfoundException(e.getMessage(), e); } catch (StorageException e) { throw new AzureExceptionMappingService().map("Cannot create folder {0}", e, folder); } return folder; }
From source file:bova.rtmapi.RestClient.java
String test() throws ServerException, RtmApiException, IOException { //Rimuovere!!!!! // Execute HTTP Post Request HttpClient httpclient = new DefaultHttpClient(); URI uri;//from w ww . j a va2s .c o m try { uri = new URI(this.request.getUrl()); HttpPost httppost = new HttpPost(uri); HttpResponse response = httpclient.execute(httppost); // Get string from response InputStream is = response.getEntity().getContent(); StringBuilder sb = new StringBuilder(); BufferedReader r = new BufferedReader(new InputStreamReader(new DoneHandlerInputStream(is))); for (String line = r.readLine(); line != null; line = r.readLine()) { sb.append(line); } return sb.toString(); } catch (URISyntaxException e) { throw new RtmApiException(e.getMessage()); } catch (ClientProtocolException e) { throw new RtmApiException(e.getMessage()); } }
From source file:org.dataconservancy.ui.it.support.CreateProjectApiAddRequest.java
public HttpPost asHttpPost() { HttpPost post = null;/*from w ww . j a va 2 s. c o m*/ try { post = new HttpPost(uiUrlConfig.getProjectApiUrl().toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e.getMessage(), e); } ByteArrayOutputStream sink = new ByteArrayOutputStream(); builder.buildProject(project, sink); ByteArrayEntity projectEntity = new ByteArrayEntity(sink.toByteArray()); projectEntity.setContentEncoding("UTF-8"); post.addHeader("Content-Type", "text/xml"); post.setEntity(projectEntity); return post; }
From source file:bova.rtmapi.RestClient.java
JSONResponse execute() throws ServerException, RtmApiException, IOException { // Execute HTTP Post Request HttpClient httpclient = new DefaultHttpClient(); URI uri;/* w w w . j a v a 2s . co m*/ try { uri = new URI(this.request.getUrl()); HttpPost httppost = new HttpPost(uri); HttpResponse response = httpclient.execute(httppost); // Get string from response InputStream is = response.getEntity().getContent(); try { StringBuilder sb = new StringBuilder(); BufferedReader r = new BufferedReader(new InputStreamReader(new DoneHandlerInputStream(is))); for (String line = r.readLine(); line != null; line = r.readLine()) { sb.append(line); } // get JSON Response from string and return it return new JSONResponse(sb.toString()); } finally { is.close(); } } catch (URISyntaxException e) { throw new RtmApiException(e.getMessage()); } catch (ClientProtocolException e) { throw new RtmApiException(e.getMessage()); } }
From source file:com.macrossx.wechat.impl.WechatMenuHelper.java
@Override public Optional<WechatMenu> getMenu() { try {//from ww w .java2s . c om Optional<WechatAccessToken> token = wechatHelper.getAccessToken(); if (token.isPresent()) { WechatAccessToken accessToken = token.get(); HttpGet httpGet = new HttpGet(); httpGet.setURI( new URI(MessageFormat.format(WechatConstants.MENU_GET_URL, accessToken.getAccess_token()))); return new WechatHttpClient().send(httpGet, WechatMenu.class); } } catch (URISyntaxException e) { log.info(e.getMessage()); } return Optional.empty(); }