List of usage examples for java.net URISyntaxException getLocalizedMessage
public String getLocalizedMessage()
From source file:com.marklogic.semantics.sesame.client.MarkLogicClientImpl.java
/** * bind object// w w w . j av a2 s. c o m * * @param qdef * @param variableName * @param object * @return * @throws MarkLogicSesameException */ private static SPARQLQueryDefinition bindObject(SPARQLQueryDefinition qdef, String variableName, Value object) throws MarkLogicSesameException { SPARQLBindings bindings = qdef.getBindings(); if (object != null) { if (object instanceof URI) { bindings.bind(variableName, object.stringValue()); } else if (object instanceof Literal) { Literal lit = (Literal) object; if (lit.getLanguage() != null) { String languageTag = lit.getLanguage(); bindings.bind(variableName, lit.getLabel(), Locale.forLanguageTag(languageTag)); } else if (((Literal) object).getDatatype() != null) { try { String xsdType = lit.getDatatype().toString(); String fragment = new java.net.URI(xsdType).getFragment(); bindings.bind(variableName, lit.getLabel(), RDFTypes.valueOf(fragment.toUpperCase())); } catch (URISyntaxException e) { logger.error(e.getLocalizedMessage()); throw new MarkLogicSesameException("Problem with object datatype."); } } else { // assume we have a string value bindings.bind(variableName, lit.getLabel(), RDFTypes.STRING); } } qdef.setBindings(bindings); } return qdef; }
From source file:pcgen.util.TestHelper.java
/** * Make an ability/* w w w .jav a 2 s.c om*/ * * @param input the Ability source string to parse and create the ability from * @return true if OK */ public static boolean makeAbilityFromString(final String input) { loadPlugins(); try { if (null == source) { try { source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + TestHelper.class.getName() + ".java")); } catch (URISyntaxException e) { throw new UnreachableError(e); } } abLoader.parseLine(Globals.getContext(), null, input, source); return true; } catch (Exception e) { Logging.errorPrint(e.getLocalizedMessage()); } return false; }
From source file:org.opencms.site.xmlsitemap.CmsXmlSitemapGenerator.java
/** * Replaces the protocol/host/port of a link with the ones from the given server URI, if it's not empty.<p> * * @param link the link to change/*from w w w .ja va 2 s . co m*/ * @param server the server URI string * @return the changed link */ public static String replaceServerUri(String link, String server) { String serverUriStr = server; if (CmsStringUtil.isEmptyOrWhitespaceOnly(serverUriStr)) { return link; } try { URI serverUri = new URI(serverUriStr); URI linkUri = new URI(link); URI result = new URI(serverUri.getScheme(), serverUri.getAuthority(), linkUri.getPath(), linkUri.getQuery(), linkUri.getFragment()); return result.toString(); } catch (URISyntaxException e) { LOG.error(e.getLocalizedMessage(), e); return link; } }
From source file:org.wso2.carbon.attachment.mgt.core.dao.impl.jpa.hibernate.AttachmentMgtDAOTransformerFactoryImpl.java
@Override public Attachment convertAttachment(AttachmentDAO attachment) throws AttachmentMgtException { Attachment attachmentDTO = null;/*from w w w. ja v a2 s .co m*/ try { attachmentDTO = new AttachmentImpl(attachment); } catch (URISyntaxException e) { log.error(e.getLocalizedMessage(), e); throw new AttachmentMgtException("Object conversion failed due to reason : " + e.getLocalizedMessage(), e); } return attachmentDTO; }
From source file:org.opencms.xml.containerpage.CmsHtmlRedirectHandler.java
/** * @see org.opencms.xml.content.CmsDefaultXmlContentHandler#prepareForWrite(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, org.opencms.file.CmsFile) *///from w w w . j a v a2 s . c o m @Override public CmsFile prepareForWrite(CmsObject cms, CmsXmlContent content, CmsFile file) throws CmsException { CmsFile result = super.prepareForWrite(cms, content, file); try { String linkStr = getStringValue(cms, content, "Link"); String typeStr = getStringValue(cms, content, "Type"); if ("sublevel".equals(typeStr)) { Locale locale = OpenCms.getLocaleManager().getDefaultLocale(cms, file); String title = org.opencms.xml.containerpage.Messages.get().getBundle(locale) .key(org.opencms.xml.containerpage.Messages.GUI_REDIRECT_SUBLEVEL_TITLE_0); CmsProperty titleProp = new CmsProperty(CmsPropertyDefinition.PROPERTY_TITLE, title, null); cms.writePropertyObjects(file, Arrays.asList(titleProp)); } else if (!CmsStringUtil.isEmptyOrWhitespaceOnly(linkStr)) { boolean hasScheme = false; try { URI uri = new URI(linkStr); hasScheme = uri.getScheme() != null; } catch (URISyntaxException e) { LOG.debug(e.getLocalizedMessage(), e); } if (!hasScheme) { linkStr = cms.getRequestContext().removeSiteRoot(linkStr); } Locale locale = OpenCms.getLocaleManager().getDefaultLocale(cms, file); String title = org.opencms.xml.containerpage.Messages.get().getBundle(locale) .key(org.opencms.xml.containerpage.Messages.GUI_REDIRECT_TITLE_1, linkStr); CmsProperty titleProp = new CmsProperty(CmsPropertyDefinition.PROPERTY_TITLE, title, null); cms.writePropertyObjects(file, Arrays.asList(titleProp)); } } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } return result; }
From source file:com.squid.kraken.v4.auth.ChangePasswordServlet.java
/** * Display the input screen./*w ww. j a v a2s .co m*/ * * @param request * @param response * @throws ServletException * @throws IOException */ private void show(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // execute the login request try { User user = getUser(request); request.setAttribute("user", user); request.setAttribute("access_token", request.getParameter("access_token")); } catch (ServerUnavailableException e1) { logger.error(e1.getLocalizedMessage()); request.setAttribute(KRAKEN_UNAVAILABLE, Boolean.TRUE); } catch (URISyntaxException e) { logger.error(e.getLocalizedMessage()); request.setAttribute(ERROR, Boolean.TRUE); } catch (ServiceException e) { WebServicesException wsException = e.getWsException(); String error; if (wsException == null) { error = AN_ERROR_OCCURRED; } else { error = wsException.getError(); } logger.error(error); request.setAttribute(ERROR, error); } catch (SSORedirectException e) { response.sendRedirect(e.getRedirectURL()); } RequestDispatcher rd = getServletContext().getRequestDispatcher("/password.jsp"); rd.forward(request, response); }
From source file:ca.phon.query.script.QueryScript.java
/** * Setup library folders for 'require'//from w ww . j ava2 s . c o m */ private void setupLibraryFolders() { final ClassLoader cl = PluginManager.getInstance(); Enumeration<URL> libUrls; try { libUrls = cl.getResources("ca/phon/query/script/"); while (libUrls.hasMoreElements()) { final URL url = libUrls.nextElement(); try { final URI uri = url.toURI(); super.addRequirePath(uri); } catch (URISyntaxException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } } } catch (IOException e1) { LOGGER.log(Level.SEVERE, e1.getLocalizedMessage(), e1); } super.addPackageImport("Packages.ca.phon.orthography"); super.addPackageImport("Packages.ca.phon.ipa"); super.addPackageImport("Packages.ca.phon.ipa.features"); super.addPackageImport("Packages.ca.phon.phonex"); super.addPackageImport("Packages.ca.phon.syllable"); super.addPackageImport("Packages.ca.phon.util"); super.addPackageImport("Packages.ca.phon.project"); super.addPackageImport("Packages.ca.phon.session"); super.addClassImport("Packages.org.apache.commons.lang3.StringUtils"); }
From source file:org.orekit.data.DataProvidersManagerTest.java
private String getPath(String resourceName) { try {/* w ww .ja va 2s .c o m*/ ClassLoader loader = DirectoryCrawlerTest.class.getClassLoader(); return loader.getResource(resourceName).toURI().getPath(); } catch (URISyntaxException e) { Assert.fail(e.getLocalizedMessage()); return null; } }
From source file:eu.esdihumboldt.hale.io.wfs.ui.describefeature.WFSDescribeFeatureSource.java
@Override protected void determineSource(URIFieldEditor sourceURL) { WFSDescribeFeatureConfig config = new WFSDescribeFeatureConfig(); WFSDescribeFeatureWizard wizard = new WFSDescribeFeatureWizard(config); HaleWizardDialog dialog = new HaleWizardDialog(Display.getCurrent().getActiveShell(), wizard); if (dialog.open() == WizardDialog.OK) { WFSDescribeFeatureConfig result = wizard.getConfiguration(); // create URL URIBuilder builder = new URIBuilder(result.getDescribeFeatureUri()); // add fixed parameters builder.addParameter("SERVICE", "WFS"); builder.addParameter("VERSION", result.getVersion().toString()); builder.addParameter("REQUEST", "DescribeFeatureType"); // specify type names if (!result.getTypeNames().isEmpty()) { KVPUtil.addTypeNameParameter(builder, result.getTypeNames(), result.getVersion()); }//ww w. j a va2 s. c o m try { sourceURL.setStringValue(builder.build().toASCIIString()); getPage().setErrorMessage(null); } catch (URISyntaxException e) { getPage().setErrorMessage(e.getLocalizedMessage()); } } }
From source file:org.kitodo.sruimport.SRUImport.java
@Override public Document getFullRecordById(String catalogId, String id) { loadOPACConfiguration(catalogId);/*from w w w. j ava 2 s. c o m*/ LinkedHashMap<String, String> queryParameters = new LinkedHashMap<>(parameters); try { URI queryURL = createQueryURI(queryParameters); return performQueryToDocument( queryURL.toString() + "&maximumRecords=1&query=" + idParameter + equalsOperand + id); } catch (URISyntaxException e) { throw new ConfigException(e.getLocalizedMessage()); } // TODO: transform hit to Kitodo internal format using SchemaConverter! }