List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:org.flowable.admin.service.engine.FlowableClientService.java
public URIBuilder createUriBuilder(String url) { try {// w ww . java 2s . c o m return new URIBuilder(url); } catch (URISyntaxException e) { throw new FlowableServiceException("Error while creating Flowable endpoint URL: " + e.getMessage()); } }
From source file:org.flowable.admin.service.engine.FlowableClientService.java
public String getServerUrl(ServerConfig serverConfig, URIBuilder builder) { try {/* w w w. j a v a 2 s. co m*/ return getServerUrl(serverConfig, builder.build().toString()); } catch (URISyntaxException e) { throw new FlowableServiceException("Error while creating Flowable endpoint URL: " + e.getMessage()); } }
From source file:org.dasein.cloud.ibm.sce.SCEMethod.java
public @Nullable Document getAsXML(@Nonnull String resource) throws CloudException, InternalException { try {/* w ww.j a v a 2 s.co m*/ return getAsXML(new URI(endpoint + resource), resource); } catch (URISyntaxException e) { throw new InternalException( "Endpoint misconfiguration (" + endpoint + resource + "): " + e.getMessage()); } }
From source file:org.wrml.server.WrmlServletTest.java
@Test public void testGetRequestUriBadHost() throws IOException, URISyntaxException { MockHttpServletRequest request = new MockHttpServletRequest(); initMockHttpRequest(request, CAPRICA_SIX_ENDPOINT); request.setMethod(Method.Get.getProtocolGivenName()); request.addHeader(WrmlServlet.WRML_HOST_HEADER_NAME, BAD_HOST_1); try {/*www .jav a 2s . co m*/ _Servlet.getRequestUri(request); } catch (URISyntaxException use) { Assert.assertTrue(use.getMessage().contains(BAD_HOST_1)); return; } Assert.assertTrue(false); }
From source file:org.wrml.server.WrmlServletTest.java
@Test public void testGetResourceIdBadHost2() throws IOException, URISyntaxException { MockHttpServletRequest request = new MockHttpServletRequest(); initMockHttpRequest(request, CAPRICA_SIX_ENDPOINT); request.setMethod(Method.Get.getProtocolGivenName()); //request.addHeader(HttpHeaders.ACCEPT, JSON_MEDIA_TYPE); request.addHeader(WrmlServlet.WRML_HOST_HEADER_NAME, BAD_HOST_2); try {//from w w w .j a va 2s . co m URI resourceUri = _Servlet.getRequestUri(request); } catch (URISyntaxException use) { Assert.assertTrue(use.getMessage().contains(BAD_HOST_2)); return; } Assert.assertTrue(false); }
From source file:net.sourceforge.dita4publishers.impl.ditabos.DitaTreeWalkerBase.java
public void walk(DitaBoundedObjectSet bos, Document mapDoc) throws Exception { URI mapUri;//from ww w .j a v a2s.c om try { String mapUriStr = mapDoc.getDocumentURI(); if (mapUriStr == null || "".equals(mapUriStr)) throw new BosException("Map document has a null or empty document URI property. Cannot continue."); mapUri = new URI(mapUriStr); } catch (URISyntaxException e) { throw new BosException("Failed to construct URI from document URI \"" + mapDoc.getDocumentURI() + "\": " + e.getMessage()); } log.debug("walk(): Walking document " + mapUri.toString() + "..."); // Add this map's keys to the key space. XmlBosMember member = bos.constructBosMember((BosMember) null, mapDoc); Element elem = mapDoc.getDocumentElement(); bos.setRootMember(member); bos.setKeySpace(keySpace); // NOTE: if input is a map, then walking the map // will populate the key namespace before processing // any topics, so that key references can be resolved. // If the input is a topic, then the key space must have // already been populated if there are any key references // to be resolved. if (DitaUtil.isDitaMap(elem)) { log.debug("walk(): Adding root map's keys to key space..."); keySpace.addKeyDefinitions(elem); // Walk the map to determine the tree of maps and calculate // the key space rooted at the starting map: log.debug("walk(): Walking the map to calculate the map tree..."); walkMapCalcMapTree(bos, member, mapDoc, 1); log.debug("walk(): Map tree calculated."); // At this point, we have a set of map BOS members and a populated key space; // Iterate over the maps to find all non-map dependencies (topics, images, // objects, xref targets, and link targets): log.debug("walk(): Calculating map dependencies for map " + member.getKey() + "..."); Collection<BosMember> mapMembers = bos.getMembers(); Iterator<BosMember> iter = mapMembers.iterator(); while (iter.hasNext()) { BosMember mapMember = iter.next(); walkMapGetDependencies(bos, (DitaMapBosMember) mapMember); } log.debug("walk(): Map dependencies calculated."); } else if (DitaUtil.isDitaTopic(elem)) { log.debug("walk(): Calculating topic dependencies for topic " + member.getKey() + "..."); walkTopic(bos, (XmlBosMember) member, 1); log.debug("walk(): Topic dependencies calculated."); } else { // Not a map or topic, delegate walking: walkNonDitaResource(bos, (NonXmlBosMember) member, 1); } }
From source file:com.trellmor.berrymotes.sync.EmoteDownloader.java
public void start(SyncResult syncResult) { Log.info("EmoteDownload started"); this.updateNetworkInfo(); mSyncResult = syncResult;//from www . ja v a2 s . com if (!mIsConnected) { Log.error("Network not available"); syncResult.stats.numIoExceptions++; return; } // Registers BroadcastReceiver to track network connection changes. IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); NetworkReceiver receiver = new NetworkReceiver(); mContext.registerReceiver(receiver, filter); ExecutorService executor = Executors.newFixedThreadPool(THREAD_COUNT); mHttpClient = AndroidHttpClient.newInstance(USER_AGENT); try { String[] subreddits = getSubreddits(); for (String subreddit : subreddits) { if (mSubreddits.isChecked(subreddit)) { Runnable subredditEmoteDownloader = new SubredditEmoteDownloader(mContext, this, subreddit); executor.execute(subredditEmoteDownloader); } else { // Delete this subreddit deleteSubreddit(subreddit, mContentResolver); // Reset last download date SharedPreferences.Editor settings = PreferenceManager.getDefaultSharedPreferences(mContext) .edit(); settings.remove(SettingsActivity.KEY_SYNC_LAST_MODIFIED + subreddit); settings.commit(); } } executor.shutdown(); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (URISyntaxException e) { Log.error("Emotes URL is malformed", e); synchronized (mSyncResult) { mSyncResult.stats.numParseExceptions++; if (mSyncResult.delayUntil < 60 * 60) mSyncResult.delayUntil = 60 * 60; } return; } catch (IOException e) { Log.error("Error reading from network: " + e.getMessage(), e); synchronized (mSyncResult) { mSyncResult.stats.numIoExceptions++; if (mSyncResult.delayUntil < 30 * 60) mSyncResult.delayUntil = 30 * 60; } return; } catch (InterruptedException e) { synchronized (mSyncResult) { syncResult.moreRecordsToGet = true; } Log.info("Sync interrupted"); executor.shutdownNow(); try { executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e2) { } Thread.currentThread().interrupt(); } finally { Log.info("Deleted emotes: " + Long.toString(mSyncResult.stats.numDeletes)); Log.info("Added emotes: " + Long.toString(mSyncResult.stats.numInserts)); // Unregisters BroadcastReceiver at the end mContext.unregisterReceiver(receiver); mHttpClient.close(); } Log.info("EmoteDownload finished"); }
From source file:com.haulmont.idp.controllers.IdpController.java
@GetMapping(value = "/") public String checkIdpSession(@RequestParam(value = "sp", defaultValue = "") String serviceProviderUrl, @RequestParam(value = "response_type", defaultValue = "server-ticket") String responseType, @CookieValue(value = CUBA_IDP_COOKIE_NAME, defaultValue = "") String idpSessionCookie, HttpServletResponse response) {// w ww . j av a2 s. c om if (!Strings.isNullOrEmpty(serviceProviderUrl) && !idpConfig.getServiceProviderUrls().contains(serviceProviderUrl)) { log.warn("Incorrect serviceProviderUrl {} passed, will be used default", serviceProviderUrl); serviceProviderUrl = null; } if (Strings.isNullOrEmpty(serviceProviderUrl)) { if (!idpConfig.getServiceProviderUrls().isEmpty()) { serviceProviderUrl = idpConfig.getServiceProviderUrls().get(0); } else { log.error("IDP property cuba.idp.serviceProviderUrls is not set"); response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); return null; } } if (!Strings.isNullOrEmpty(idpSessionCookie)) { String serviceProviderTicket = idpService.createServiceProviderTicket(idpSessionCookie); if (serviceProviderTicket != null) { String serviceProviderRedirectUrl; try { URIBuilder uriBuilder = new URIBuilder(serviceProviderUrl); if (ResponseType.CLIENT_TICKET.getCode().equals(responseType)) { uriBuilder.setFragment(CUBA_IDP_TICKET_PARAMETER + "=" + serviceProviderTicket); } else { uriBuilder.setParameter(CUBA_IDP_TICKET_PARAMETER, serviceProviderTicket); } serviceProviderRedirectUrl = uriBuilder.build().toString(); } catch (URISyntaxException e) { log.warn("Unable to compose redirect URL", e); response.setStatus(HttpStatus.BAD_REQUEST.value()); return null; } try { response.sendRedirect(serviceProviderRedirectUrl); } catch (IOException e) { // do not log stacktrace here log.warn("Unable to send redirect to service provider URL", e.getMessage()); } log.debug("New ticket {} created for already logged in user", serviceProviderTicket); return null; } else { log.debug("IDP session {} not found, login required", idpSessionCookie); } } // remove auth cookie Cookie cookie = new Cookie(CUBA_IDP_COOKIE_NAME, ""); cookie.setMaxAge(0); response.addCookie(cookie); if (ResponseType.CLIENT_TICKET.getCode().equals(responseType)) { return "redirect:login.html" + "?response_type=" + ResponseType.CLIENT_TICKET.getCode() + "&sp=" + URLEncodeUtils.encodeUtf8(serviceProviderUrl); } return "redirect:login.html?sp=" + URLEncodeUtils.encodeUtf8(serviceProviderUrl); }
From source file:edu.jhu.pha.vospace.meta.MySQLMetaStore2.java
@Override public NodesList getNodeChildren(final VospaceId identifier, final boolean searchDeep /*always false*/, final boolean includeDeleted /*not used*/, final int start, final int count) { if (identifier.getNodePath().isRoot(false)) { String deletedCondition = includeDeleted ? "" : "nodes.`deleted` = 0 AND "; return DbPoolServlet.goSql("GetNodeChildren root request", "SELECT SQL_CALC_FOUND_ROWS containers.container_name as container, nodes.rev, nodes.deleted, nodes.mtime, nodes.size, nodes.mimetype, nodes.type " + "FROM nodes JOIN containers ON nodes.container_id = containers.container_id JOIN user_identities ON containers.user_id = user_identities.user_id " + "WHERE " + deletedCondition + "`parent_node_id` is NULL AND `identity` = ? AND `container_name` <> '' order by container " + ((count > 0) ? " limit ?, ?" : ""), new SqlWorker<NodesList>() { @Override/*from w w w. j a v a 2s. c o m*/ public NodesList go(Connection conn, PreparedStatement stmt) throws SQLException { ArrayList<Node> result = new ArrayList<Node>(); int countRows = 0; stmt.setString(1, owner); if (count > 0) { stmt.setInt(2, start); stmt.setInt(3, count); } ResultSet rs = stmt.executeQuery(); while (rs.next()) { try { VospaceId id = new VospaceId(new NodePath(rs.getString("container"))); id.getNodePath() .setEnableAppContainer(identifier.getNodePath().isEnableAppContainer()); NodeInfo info = new NodeInfo(); info.setRevision(rs.getInt("rev")); info.setDeleted(rs.getBoolean("deleted")); info.setMtime(new Date(rs.getTimestamp("mtime").getTime())); info.setSize(rs.getLong("size")); info.setContentType(rs.getString("mimetype")); Node newNode = NodeFactory.createNode(id, owner, NodeType.valueOf(rs.getString("type"))); newNode.setNodeInfo(info); result.add(newNode); } catch (URISyntaxException e) { logger.error("Error in child URI: " + e.getMessage()); } } ResultSet resSet = conn.createStatement().executeQuery("SELECT FOUND_ROWS();"); resSet.next(); countRows = resSet.getInt(1); return new NodesList(result, countRows); } }); } else { String deletedCondition = includeDeleted ? "" : "nodes.`deleted` = 0 AND "; String request = "SELECT SQL_CALC_FOUND_ROWS containers.container_name as container, nodes.path, nodes.rev, nodes.deleted, nodes.mtime, nodes.size, nodes.mimetype, nodes.type " + "FROM nodes JOIN containers ON nodes.container_id = containers.container_id " + "JOIN user_identities ON containers.user_id = user_identities.user_id " + "JOIN nodes b ON nodes.parent_node_id = b.node_id " + "WHERE " + deletedCondition + "containers.container_name = ? AND b.`path` = ? AND `identity` = ? order by path " + ((count > 0) ? " limit ?, ?" : ""); return DbPoolServlet.goSql("GetNodeChildren request", request, new SqlWorker<NodesList>() { @Override public NodesList go(Connection conn, PreparedStatement stmt) throws SQLException { ArrayList<Node> result = new ArrayList<Node>(); int countRows = 0; stmt.setString(1, identifier.getNodePath().getContainerName()); stmt.setString(2, identifier.getNodePath().getNodeRelativeStoragePath()); stmt.setString(3, owner); if (count > 0) { stmt.setInt(4, start); stmt.setInt(5, count); } ResultSet rs = stmt.executeQuery(); while (rs.next()) { try { VospaceId id = new VospaceId( new NodePath(rs.getString("container") + "/" + rs.getString("path"))); id.getNodePath().setEnableAppContainer(identifier.getNodePath().isEnableAppContainer()); NodeInfo info = new NodeInfo(); info.setRevision(rs.getInt("rev")); info.setDeleted(rs.getBoolean("deleted")); info.setMtime(new Date(rs.getTimestamp("mtime").getTime())); info.setSize(rs.getLong("size")); info.setContentType(rs.getString("mimetype")); Node newNode = NodeFactory.createNode(id, owner, NodeType.valueOf(rs.getString("type"))); newNode.setNodeInfo(info); result.add(newNode); } catch (URISyntaxException e) { logger.error("Error in child URI: " + e.getMessage()); } } ResultSet resSet = conn.createStatement().executeQuery("SELECT FOUND_ROWS();"); resSet.next(); countRows = resSet.getInt(1); return new NodesList(result, countRows); } }); } }