List of usage examples for java.net URISyntaxException printStackTrace
public void printStackTrace()
From source file:org.gege.caldavsyncadapter.caldav.entities.DavCalendar.java
/** * example: http://caldav.example.com/calendarserver.php/calendars/username/calendarname *//*from w w w. j a va2s . c o m*/ public URI getURI() { String strUri = this.getContentValueAsString(DavCalendar.URI); URI result = null; try { result = new URI(strUri); } catch (URISyntaxException e) { e.printStackTrace(); } return result; }
From source file:org.orcid.api.t1.server.T1OrcidApiServiceImplBase.java
/** * returns a redirect to experimental rdf api * //from w w w.java2 s. c om * @param orcid * the ORCID that corresponds to the user's record * @return A 307 redirect */ @GET @Produces(value = { APPLICATION_RDFXML }) @Path(BIO_PATH) public Response redirBioDetailsRdf(@PathParam("orcid") String orcid) { URI uri = null; try { uri = new URI(pubBaseUri + EXPERIMENTAL_RDF_V1 + "/" + orcid); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return Response.temporaryRedirect(uri).build(); }
From source file:org.orcid.api.t1.server.T1OrcidApiServiceImplBase.java
/** * returns a redirect to experimental rdf api * /*from w w w . j a va 2 s.co m*/ * @param orcid * the ORCID that corresponds to the user's record * @return A 307 redirect */ @GET @Produces(value = { TEXT_N3, TEXT_TURTLE }) @Path(BIO_PATH) public Response redirBioDetailsTurtle(@PathParam("orcid") String orcid) { URI uri = null; try { uri = new URI(pubBaseUri + EXPERIMENTAL_RDF_V1 + "/" + orcid); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return Response.temporaryRedirect(uri).build(); }
From source file:org.kalypso.core.catalog.DynamicCatalog.java
@SuppressWarnings("unchecked") //$NON-NLS-1$ private void addEntry(final String uri, final String entryID, final int entryType, final boolean relative) { if (entryID == null || "".equals(entryID)) //$NON-NLS-1$ return;//from w w w .ja va2 s . co m if (!entryID.startsWith("urn:")) //$NON-NLS-1$ { switch (entryType) { case SYSTEM_ID: internalAddEntry(uri, entryID, null, relative); break; case PUBLIC_ID: internalAddEntry(uri, null, entryID, relative); break; default: throw new UnsupportedOperationException(); } return; } final int max = CatalogUtilities.getMaxLevel(entryID); final String baseURN = CatalogUtilities.getUrnSection(entryID, 1, max - 1) + ":"; //$NON-NLS-1$ // check the internal policy for our dynamic catalogs // either // 1. the requested catalog is this catalog // or // 2. it is a delegated catalog // check 1: this catalog ? final String myBaseURN = getBase(); if (myBaseURN.equals(baseURN)) { switch (entryType) { case SYSTEM_ID: internalAddEntry(uri, entryID, null, relative); break; case PUBLIC_ID: internalAddEntry(uri, null, entryID, relative); break; default: throw new UnsupportedOperationException(); } return; } // check 2: a delegate ? final List<Object> publicOrSystemOrUri = m_catalog.getPublicOrSystemOrUri(); for (final Object object : publicOrSystemOrUri) { final Object item = ((JAXBElement<Object>) object).getValue(); if (item instanceof DelegateURI) { final DelegateURI delegateURI = (DelegateURI) item; final String uriStartString = delegateURI.getUriStartString(); if (baseURN.startsWith(uriStartString)) { // delegate matches final String catalogID = delegateURI.getCatalog(); final String uriToCatalog = resolve(catalogID, catalogID); final ICatalog catalog; try { catalog = m_manager.getCatalog(new URI(uriToCatalog)); switch (entryType) { case SYSTEM_ID: if (relative) catalog.addEntryRelative(uri, entryID, null); else catalog.addEntry(uri, entryID, null); break; case PUBLIC_ID: if (relative) catalog.addEntryRelative(uri, null, entryID); else catalog.addEntry(uri, null, entryID); break; default: throw new UnsupportedOperationException(); } return; } catch (final URISyntaxException e) { e.printStackTrace(); throw new UnsupportedOperationException(e); } } } } // catalog seems to be non existing final int maxLevel = CatalogUtilities.getMaxLevel(myBaseURN); final String urnSection = CatalogUtilities.getUrnSection(baseURN, maxLevel + 1); final String newCatalogURIBase = CatalogUtilities.addURNSection(myBaseURN, urnSection) + ":"; //$NON-NLS-1$ final String newCatalogURN = CatalogUtilities.createCatalogURN(newCatalogURIBase); try { m_manager.ensureExisting(newCatalogURIBase); } catch (final Exception e) { e.printStackTrace(); throw new UnsupportedOperationException(e); } // create a delegate to a new catalog // the catalog will be created on demand final DelegateURI catalogURIEntry = CatalogManager.OBJECT_FACTORY_CATALOG.createDelegateURI(); catalogURIEntry.setUriStartString(newCatalogURIBase); catalogURIEntry.setCatalog(newCatalogURN); publicOrSystemOrUri.add(CatalogManager.OBJECT_FACTORY_CATALOG.createDelegateURI(catalogURIEntry)); final System catalogSystemEntry = CatalogManager.OBJECT_FACTORY_CATALOG.createSystem(); catalogSystemEntry.setSystemId(newCatalogURN); catalogSystemEntry.setUri(urnSection + "/" + CatalogUtilities.CATALOG_FILE_NAME); //$NON-NLS-1$ publicOrSystemOrUri.add(CatalogManager.OBJECT_FACTORY_CATALOG.createSystem(catalogSystemEntry)); // next time catalog will be available addEntry(uri, entryID, entryType, relative); }
From source file:org.gege.caldavsyncadapter.caldav.entities.DavCalendar.java
/** * creates an new instance from a cursor * @param cur must be a cursor from "ContentProviderClient" with Uri Calendars.CONTENT_URI *//* www. ja v a 2s . c o m*/ public DavCalendar(Account account, ContentProviderClient provider, Cursor cur, CalendarSource source, String serverUrl) { this.mAccount = account; this.mProvider = provider; this.foundClientSide = true; this.Source = source; this.ServerUrl = serverUrl; String strSyncID = cur.getString(cur.getColumnIndex(Calendars._SYNC_ID)); String strName = cur.getString(cur.getColumnIndex(Calendars.NAME)); String strDisplayName = cur.getString(cur.getColumnIndex(Calendars.CALENDAR_DISPLAY_NAME)); String strCTAG = cur.getString(cur.getColumnIndex(DavCalendar.CTAG)); String strServerUrl = cur.getString(cur.getColumnIndex(DavCalendar.SERVERURL)); int intAndroidCalendarId = cur.getInt(cur.getColumnIndex(Calendars._ID)); this.setCalendarName(strName); this.setCalendarDisplayName(strDisplayName); this.setCTag(strCTAG, false); this.setAndroidCalendarId(intAndroidCalendarId); if (strSyncID == null) { this.correctSyncID(strName); strSyncID = strName; } if (strServerUrl == null) { this.correctServerUrl(serverUrl); } URI uri = null; try { uri = new URI(strSyncID); } catch (URISyntaxException e) { e.printStackTrace(); } this.setURI(uri); }
From source file:com.lunix.cheata.gui.CheataMainMenu.java
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) *//*from w w w.j av a2 s . co m*/ protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 0) { this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); } if (button.id == 5) { this.mc.displayGuiScreen(new GuiLanguage(this, this.mc.gameSettings, this.mc.getLanguageManager())); } if (button.id == 1) { this.mc.displayGuiScreen(new GuiWorldSelection(this)); } if (button.id == 2) { this.mc.displayGuiScreen(new GuiMultiplayer(this)); } if (button.id == 4) { this.mc.shutdown(); } if (button.id == 11) { this.mc.launchIntegratedServer("Demo_World", "Demo_World", DemoWorldServer.demoWorldSettings); } if (button.id == 12) { ISaveFormat isaveformat = this.mc.getSaveLoader(); WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); if (worldinfo != null) { this.mc.displayGuiScreen( new GuiYesNo(this, I18n.format("selectWorld.deleteQuestion", new Object[0]), "\'" + worldinfo.getWorldName() + "\' " + I18n.format("selectWorld.deleteWarning", new Object[0]), I18n.format("selectWorld.deleteButton", new Object[0]), I18n.format("gui.cancel", new Object[0]), 12)); } } if (button.id == 21) { this.mc.displayGuiScreen(new CheataGui(this)); } if (button.id == 24) { try { final URL url = new URL("https://github.com/CheataClient/CheataClient"); URI uri = url.toURI(); Desktop.getDesktop().browse(uri); } catch (URISyntaxException e) { e.printStackTrace(); } } }
From source file:com.sourcesense.confluence.servlets.CMISProxyServlet.java
protected String getProxyHost(HttpServletRequest httpServletRequest) { String serverName = httpServletRequest.getParameter("servername"); if (serverName != null) { List<String> up = getConfigurationList(serverName); if (up != null) { if (httpServletRequest.getPathInfo() == null || httpServletRequest.getPathInfo().equals("/")) { return up.get(0); } else { try { URI uri = new URI(up.get(0)); if (uri.getPort() != -1) { return uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort(); } else return uri.getScheme() + uri.getHost(); } catch (URISyntaxException e) { e.printStackTrace(); }//from w w w . j av a 2 s . c o m } } } return null; }
From source file:org.hfoss.posit.web.Communicator.java
/** * A wrapper(does some cleanup too) for sending HTTP GET requests to the URI * //www .j a va 2 s . c o m * @param Uri * @return the request from the remote server */ public String doHTTPGET(String Uri) { if (Uri == null) throw new NullPointerException("The URL has to be passed"); String responseString = null; HttpGet httpGet = new HttpGet(); try { httpGet.setURI(new URI(Uri)); } catch (URISyntaxException e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); return "[Error]" + e.getMessage(); } if (Utils.debug) { Log.i(TAG, "doHTTPGet Uri = " + Uri); } ResponseHandler<String> responseHandler = new BasicResponseHandler(); mStart = System.currentTimeMillis(); try { responseString = mHttpClient.execute(httpGet, responseHandler); } catch (ClientProtocolException e) { Log.e(TAG, "ClientProtocolException" + e.getMessage()); e.printStackTrace(); return "[Error]" + e.getMessage(); } catch (IOException e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); return "[Error]" + e.getMessage(); } catch (Exception e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); return "[Error]" + e.getMessage(); } long time = System.currentTimeMillis() - mStart; mTotalTime += time; Log.i(TAG, "TIME = " + time + " millisecs"); if (Utils.debug) Log.i(TAG, "doHTTPGet Response: " + responseString); return responseString; }
From source file:com.funambol.LDAP.security.LDAPMailUserProvisioningOfficer.java
/** * return an URI from the server, eventually using a default protocol *///w w w . j a va 2 s . c o m protected URI getServerUri(String s, String proto) { URI u = null; String protocol; int port; try { if (s.indexOf(URL_SCHEME_SEPARATOR) < 0) { s = proto + URL_SCHEME_SEPARATOR + s; } u = new URI(s); protocol = (u.getSchemeSpecificPart() != null) ? u.getScheme() : proto; if (u.getPort() == -1) { if (PROTO_IMAP.equals(protocol)) { port = 143; } else if (PROTO_IMAPS.equals(protocol)) { port = 993; } else if (PROTO_SMTP.equals(protocol)) { port = 25; } else if (PROTO_SMTPS.equals(protocol)) { port = 465; } else if (PROTO_POP.equals(protocol)) { port = 110; } else if (PROTO_POPS.equals(protocol)) { port = 995; } else { throw new URISyntaxException(protocol, "Invalid protocol: " + protocol); } // else { // port = -1; // if (log.isDebugEnabled()) { // log.debug("no protocol defined, an error will rise if no default protocol defined in DefaultMailServer.xml"); // } // } } else { port = u.getPort(); } u = new URI(protocol, null, u.getHost(), port, null, null, null); } catch (URISyntaxException e) { log.error("can't parse uri from string: " + s); e.printStackTrace(); } return u; }
From source file:org.apache.hadoop.mapred.gridmix.DistributedCacheEmulator.java
/** * This is to be called before any other method of DistributedCacheEmulator. * <br> Checks if emulation of distributed cache load is needed and is feasible. * Sets the flags generateDistCacheData and emulateDistributedCache to the * appropriate values.//from w w w . j a va 2 s . c o m * <br> Gridmix does not emulate distributed cache load if * <ol><li> the specific gridmix job type doesn't need emulation of * distributed cache load OR * <li> the trace is coming from a stream instead of file OR * <li> the distributed cache dir where distributed cache data is to be * generated by gridmix is on local file system OR * <li> execute permission is not there for any of the ascendant directories * of <ioPath> till root. This is because for emulation of distributed * cache load, distributed cache files created under * <ioPath/distributedCache/> should be considered by hadoop * as public distributed cache files. * <li> creation of pseudo local file system fails.</ol> * <br> For (2), (3), (4) and (5), generation of distributed cache data * is also disabled. * * @param traceIn trace file path. If this is '-', then trace comes from the * stream stdin. * @param jobCreator job creator of gridmix jobs of a specific type * @param generate true if -generate option was specified * @throws IOException */ void init(String traceIn, JobCreator jobCreator, boolean generate) throws IOException { emulateDistributedCache = jobCreator.canEmulateDistCacheLoad() && conf.getBoolean(GRIDMIX_EMULATE_DISTRIBUTEDCACHE, true); generateDistCacheData = generate; if (generateDistCacheData || emulateDistributedCache) { if ("-".equals(traceIn)) {// trace is from stdin LOG.warn("Gridmix will not emulate Distributed Cache load because " + "the input trace source is a stream instead of file."); emulateDistributedCache = generateDistCacheData = false; } else if (FileSystem.getLocal(conf).getUri().getScheme().equals(distCachePath.toUri().getScheme())) {// local FS LOG.warn("Gridmix will not emulate Distributed Cache load because " + "<iopath> provided is on local file system."); emulateDistributedCache = generateDistCacheData = false; } else { // Check if execute permission is there for all the ascendant // directories of distCachePath till root. FileSystem fs = FileSystem.get(conf); Path cur = distCachePath.getParent(); while (cur != null) { if (cur.toString().length() > 0) { FsPermission perm = fs.getFileStatus(cur).getPermission(); if (!perm.getOtherAction().and(FsAction.EXECUTE).equals(FsAction.EXECUTE)) { LOG.warn("Gridmix will not emulate Distributed Cache load " + "because the ascendant directory (of distributed cache " + "directory) " + cur + " doesn't have execute permission " + "for others."); emulateDistributedCache = generateDistCacheData = false; break; } } cur = cur.getParent(); } } } // Check if pseudo local file system can be created try { pseudoLocalFs = FileSystem.get(new URI("pseudo:///"), conf); } catch (URISyntaxException e) { LOG.warn("Gridmix will not emulate Distributed Cache load because " + "creation of pseudo local file system failed."); e.printStackTrace(); emulateDistributedCache = generateDistCacheData = false; return; } }