List of usage examples for java.lang IllegalAccessException getMessage
public String getMessage()
From source file:de.forsthaus.webui.security.user.MyUserSettingsCtrl.java
/** * Reset the selected object to its origin property values. * /*from www . ja v a 2s. com*/ * @throws InterruptedException * * @see doStoreInitValues() * */ public void doResetToInitValues() throws InterruptedException { if (getOriginalUser() != null) { try { setSelectedUser((SecUser) ZksampleBeanUtils.cloneBean(getOriginalUser())); // TODO Bug in DataBinder?? windowMyUserSettings.invalidate(); } catch (IllegalAccessException e) { ZksampleMessageUtils.showErrorMessage(e.getMessage()); } catch (InstantiationException e) { ZksampleMessageUtils.showErrorMessage(e.getMessage()); } catch (InvocationTargetException e) { ZksampleMessageUtils.showErrorMessage(e.getMessage()); } catch (NoSuchMethodException e) { ZksampleMessageUtils.showErrorMessage(e.getMessage()); } } }
From source file:com.ottogroup.bi.asap.repository.ComponentClassloader.java
/** * Looks up the reference {@link DataComponent}, instantiates it and passes over the provided {@link Properties} * @param name name of component to instantiate (required) * @param version version of component to instantiate (required) * @param properties properties to use for instantiation * @return/* www . j av a 2s . c o m*/ * @throws RequiredInputMissingException thrown in case a required parameter value is missing * @throws ComponentInstantiationFailedException thrown in case the instantiation failed for any reason * @throws UnknownComponentException thrown in case the name and version combination does not reference a managed component */ public Component newInstance(final String name, final String version, final Properties properties) throws RequiredInputMissingException, ComponentInstantiationFailedException, UnknownComponentException { ////////////////////////////////////////////////////////////////////////////////////////// // validate provided input if (StringUtils.isBlank(name)) { throw new RequiredInputMissingException("Missing required component name"); } if (StringUtils.isBlank(version)) { throw new RequiredInputMissingException("Missing required component version"); } // ////////////////////////////////////////////////////////////////////////////////////////// // generate component key and retrieve the associated descriptor ... if available String componentKey = getManagedComponentKey(name, version); ComponentDescriptor descriptor = this.managedComponents.get(componentKey); if (descriptor == null) throw new UnknownComponentException("Unknown component [name=" + name + ", version=" + version + "]"); // if the descriptor exists, load the referenced component class, create an instance and hand over the properties try { Class<?> messageHandlerClass = loadClass(descriptor.getComponentClass()); Component instance = (Component) messageHandlerClass.newInstance(); instance.init(properties); return instance; } catch (IllegalAccessException e) { throw new ComponentInstantiationFailedException("Failed to instantiate component [name=" + name + ", version=" + version + ", reason=" + e.getMessage()); } catch (InstantiationException e) { throw new ComponentInstantiationFailedException("Failed to instantiate component [name=" + name + ", version=" + version + ", reason=" + e.getMessage()); } catch (ClassNotFoundException e) { throw new ComponentInstantiationFailedException("Failed to instantiate component [name=" + name + ", version=" + version + ", reason=" + e.getMessage()); } }
From source file:com.cws.us.pws.ApplicationServiceBean.java
@Override public final String toString() { final String methodName = ApplicationServiceBean.CNAME + "#toString()"; if (DEBUG) {//from w w w . j av a 2s . c o m DEBUGGER.debug(methodName); } StringBuilder sBuilder = new StringBuilder() .append("[" + this.getClass().getName() + "]" + Constants.LINE_BREAK + "{" + Constants.LINE_BREAK); for (Field field : this.getClass().getDeclaredFields()) { if (DEBUG) { DEBUGGER.debug("field: {}", field); } if (!(field.getName().equals("methodName")) && (!(field.getName().equals("CNAME"))) && (!(field.getName().equals("DEBUGGER"))) && (!(field.getName().equals("DEBUG"))) && (!(field.getName().equals("ERROR_RECORDER"))) && (!(field.getName().equals("serialVersionUID")))) { try { if (field.get(this) != null) { sBuilder.append("\t" + field.getName() + " --> " + field.get(this) + Constants.LINE_BREAK); } } catch (IllegalAccessException iax) { ERROR_RECORDER.error(iax.getMessage(), iax); } } } sBuilder.append('}'); if (DEBUG) { DEBUGGER.debug("sBuilder: {}", sBuilder); } return sBuilder.toString(); }
From source file:org.fao.fenix.wds.web.rest.faostat.FAOSTATExporter.java
@POST @Path("/streamcsv") public Response streamCSV(final @FormParam("datasource_WQ_csv") String datasource, final @FormParam("json_WQ_csv") String json, final @FormParam("cssFilename_WQ_csv") String cssFilename, final @FormParam("valueIndex_WQ_csv") String valueIndex, final @FormParam("thousandSeparator_WQ_csv") String thousandSeparator, final @FormParam("decimalSeparator_WQ_csv") String decimalSeparator, final @FormParam("decimalNumbers_WQ_csv") String decimalNumbers, final @FormParam("quote_WQ_csv") String quote, final @FormParam("title_WQ_csv") String title, final @FormParam("subtitle_WQ_csv") String subtitle) { System.out.println("WE ARE IN LOCALHOST"); System.out.println(valueIndex); System.out.println(json);//from w w w . ja va2 s. co m // Initiate the stream StreamingOutput stream = new StreamingOutput() { @Override public void write(OutputStream os) throws IOException, WebApplicationException { // compute result Gson g = new Gson(); SQLBean sql = g.fromJson(json, SQLBean.class); System.out.println(sql.getQuery()); System.out.println(); DatasourceBean db = datasourcePool.getDatasource(datasource.toUpperCase()); Writer writer = new BufferedWriter(new OutputStreamWriter(os)); // compute result JDBCIterable it = new JDBCIterable(); try { // alter the query to switch from LIMIT to TOP if (datasource.toUpperCase().startsWith("FAOSTAT")) sql.setQuery(replaceLimitWithTop(sql)); System.out.println(Bean2SQL.convert(sql)); it.query(db, Bean2SQL.convert(sql).toString()); } catch (IllegalAccessException e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamCSV' thrown an error: " + e.getMessage())); } catch (InstantiationException e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamCSV' thrown an error: " + e.getMessage())); } catch (SQLException e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamCSV' thrown an error: " + e.getMessage())); } catch (ClassNotFoundException e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamCSV' thrown an error: " + e.getMessage())); } catch (Exception e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamCSV' thrown an error: " + e.getMessage())); } writer.write("\ufeff"); List<String> cols = it.getColumnNames(); for (int i = 0; i < cols.size(); i++) { writer.write(cols.get(i)); if (i < cols.size() - 1) writer.write(","); } writer.write("\n"); // write the result of the query while (it.hasNext()) { List<String> l = it.next(); for (int i = 0; i < l.size(); i++) { writer.write("\"" + l.get(i) + "\""); if (i < l.size() - 1) writer.write(","); } writer.write("\n"); } writer.write("\n"); writer.write(createMetadata()); writer.write("\n"); // Convert and write the output on the stream writer.flush(); writer.close(); } }; // Wrap result ResponseBuilder builder = Response.ok(stream); builder.header("Content-Disposition", "attachment; filename=" + UUID.randomUUID().toString() + ".csv"); // Stream Excel return builder.build(); }
From source file:org.kuali.coeus.common.budget.framework.query.QueryList.java
/** returns the field value in the base bean for the specified field. * @param fieldName fieldname whose value has to be got. * @param baseBean Bean containing the field. * @return value of the field.//w ww . j av a 2 s .c o m */ private Object getFieldValue(String fieldName, Object baseBean) { Field field = null; Method method = null; Class dataClass = baseBean.getClass(); Object value = null; try { field = dataClass.getDeclaredField(fieldName); if (!field.isAccessible()) { throw new NoSuchFieldException(); } } catch (NoSuchFieldException noSuchFieldException) { try { String methodName = "get" + (fieldName.charAt(0) + "").toUpperCase() + fieldName.substring(1); method = dataClass.getMethod(methodName, null); } catch (NoSuchMethodException noSuchMethodException) { LOG.error(noSuchMethodException.getMessage(), noSuchMethodException); } } try { if (field != null && field.isAccessible()) { value = field.get(baseBean); } else { value = method.invoke(baseBean, null); } } catch (IllegalAccessException illegalAccessException) { LOG.error(illegalAccessException.getMessage(), illegalAccessException); } catch (InvocationTargetException invocationTargetException) { LOG.error(invocationTargetException.getMessage(), invocationTargetException); } return value; }
From source file:org.fao.fenix.wds.web.rest.faostat.FAOSTATExporter.java
@POST @Path("/streamexcel") public Response streamExcel(final @FormParam("datasource_WQ") String datasource, final @FormParam("json_WQ") String json, final @FormParam("cssFilename_WQ") String cssFilename, final @FormParam("valueIndex_WQ") String valueIndex, final @FormParam("thousandSeparator_WQ") String thousandSeparator, final @FormParam("decimalSeparator_WQ") String decimalSeparator, final @FormParam("decimalNumbers_WQ") String decimalNumbers, final @FormParam("quote_WQ") String quote, final @FormParam("title_WQ") String title, final @FormParam("subtitle_WQ") String subtitle) { // Initiate the stream StreamingOutput stream = new StreamingOutput() { @Override//ww w .j ava 2s.co m public void write(OutputStream os) throws IOException, WebApplicationException { // compute result Gson g = new Gson(); SQLBean sql = g.fromJson(json, SQLBean.class); DatasourceBean db = datasourcePool.getDatasource(datasource.toUpperCase()); Writer writer = new BufferedWriter(new OutputStreamWriter(os)); // compute result JDBCIterable it = new JDBCIterable(); try { // alter the query to switch from LIMIT to TOP if (datasource.toUpperCase().startsWith("FAOSTAT")) sql.setQuery(replaceLimitWithTop(sql)); it.query(db, Bean2SQL.convert(sql).toString()); } catch (IllegalAccessException e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamExcel' thrown an error: " + e.getMessage())); } catch (InstantiationException e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamExcel' thrown an error: " + e.getMessage())); } catch (SQLException e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamExcel' thrown an error: " + e.getMessage())); } catch (ClassNotFoundException e) { e.printStackTrace(); WDSExceptionStreamWriter.streamException(os, ("Method 'streamExcel' thrown an error: " + e.getMessage())); } catch (Exception e) { WDSExceptionStreamWriter.streamException(os, ("Method 'getDomains' thrown an error: " + e.getMessage())); } writer.write("\ufeff"); writer.write("<table>"); // add column names List<String> cols = it.getColumnNames(); writer.write("<tr>"); for (int i = 0; i < cols.size(); i++) { writer.write("<td>"); writer.write(cols.get(i)); writer.write("</td>"); } writer.write("</tr>"); // write the result of the query while (it.hasNext()) { List<String> l = it.next(); writer.write("<tr>"); for (int i = 0; i < l.size(); i++) { writer.write("<td>"); writer.write(l.get(i)); writer.write("</td>"); } writer.write("</tr>"); } // add metadata writer.write("<tr><td> </td></tr>"); writer.write("<tr>"); writer.write("<td>"); writer.write(createMetadata()); writer.write("<td>"); writer.write("</tr>"); writer.write("</table>"); // Convert and write the output on the stream writer.flush(); writer.close(); } }; // Wrap result ResponseBuilder builder = Response.ok(stream); builder.header("Content-Disposition", "attachment; filename=" + UUID.randomUUID().toString() + ".xls"); // Stream Excel return builder.build(); }
From source file:org.ikasan.configurationService.service.ConfiguredResourceConfigurationService.java
/** * Retrieves the persisted configuration based on the configuredResource's configurationId and applies the persisted * configuration to the configuration of the configuredResource. This is typically called just prior to the flow * being started./*w w w . j a v a 2s.c o m*/ * * @param configuredResource */ /* * (non-Javadoc) * * @see org.ikasan.framework.configuration.service.ConfigurationService#configure(java.lang.Object) */ public void configure(ConfiguredResource configuredResource) { Configuration<List<ConfigurationParameter>> persistedConfiguration = this.staticConfigurationDao .findByConfigurationId(configuredResource.getConfiguredResourceId()); if (persistedConfiguration == null) { logger.warn("No persisted dao for configuredResource [" + configuredResource.getConfiguredResourceId() + "]. Default programmatic dao will be used."); return; } Object runtimeConfiguration = configuredResource.getConfiguration(); if (runtimeConfiguration != null) { try { for (ConfigurationParameter persistedConfigurationParameter : persistedConfiguration .getParameters()) { BeanUtils.setProperty(runtimeConfiguration, persistedConfigurationParameter.getName(), persistedConfigurationParameter.getValue()); } configuredResource.setConfiguration(runtimeConfiguration); } catch (IllegalAccessException e) { throw new ConfigurationException(e); } catch (InvocationTargetException e) { throw new ConfigurationException(e); } catch (RuntimeException e) { throw new ConfigurationException("Failed dao for configuredResource [" + configuredResource.getConfiguredResourceId() + "] " + e.getMessage(), e); } } else { logger.warn("Cannot configure configuredResource [" + configuredResource.getConfiguredResourceId() + "] as getConfiguration() returned 'null'"); } }
From source file:com.sm.query.QueryVisitorImpl.java
@Override public Result visitIDS(@NotNull QueryParser.IDSContext ctx) { //first is object, second is field Pair<Object, FieldInfo> pair = findObjectId(ctx.getText(), source, classInfoMap); idMap.put(ctx.getText(), pair.getSecond()); try {/*from w ww . j a v a 2s . c o m*/ if (pair.getFirst() == null) return new Result(null); else { Object object = pair.getSecond().getField().get(pair.getFirst()); return new Result(object); } } catch (IllegalAccessException e) { throw new ObjectIdException(e.getMessage(), e); } }
From source file:fr.dyade.aaa.util.MySqlDBRepository.java
/** * Initializes the repository./*from w ww . j av a2 s . c o m*/ * Opens the connection, evntually creates the database and tables. */ public void init(Transaction transaction, File dir) throws IOException { this.dir = dir; try { Class.forName(driver).newInstance(); // conn = DriverManager.getConnection(connurl + new File(dir, "JoramDB").getPath() + ";shutdown=true;server.no_system_exit=true", "sa", ""); Properties props = new Properties(); /* props.put("user", "user1"); props.put("password", "user1"); */ props.put("user", user); props.put("password", pass); /* conn = DriverManager.getConnection(connurl + new File(dir, "JoramDB").getPath() + ";create=true", props); */ // conn = DriverManager.getConnection(connurl, props); // MySQL (the database must exist and start seperately) conn = getConnection(); conn.setAutoCommit(false); } catch (IllegalAccessException exc) { throw new IOException(exc.getMessage()); } catch (ClassNotFoundException exc) { throw new IOException(exc.getMessage()); } catch (InstantiationException exc) { throw new IOException(exc.getMessage()); } catch (SQLException sqle) { throw new IOException(sqle.getMessage()); } try { // Creating a statement lets us issue commands against the connection. Statement s = conn.createStatement(); // We create the table. // s.execute("create cached table JoramDB(name VARCHAR PRIMARY KEY, content VARBINARY(256))"); /* s.execute("CREATE TABLE JoramDB (name VARCHAR(256), content LONG VARCHAR FOR BIT DATA, PRIMARY KEY(name))"); */ s.execute("CREATE TABLE JoramDB (name VARCHAR(256), content longblob, primary key(name))"); // MySQL s.close(); conn.commit(); } catch (SQLException sqle) { String exceptionString = sqle.toString(); if (exceptionString.indexOf("CREATE command denied") == -1) { sqle.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } try { insertStmt = conn.prepareStatement("INSERT INTO JoramDB VALUES (?, ?)"); updateStmt = conn.prepareStatement("UPDATE JoramDB SET content=? WHERE name=?"); deleteStmt = conn.prepareStatement("DELETE FROM JoramDB WHERE name=?"); } catch (SQLException sqle) { sqle.printStackTrace(); throw new IOException(sqle.getMessage()); } catch (Exception e) { e.printStackTrace(); // throw e; } }
From source file:com.google.gsa.valve.rootAuth.RootAuthenticationProcess.java
/** * Sets the Valve Configuration instance to read the parameters * from there/*from www. j a v a2 s. c o m*/ * * @param valveConf the Valve configuration instance */ public void setValveConfiguration(ValveConfiguration valveConf) { this.valveConf = valveConf; //Protection. Make sure the Map is empty before proceeding authenticationImplementations.clear(); //Authentication process instance AuthenticationProcessImpl authenticationProcess = null; String repositoryIds[] = valveConf.getRepositoryIds(); ValveRepositoryConfiguration repository = null; int order = 1; for (int i = 0; i < repositoryIds.length; i++) { try { repository = valveConf.getRepository(repositoryIds[i]); //Check if repository has to be included in the authentication process. By default set it to true boolean checkAuthN = true; try { if ((repository.getCheckAuthN() != null) && (!repository.getCheckAuthN().equals(""))) { checkAuthN = new Boolean(repository.getCheckAuthN()).booleanValue(); } } catch (Exception e) { logger.error("Error when reading checkAuthN param: " + e.getMessage(), e); //protection checkAuthN = true; } if (checkAuthN) { logger.info( "Initialising authentication process for " + repository.getId() + " [#" + order + "]"); authenticationProcess = (AuthenticationProcessImpl) Class.forName(repository.getAuthN()) .newInstance(); authenticationProcess.setValveConfiguration(valveConf); //add this authentication process to the Map synchronized (authenticationImplementations) { synchronized (authenticationImplementations) { authenticationImplementations.put(repository.getId(), authenticationProcess); authenticationImplementationsOrder.put(new Integer(order), repository.getId()); order++; } } } else { logger.debug("Authentication process for repository [" + repository.getId() + "] is not going to be launched"); } } catch (LinkageError le) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-LinkageError]: " + le.getMessage(), le); } catch (InstantiationException ie) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-InstantiationException]: " + ie.getMessage(), ie); } catch (IllegalAccessException iae) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-IllegalAccessException]: " + iae.getMessage(), iae); } catch (ClassNotFoundException cnfe) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-ClassNotFoundException]: " + cnfe.getMessage(), cnfe); } catch (Exception e) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-Exception]: " + e.getMessage(), e); } } logger.debug(RootAuthenticationProcess.class.getName() + " initialised"); }