List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:com.jbsoft.farmtotable.FarmToTableActivity.java
public static JSONObject POST() { InputStream inputStream = null; String result = ""; if (NOFM) {//from w w w . java2 s .c o m try { HttpClient httpclient = new DefaultHttpClient(); HttpResponse httpResponse = httpclient.execute(new HttpPost(usdaurl)); inputStream = httpResponse.getEntity().getContent(); if (inputStream != null) { result = convertInputStreamToString(inputStream); usdajson = new JSONObject(result); } } catch (Exception e) { Log.d("InputStream", e.getLocalizedMessage()); } } if ((NOFS) || (NOVR) || (NOOR)) { try { HttpClient httpclient2 = new DefaultHttpClient(); HttpResponse httpResponse2 = httpclient2.execute(new HttpPost(gplaceurl)); inputStream = httpResponse2.getEntity().getContent(); { if ((NOFS) || (NOVR) || (NOOR)) { String result2 = convertInputStreamToString(inputStream); gplacesjson = new JSONObject(result2); } } } catch (Exception e) { Log.d("InputStream", e.getLocalizedMessage()); } } return gplacesjson; }
From source file:com.microsoft.tfs.client.common.ui.teamexplorer.helpers.WebAccessHelper.java
private static void showPage(final TFSTeamProjectCollection collection, final String projectName, final String serviceType, final GUID serviceIdentifier) { final URI uri; try {//from w ww. jav a 2 s . c o m final ServiceDefinition serviceDefinition = getServiceDefinition(collection, serviceType, serviceIdentifier); if (serviceDefinition == null) { final String format = Messages.getString("WebAccessHelper.ServiceNotSupportedFormat"); //$NON-NLS-1$ throw new NotSupportedException(MessageFormat.format(format, serviceType)); } final ServerDataProvider provider = collection.getServerDataProvider(); final AccessMapping accessMapping = provider .getAccessMapping(AccessMappingMonikers.PUBLIC_ACCESS_MAPPING); String uriText = provider.locationForAccessMapping(serviceDefinition, accessMapping, false); if (uriText.indexOf("/{projectName}") > 0) //$NON-NLS-1$ { if (projectName == null) { uriText = StringUtil.replace(uriText, "/{projectName}", ""); //$NON-NLS-1$ //$NON-NLS-2$ } else { uriText = StringUtil.replace(uriText, "{projectName}", projectName); //$NON-NLS-1$ } } try { uri = new URI(URIUtil.encodePathQuery(uriText)); } catch (final Exception e) { final String format = Messages.getString("WebAccessHelper.URIErrorFormat"); //$NON-NLS-1$ throw new TECoreException(MessageFormat.format(format, uriText), e); } } catch (final TECoreException e) { final String title = Messages.getString("WebAccessHelper.ErrorDialogTitle"); //$NON-NLS-1$ final String format = Messages.getString("WebAccessHelper.LauchWebAccessErrorFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(format, e.getLocalizedMessage()); log.error("Caught exception while creating a Web Access URL", e); //$NON-NLS-1$ MessageBoxHelpers.errorMessageBox(ShellUtils.getWorkbenchShell(), title, message); return; } showURI(uri); }
From source file:edu.du.penrose.systems.fedoraApp.util.FedoraAppUtil.java
/** * Get THE SINGLETON REMOTE TASK ingest administrator, THERE IS ONLY ONE, if it does not exist this function will create it.. * This is a method to get a fedora administrator using the settings in the program properties file (batchIngest.properites). * This is a different administrator then the one used for manual ingests * if System properties javax.net.ssl.trustStore or javax.net.ssl.trustStorePassword are not set, they are set * to "\\fedora\\client\\truststore" and "tomcat" respectively. * //from www .ja v a 2 s .c om * @return a loged in fedora aministrator * @throws FatalException */ public static Administrator getAdministratorUsingProgramProperiesFileCredentials() throws FatalException { try { if (administratorForRemoteTaskIngest == null) { if (System.getProperty("javax.net.ssl.trustStore") == null) { System.setProperty("javax.net.ssl.trustStore", "\\fedora\\client\\truststore"); // TBD } if (System.getProperty("javax.net.ssl.trustStorePassword") == null) { System.setProperty("javax.net.ssl.trustStorePassword", "tomcat"); // TBD } String host = ProgramProperties .getInstance(FedoraAppConstants.getServletContextListener().getProgramPropertiesURL()) .getProperty(FedoraAppConstants.FEDORA_HOST_PROPERTY); String port = ProgramProperties .getInstance(FedoraAppConstants.getServletContextListener().getProgramPropertiesURL()) .getProperty(FedoraAppConstants.FEDORA_PORT_PROPERTY); String userName = ProgramProperties .getInstance(FedoraAppConstants.getServletContextListener().getProgramPropertiesURL()) .getProperty(FedoraAppConstants.FEDORA_USER_PROPERTY); String pwd = ProgramProperties .getInstance(FedoraAppConstants.getServletContextListener().getProgramPropertiesURL()) .getProperty(FedoraAppConstants.FEDORA_PWD_PROPERTY); administratorForRemoteTaskIngest = new Administrator("http", Integer.parseInt(port), host, userName, pwd); } } catch (Exception e) { throw new FatalException("Unable to get Fedora Administrator using batchIngest.properites credentials:" + e.getLocalizedMessage()); } return administratorForRemoteTaskIngest; }
From source file:com.almende.eve.rpc.jsonrpc.JSONRPC.java
/** * Validate whether the given class contains valid JSON-RPC methods. A class * if valid when:<br>//from w w w. j av a 2 s . com * - There are no public methods with equal names<br> * - The parameters of all public methods have the @Name annotation<br> * If the class is not valid, an Exception is thrown * * @param c * The class to be verified * @param requestParams * optional request parameters * @return errors A list with validation errors. When no problems are found, * an empty list is returned */ public static List<String> validate(final Class<?> c, final RequestParams requestParams) { final List<String> errors = new ArrayList<String>(); final Set<String> methodNames = new HashSet<String>(); AnnotatedClass ac = null; try { ac = AnnotationUtil.get(c); if (ac != null) { for (final AnnotatedMethod method : ac.getMethods()) { final boolean available = isAvailable(method, null, requestParams, null); if (available) { // The method name may only occur once final String name = method.getName(); if (methodNames.contains(name)) { errors.add("Public method '" + name + "' is defined more than once, which is not" + " allowed for JSON-RPC."); } methodNames.add(name); // TODO: I removed duplicate @Name check. If you reach // this point the function at least has named // parameters, due to the isAvailable() call. Should we // add a duplicates check to isAvailable()? } } } } catch (final Exception e) { LOG.log(Level.WARNING, "Problems wrapping class for annotation", e); errors.add("Class can't be wrapped for annotation, exception raised:" + e.getLocalizedMessage()); } return errors; }
From source file:com.evolveum.midpoint.gui.api.util.WebModelServiceUtils.java
public static boolean isEnableExperimentalFeature(Task task, ModelServiceLocator pageBase) { OperationResult result = task.getResult(); ModelInteractionService mInteractionService = pageBase.getModelInteractionService(); AdminGuiConfigurationType adminGuiConfig = null; try {//from ww w . j a va2s.c o m adminGuiConfig = mInteractionService.getAdminGuiConfiguration(task, result); result.recomputeStatus(); result.recordSuccessIfUnknown(); } catch (Exception e) { LoggingUtils.logException(LOGGER, "Cannot load admin gui config", e); result.recordPartialError("Cannot load admin gui config. Reason: " + e.getLocalizedMessage()); } if (adminGuiConfig == null) { return false; } return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures()); }
From source file:com.amalto.webapp.core.util.Util.java
/** * Returns a namespaced root element of a document Useful to create a namespace holder element * /*www . j a v a2s . com*/ * @return the root Element */ public static Element getRootElement(String elementName, String namespace, String prefix) throws Exception { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); DOMImplementation impl = builder.getDOMImplementation(); Document namespaceHolder = impl.createDocument(namespace, (prefix == null ? "" : prefix + ":") + elementName, null); //$NON-NLS-1$ //$NON-NLS-2$ Element rootNS = namespaceHolder.getDocumentElement(); rootNS.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, namespace); //$NON-NLS-1$ //$NON-NLS-2$ return rootNS; } catch (Exception e) { String err = "Error creating a namespace holder document: " + e.getLocalizedMessage(); //$NON-NLS-1$ throw new Exception(err); } }
From source file:com.aurel.track.util.emailHandling.MailReader.java
public synchronized static String verifyMailSetting(String protocol, String server, int securityConnection, int port, String user, String password) { LOGGER.debug(" Verify mail setting: " + protocol + ":" + server + ":" + port + "," + user + "..."); try {// w w w . j a v a 2s . co m // create session instance Properties props = System.getProperties(); updateSecurityProps(protocol, server, securityConnection, props); Session session = Session.getDefaultInstance(props, null); // instantiate POP3-store and connect to server store = session.getStore(protocol); store.connect(server, port, user, password); store.close(); } catch (Exception ex) { LOGGER.warn("Incoming e-mail settings don't work: " + protocol + ":" + server + ":" + port + ", user " + user + " - " + ex.getMessage()); if (LOGGER.isDebugEnabled()) { LOGGER.error(ExceptionUtils.getStackTrace(ex)); } return ex.getLocalizedMessage() == null ? ex.getClass().getName() : ex.getLocalizedMessage(); } LOGGER.debug("Mail setting: " + protocol + ":" + server + ":" + port + "," + user + " valid!"); return null; }
From source file:com.amalto.core.objects.DroppedItemPOJO.java
/** * recover dropped item//from w w w. java 2 s. c om */ public static ItemPOJOPK recover(DroppedItemPOJOPK droppedItemPOJOPK) throws XtentisException { // validate input if (droppedItemPOJOPK == null) { return null; } String partPath = droppedItemPOJOPK.getPartPath(); if (partPath == null || partPath.length() == 0) { return null; } if (!"/".equals(partPath)) { //$NON-NLS-1$ throw new IllegalArgumentException("Path '" + partPath + "' is not valid."); } ItemPOJOPK refItemPOJOPK = droppedItemPOJOPK.getRefItemPOJOPK(); String actionName = "recover"; //$NON-NLS-1$ // for recover we need to be admin, or have a role of admin, or role of write on instance rolesFilter(refItemPOJOPK, actionName, "w"); //$NON-NLS-1$ // get the universe and revision ID XmlServer server = Util.getXmlServerCtrlLocal(); try { // load dropped content String doc = server.getDocumentAsString(MDM_ITEMS_TRASH, droppedItemPOJOPK.getUniquePK(), null); if (doc == null) { return null; } // recover source item DroppedItemPOJO droppedItemPOJO = MarshallingFactory.getInstance() .getUnmarshaller(DroppedItemPOJO.class).unmarshal(new StringReader(doc)); String clusterName = refItemPOJOPK.getDataClusterPOJOPK().getUniqueId(); server.start(clusterName); try { server.putDocumentFromString(droppedItemPOJO.getProjection(), refItemPOJOPK.getUniqueID(), clusterName); server.commit(clusterName); } catch (Exception e) { server.rollback(clusterName); throw e; } //delete dropped item try { server.deleteDocument(MDM_ITEMS_TRASH, droppedItemPOJOPK.getUniquePK()); } catch (Exception e) { server.rollback(MDM_ITEMS_TRASH); throw e; } return refItemPOJOPK; } catch (Exception e) { String err = "Unable to " + actionName + " the dropped item " + droppedItemPOJOPK.getUniquePK() + ": " + e.getClass().getName() + ": " + e.getLocalizedMessage(); LOGGER.error(err, e); throw new XtentisException(err, e); } }
From source file:com.github.riccardove.easyjasub.EasyJaSubInputFromCommand.java
private static URL getUrl(String urlStr) throws EasyJaSubException { if (urlStr != null) { try {/*from w w w. j av a 2 s . c om*/ return new URL(urlStr); } catch (Exception ex) { throw new EasyJaSubException("Invalid URL: " + ex.getLocalizedMessage()); } } return null; }
From source file:MainClass.java
public MyCanvas() { try {//from www .j ava2 s .com InputStream in = getClass().getResourceAsStream("myExampleImage.jpg"); JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in); mImage = decoder.decodeAsBufferedImage(); in.close(); } catch (Exception e) { System.err.println(e.getLocalizedMessage()); } ImageIcon icon = new ImageIcon(mImage); add(new JLabel(icon)); }