List of usage examples for java.lang IllegalArgumentException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.apache.hadoop.yarn.applications.distributedshell.DshellClient.java
/** * @param args Command line arguments/* w ww. j a v a2 s. c o m*/ */ public static void main(String[] args) { boolean result = false; try { DshellClient client = new DshellClient(); LOG.info("Initializing Client"); try { boolean doRun = client.init(args); if (!doRun) { System.exit(0); } } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); client.printUsage(); System.exit(-1); } result = client.run(); } catch (Throwable t) { LOG.fatal("Error running Client", t); System.exit(1); } if (result) { LOG.info("Application completed successfully"); System.exit(0); } LOG.error("Application failed to complete successfully"); System.exit(2); }
From source file:org.apache.hadoop.yarn.applications.ivic.Client.java
/** * @param args Command line arguments //from w w w .j ava 2 s .co m */ public static void main(String[] args) { boolean result = false; try { Client client = new Client(); LOG.info("Initializing Client"); try { boolean doRun = client.init(args);//??? if (!doRun) { System.exit(0); } } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); client.printUsage(); System.exit(-1); } result = client.run(); } catch (Throwable t) { LOG.fatal("Error running Client", t); System.exit(1); } if (result) { LOG.info("Application completed successfully"); System.exit(0); } LOG.error("Application failed to complete successfully"); System.exit(2); }
From source file:org.ajax4jsf.resource.util.URLToStreamHelper.java
/** * Returns {@link InputStream} corresponding to argument {@link URL} * but with caching disabled//from w ww . j a v a 2 s . co m * * @param url {@link URL} of the resource * @return {@link InputStream} instance or <code>null</code> * @throws IOException */ public static final InputStream urlToStream(URL url) throws IOException { if (url != null) { URLConnection connection = url.openConnection(); try { connection.setUseCaches(false); } catch (IllegalArgumentException e) { log.error(e.getLocalizedMessage(), e); } return connection.getInputStream(); } else { return null; } }
From source file:org.kitodo.sruimport.SRUImport.java
private static void loadOPACConfiguration(String opacName) { try {//www.j a va 2 s .co m // XML configuration of OPAC HierarchicalConfiguration opacConfig = OPACConfig.getOPACConfiguration(opacName); for (HierarchicalConfiguration queryConfigParam : opacConfig.configurationsAt(PARAM_TAG)) { if (queryConfigParam.getString(NAME_ATTRIBUTE).equals(SCHEME_CONFIG)) { protocol = queryConfigParam.getString(VALUE_ATTRIBUTE); } else if (queryConfigParam.getString(NAME_ATTRIBUTE).equals(HOST_CONFIG)) { host = queryConfigParam.getString(VALUE_ATTRIBUTE); } else if (queryConfigParam.getString(NAME_ATTRIBUTE).equals(PATH_CONFIG)) { path = queryConfigParam.getString(VALUE_ATTRIBUTE); } } idParameter = OPACConfig.getIdentifierParameter(opacName); HierarchicalConfiguration searchFields = OPACConfig.getSearchFields(opacName); for (HierarchicalConfiguration searchField : searchFields.configurationsAt(SEARCHFIELD_TAG)) { searchFieldMapping.put(searchField.getString(LABEL_ATTRIBUTE), searchField.getString(VALUE_ATTRIBUTE)); } HierarchicalConfiguration urlParameters = OPACConfig.getUrlParameters(opacName); for (HierarchicalConfiguration queryParam : urlParameters.configurationsAt(PARAM_TAG)) { parameters.put(queryParam.getString(NAME_ATTRIBUTE), queryParam.getString(VALUE_ATTRIBUTE)); } } catch (IllegalArgumentException e) { logger.error(e.getLocalizedMessage()); } }
From source file:com.nextgis.maplibui.fragment.CompassFragment.java
public static String formatNumber(Object value, int max, int min) { NumberFormat f = NumberFormat.getInstance(); f.setMaximumFractionDigits(max);//from w w w .ja va 2 s . c o m f.setMinimumFractionDigits(min); f.setGroupingUsed(false); try { return f.format(value); } catch (IllegalArgumentException e) { return e.getLocalizedMessage(); } }
From source file:it.geosolutions.filesystemmonitor.neutral.monitorpolling.GBFileSystemMonitorJob.java
/** * Try to build the Observer using informations stored into the JobDataMap * /* ww w.j av a 2 s . co m*/ * @note this method is not sync * @param jdm * @return * @throws JobExecutionException */ private static FileAlterationObserver buildObserver(JobDataMap jdm) throws JobExecutionException { FileAlterationObserver observer = null; final GBEventNotifier notifier; // first time build try { final File directory = new File(jdm.getString(FileSystemMonitorSPI.SOURCE_KEY)); observer = new FileAlterationObserver(directory, new WildcardFileFilter(jdm.getString(FileSystemMonitorSPI.WILDCARD_KEY))); notifier = (GBEventNotifier) jdm.get(EVENT_NOTIFIER_KEY); final FileAlterationListener fal = new GBFileAlterationListener(notifier); observer.addListener(fal); } catch (ClassCastException cce) { // ClassCastException - if the identified object is not a String. throw exceptionPolicy(ExcPolicy.IMMEDIATELY, "The identified object is not a String.\n" + cce.getLocalizedMessage(), cce); } catch (NullPointerException npe) { // NullPointerException - If the pathname argument is null throw exceptionPolicy(ExcPolicy.IMMEDIATELY, "The pathname argument is null.\n" + npe.getLocalizedMessage(), npe); } catch (IllegalArgumentException iae) { // IllegalArgumentException - if the pattern is null throw exceptionPolicy(ExcPolicy.IMMEDIATELY, "The pattern is null.\n" + iae.getLocalizedMessage(), iae); } catch (Throwable e) { throw exceptionPolicy(ExcPolicy.IMMEDIATELY, "Probably the consumer cannot start.\n" + e.getLocalizedMessage(), e); } try { observer.initialize(); } catch (Throwable t) { throw exceptionPolicy(ExcPolicy.IMMEDIATELY, "An error occurs.\n" + t.getLocalizedMessage(), t); } jdm.put(OBSERVER_KEY, observer); return observer; }
From source file:android.databinding.tool.store.LayoutFileParser.java
public static File urlToFile(URL url) throws MalformedURLException { try {/*from ww w. j a v a 2s . c o m*/ return new File(url.toURI()); } catch (IllegalArgumentException e) { MalformedURLException ex = new MalformedURLException(e.getLocalizedMessage()); ex.initCause(e); throw ex; } catch (URISyntaxException e) { return new File(url.getPath()); } }
From source file:com.epam.hadoop.nv.yarn.Client.java
/** * @param args/*from ww w . j a v a 2 s . c om*/ * Command line arguments */ public static void main(YarnUI ui, String[] args) { boolean result = false; try { Client client = new Client(); LOG.info("Initializing Client"); Logger.getLogger(Client.class.getName()).info("Initializing Client"); try { boolean doRun = client.init(args); if (!doRun) { ui.notifyNotStarted(); // callback here // System.exit(0); } } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); client.printUsage(); ui.notifyWrongInput(); // callback here // System.exit(-1); } Logger.getLogger(Client.class.getName()).info("Running client"); result = client.run(); } catch (Throwable t) { Logger.getLogger(Client.class.getName()).info("Error running client"); LOG.fatal("Error running CLient", t); ui.notifyError(); // System.exit(1); } if (result) { Logger.getLogger(Client.class.getName()).info("Completed"); LOG.info("Application completed successfully"); ui.notifyCompleted(); // System.exit(0); } Logger.getLogger(Client.class.getName()).info("Failed"); LOG.error("Application failed to complete successfully"); ui.notifyFailed(); // System.exit(2); }
From source file:com.ibm.soatf.component.osb.ServiceManager.java
public static boolean changeServiceStatus(String servicetype, boolean status, String serviceURI, String host, int port, String username, String password) throws FrameworkExecutionException { SessionManagementMBean sm = null;/* ww w . j av a 2s . c o m*/ JMXConnector conn = null; boolean result = true; String statusMsg = ""; try { conn = initConnection(host, port, username, password); MBeanServerConnection mbconn = conn.getMBeanServerConnection(); DomainRuntimeServiceMBean clusterService = (DomainRuntimeServiceMBean) MBeanServerInvocationHandler .newProxyInstance(mbconn, new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME)); sm = (SessionManagementMBean) clusterService.findService(SessionManagementMBean.NAME, SessionManagementMBean.TYPE, null); sm.createSession(SESSION_NAME); ALSBConfigurationMBean alsbSession = (ALSBConfigurationMBean) clusterService.findService( ALSBConfigurationMBean.NAME + "." + SESSION_NAME, ALSBConfigurationMBean.TYPE, null); if (servicetype.equals("ProxyService")) { Ref ref = constructRef("ProxyService", serviceURI); ProxyServiceConfigurationMBean proxyConfigMBean = (ProxyServiceConfigurationMBean) clusterService .findService(ProxyServiceConfigurationMBean.NAME + "." + SESSION_NAME, ProxyServiceConfigurationMBean.TYPE, null); if (status) { proxyConfigMBean.enableService(ref); statusMsg = "Enable the ProxyService : " + serviceURI; logger.info(statusMsg); } else { proxyConfigMBean.disableService(ref); statusMsg = "Disable the ProxyService : " + serviceURI; logger.info(statusMsg); } } else if (servicetype.equals("BusinessService")) { try { Ref ref = constructRef("BusinessService", serviceURI); BusinessServiceConfigurationMBean businessConfigMBean = (BusinessServiceConfigurationMBean) clusterService .findService(BusinessServiceConfigurationMBean.NAME + "." + SESSION_NAME, BusinessServiceConfigurationMBean.TYPE, null); if (status) { businessConfigMBean.enableService(ref); statusMsg = "Enable the BusinessService : " + serviceURI; logger.info(statusMsg); } else { businessConfigMBean.disableService(ref); statusMsg = "Disable the BusinessService : " + serviceURI; logger.info(statusMsg); } } catch (IllegalArgumentException ex) { logger.fatal(ExceptionUtils.getStackTrace(ex)); } } sm.activateSession(SESSION_NAME, statusMsg); conn.close(); } catch (Exception ex) { if (null != sm) { try { sm.discardSession(SESSION_NAME); } catch (Exception e) { logger.debug("Not able to discard the session. " + e.getLocalizedMessage()); throw new FrameworkExecutionException(e); } } result = false; logger.error("Error in MBean Server connection. " + ex.getLocalizedMessage()); ex.printStackTrace(); } finally { if (null != conn) { try { conn.close(); } catch (Exception e) { logger.debug("Not able to close the JMX connection. " + e.getLocalizedMessage()); throw new FrameworkExecutionException(e); } } } return result; }
From source file:org.hdl.tensorflow.yarn.util.ProcessRunner.java
public void run(String[] args) { boolean success = false; LOG.info("Initializing " + name); Options opts = initOptions(args);/*from w ww . j a v a 2 s .com*/ try { init(parseArgs(opts, args)); success = run(); } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); printUsage(opts); System.exit(-1); } catch (Throwable t) { LOG.fatal("Error running " + name, t); System.exit(1); } if (success) { System.exit(0); } else { LOG.error(name + " failed to complete successfully"); System.exit(2); } }