List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Returns the size value (in bytes) for the given resource identifier if * it exists; otherwise, throw a ResourceNotFoundException. * /*from w ww .jav a 2 s .co m*/ * @param resourceId the resource identifier * @param authToken the authorization token * @return the size value (in bytes) * @throws ClassNotFoundException * @throws SQLException * @throws UnauthorizedException * @throws ResourceNotFoundException * @throws Exception */ public Long readResourceSize(String resourceId, AuthToken authToken) throws ClassNotFoundException, SQLException, UnauthorizedException, ResourceNotFoundException, Exception { Long resourceSize = null; String user = authToken.getUserId(); try { DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); /* * Check whether user is authorized to read the data package report */ Authorizer authorizer = new Authorizer(dataPackageRegistry); boolean isAuthorized = authorizer.isAuthorized(authToken, resourceId, Rule.Permission.read); if (!isAuthorized) { String gripe = "User " + user + " does not have permission to read the size value for this resource: " + resourceId; throw new UnauthorizedException(gripe); } resourceSize = dataPackageRegistry.getResourceSize(resourceId); if (resourceSize == null) { String gripe = "A size value does not exist for this resource: " + resourceId; throw new ResourceNotFoundException(gripe); } } catch (ClassNotFoundException e) { logger.error(e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); } return resourceSize; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Returns the Digital Object Identifier for the given resource identifier if * it exists; otherwise, throw a ResourceNotFoundException. * //from w w w. j a v a2 s. c o m * @param resourceId the resource identifier * @param authToken the authorization token * @return the Digital Object Identifier (DOI) value * @throws ClassNotFoundException * @throws SQLException * @throws UnauthorizedException * @throws ResourceNotFoundException * @throws Exception */ public String readResourceDoi(String resourceId, AuthToken authToken) throws ClassNotFoundException, SQLException, UnauthorizedException, ResourceNotFoundException, Exception { String doi = null; String user = authToken.getUserId(); try { DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); /* * Check whether user is authorized to read the data package report */ Authorizer authorizer = new Authorizer(dataPackageRegistry); boolean isAuthorized = authorizer.isAuthorized(authToken, resourceId, Rule.Permission.read); if (!isAuthorized) { String gripe = "User " + user + " does not have permission to read the DOI for this resource: " + resourceId; throw new UnauthorizedException(gripe); } doi = dataPackageRegistry.getDoi(resourceId); if (doi == null) { String gripe = "A DOI does not exist for this resource: " + resourceId; throw new ResourceNotFoundException(gripe); } } catch (ClassNotFoundException e) { logger.error(e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); } return doi; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Returns the format type stored for the given resource identifier if * the resource exists; otherwise, throw a ResourceNotFoundException. * /*from ww w. j ava2 s .c o m*/ * @param resourceId the resource identifier * @param authToken the authorization token * @return the format type * @throws ClassNotFoundException * @throws SQLException * @throws UnauthorizedException * @throws ResourceNotFoundException * @throws Exception */ public String readResourceFormatType(String resourceId, AuthToken authToken) throws ClassNotFoundException, SQLException, UnauthorizedException, ResourceNotFoundException, Exception { String formatType = null; String user = authToken.getUserId(); try { DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); /* * Check whether user is authorized to read the resource */ Authorizer authorizer = new Authorizer(dataPackageRegistry); boolean isAuthorized = authorizer.isAuthorized(authToken, resourceId, Rule.Permission.read); if (!isAuthorized) { String gripe = String.format("User %s does not have permission to read this resource: %s", user, resourceId); throw new UnauthorizedException(gripe); } formatType = dataPackageRegistry.getFormatType(resourceId); if (formatType == null) { String gripe = String.format("A formatType does not exist for this resource: %s", resourceId); throw new ResourceNotFoundException(gripe); } } catch (ClassNotFoundException e) { logger.error(e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); throw (e); } return formatType; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Determines whether the user identified by the authentication token is * authorized to access the given resource identifier with the given * permission./* w ww .ja v a2 s . c o m*/ * * @param authToken * The user's authentication token. * @param resourceId * The resource identifier of the requested resource. * @param permission * The requested permission for accessing the resource (e.g., READ). * @return The boolean result of the request. * @throws IllegalArgumentException, UnauthorizedException */ public Boolean isAuthorized(AuthToken authToken, String resourceId, Rule.Permission permission) throws IllegalArgumentException, UnauthorizedException { Boolean isAuthorized = null; DataPackageRegistry dpr = null; String userId = authToken.getUserId(); if (resourceId == null || resourceId.isEmpty()) { String gripe = "ResourceId parameter is null or is empty!"; throw new IllegalArgumentException(gripe); } try { dpr = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); } catch (ClassNotFoundException e) { logger.error(e.getMessage()); e.printStackTrace(); } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); } Authorizer authorizer = new Authorizer(dpr); try { isAuthorized = authorizer.isAuthorized(authToken, resourceId, permission); if (!isAuthorized) { String gripe = "User \"" + userId + "\" is not authorized to " + permission + " this " + resourceId + " resource!"; throw new UnauthorizedException(gripe); } } catch (ClassNotFoundException e) { logger.error(e.getMessage()); e.printStackTrace(); } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); } return isAuthorized; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Returns the entity name for the given entity resource identifier if it * exists; otherwise, throw a ResourceNotFoundException. Authorization for * reading the entity name is based on access rules for the data package * resource, not on the access rules for the data entity resource. * /*from ww w. ja v a 2s . co m*/ * @param dataPackageResourceId * the data package resource identifier, used for authorization * purposes * @param entityResourceId * the entity resource identifier, used as the key to the entityName * value * @param authToken * the authentication token object * @return the data entity name string for this resource, if it exists * @throws ClassNotFoundException * @throws SQLException * @throws UnauthorizedException * @throws ResourceNotFoundException * @throws Exception */ public String readDataEntityName(String dataPackageResourceId, String entityResourceId, AuthToken authToken) throws ClassNotFoundException, SQLException, UnauthorizedException, ResourceNotFoundException, Exception { String entityName = null; String user = authToken.getUserId(); try { DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); /* * Check whether user is authorized to read the data entity. This is based * on the access rules specified for the data package, not on the access * rules specified for reading the data entity. */ Authorizer authorizer = new Authorizer(dataPackageRegistry); boolean isAuthorized = authorizer.isAuthorized(authToken, dataPackageResourceId, Rule.Permission.read); if (!isAuthorized) { String gripe = "User " + user + " does not have permission to read the entity name for this resource: " + entityResourceId; throw new UnauthorizedException(gripe); } entityName = dataPackageRegistry.getDataEntityName(entityResourceId); if (entityName == null) { String gripe = "An entityName value does not exist for this resource: " + entityResourceId; throw new ResourceNotFoundException(gripe); } } catch (ClassNotFoundException e) { logger.error(e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); } return entityName; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * For the specified data package, returns a newline-separated * list of strings, where each string contains an entity id followed by a * comma followed by the name of that entity. * /*from ww w . j av a 2s .c om*/ * @param scope * the scope value * @param identifier * the identifier value * @param revision * the revision value * @param authToken * the authorization token * @return a newline-separated list of strings, where each string contains an entity id followed by a * comma followed by the entity name. * @throws ClassNotFoundException * @throws SQLException * @throws UnauthorizedException * @throws ResourceNotFoundException * @throws Exception */ public String readDataEntityNames(String scope, Integer identifier, Integer revision, AuthToken authToken) throws ClassNotFoundException, SQLException, UnauthorizedException, ResourceNotFoundException, Exception { String entityNames = null; String packageId = String.format("%s.%d.%d", scope, identifier, revision); StringBuilder stringBuilder = new StringBuilder(""); try { DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); Authorizer authorizer = new Authorizer(dataPackageRegistry); entityNames = dataPackageRegistry.getEntityNames(scope, identifier, revision); if (entityNames == null) { String gripe = "No entity name values found for this data package: " + packageId; throw new ResourceNotFoundException(gripe); } else { String[] lines = entityNames.split("\n"); for (String line : lines) { if ((line != null) && (line.length() > 0)) { String[] keyValuePair = line.split(","); if (keyValuePair.length >= 2) { int firstCommaPosition = line.indexOf(','); String entityId = line.substring(0, firstCommaPosition); String entityName = line.substring(firstCommaPosition + 1); String resourceId = DataPackageManager.composeResourceId(ResourceType.data, scope, identifier, revision, entityId); boolean isAuthorized = authorizer.isAuthorized(authToken, resourceId, Rule.Permission.read); if (isAuthorized) { stringBuilder.append(String.format("%s,%s\n", entityId, entityName)); } } } } } } catch (ClassNotFoundException e) { logger.error(e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); } entityNames = stringBuilder.toString(); return entityNames; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * For the specified data package, returns a newline-separated * list of strings, where each string contains an entity id followed by a * comma followed by the size of that entity (in bytes). * Throws a ResourceNotFoundException if the specified data package does * not exist./*from w w w . j av a 2 s . co m*/ * * @param scope * the scope value * @param identifier * the identifier value * @param revision * the revision value * @param authToken * the authorization token * @return a newline-separated list of strings, where each string contains an entity id followed by a * comma followed by an integer representing the size (in bytes) of that entity. * @throws ClassNotFoundException * @throws SQLException * @throws UnauthorizedException * @throws ResourceNotFoundException * @throws Exception */ public String readEntitySizes(String scope, Integer identifier, Integer revision, AuthToken authToken) throws ClassNotFoundException, SQLException, UnauthorizedException, ResourceNotFoundException, Exception { String entitySizes = null; String packageId = String.format("%s.%d.%d", scope, identifier, revision); StringBuilder stringBuilder = new StringBuilder(""); String user = authToken.getUserId(); try { DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); Authorizer authorizer = new Authorizer(dataPackageRegistry); entitySizes = dataPackageRegistry.getEntitySizes(scope, identifier, revision); if (entitySizes == null) { String gripe = "No entity size values found for this data package: " + packageId; throw new ResourceNotFoundException(gripe); } else { String[] lines = entitySizes.split("\n"); for (String line : lines) { if ((line != null) && (line.length() > 0)) { String[] keyValuePair = line.split(","); if (keyValuePair.length == 2) { String entityId = keyValuePair[0]; String entitySize = keyValuePair[1]; String resourceId = DataPackageManager.composeResourceId(ResourceType.data, scope, identifier, revision, entityId); boolean isAuthorized = authorizer.isAuthorized(authToken, resourceId, Rule.Permission.read); if (isAuthorized) { stringBuilder.append(String.format("%s,%s\n", entityId, entitySize)); } } } } } } catch (ClassNotFoundException e) { logger.error(e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); throw (e); } entitySizes = stringBuilder.toString(); return entitySizes; }
From source file:gr.abiss.calipso.CalipsoServiceImpl.java
/** * @param history/*from w w w . j av a 2s .c om*/ * @param item */ public void runStateChangePlugins(History history, Item item, Integer state) { // assets to create based on Item info? AbstractItem abstractItem = history != null ? history : item; logger.info("RUNNING PLUGINS (" + state + "), item state: " + abstractItem.getSpace().getMetadata().getStatusValue(abstractItem.getStatus())); // run plugins Map<Integer, String> pluginsMap = abstractItem.getSpace().getMetadata().getStatesPluginMap(); if (abstractItem.getStatus() != null && MapUtils.isNotEmpty(pluginsMap)) { String pluginClassNames = pluginsMap.get(abstractItem.getStatus()); logger.info("pluginClassNames:" + pluginClassNames + ", status: " + (abstractItem != null ? abstractItem.getStatus() : null)); logger.info("Running plugins for status: " + abstractItem.getStatus() + ", plugins: " + pluginsMap.get(abstractItem.getStatus())); if (pluginClassNames != null && pluginClassNames.length() > 0) { String[] pluginNames = pluginClassNames.split(" "); for (int i = 0; i < pluginNames.length; i++) { String pluginClassName = pluginNames[i]; if (StringUtils.isNotBlank(pluginClassName)) { logger.debug("Loading plugin class: " + pluginClassName); // "clazz" is the class name to load Class clazz = null; try { clazz = Class.forName(pluginClassName); AbstractStatePlugin plugin = (AbstractStatePlugin) clazz.newInstance(); if (state.equals(AbstractStatePlugin.PRE_STATE_CHANGE)) { plugin.executePreStateChange(this, item); } else if (state.equals(AbstractStatePlugin.PRE_HISTORY_SAVE)) { plugin.executePreHistoryChange(this, history); } else if (state.equals(AbstractStatePlugin.POST_STATE_CHANGE)) { plugin.executePostStateChange(this, history); } } catch (ClassNotFoundException e) { logger.error("Cannot load State Plugin class: " + pluginClassName, e); e.printStackTrace(); } catch (InstantiationException ie) { logger.error("Cannot instantiate State Plugin class: " + pluginClassName, ie); ie.printStackTrace(); } catch (IllegalAccessException iae) { logger.error("Cannot load State Plugin class: " + pluginClassName, iae); iae.printStackTrace(); } } } } } }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Enables or disables mouse wheel support for the panel. Note that this method does nothing * when running JFreeChart on JRE 1.3.1, because that older version of the Java runtime does not * support mouse wheel events./* w w w .ja va2 s .c o m*/ * * @param flag * a boolean. * * @since 1.0.13 */ @Override public void setMouseWheelEnabled(boolean flag) { if (flag && this.mouseWheelHandler == null) { // use reflection to instantiate a mouseWheelHandler because to // continue supporting JRE 1.3.1 we cannot depend on the // MouseWheelListener interface directly try { Class<?> c = Class.forName("org.jfree.chart.MouseWheelHandler"); Constructor<?> cc = c.getConstructor(new Class[] { ChartPanel.class }); Object mwh = cc.newInstance(new Object[] { this }); this.mouseWheelHandler = mwh; } catch (ClassNotFoundException e) { // the class isn't there, so we must have compiled JFreeChart // with JDK 1.3.1 - thus, we can't have mouse wheel support } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } else if (!flag && this.mouseWheelHandler != null) { // use reflection to deregister the mouseWheelHandler try { Class<?> mwl = Class.forName("java.awt.event.MouseWheelListener"); Class<ChartPanel> c2 = ChartPanel.class; Method m = c2.getMethod("removeMouseWheelListener", new Class[] { mwl }); m.invoke(this, new Object[] { this.mouseWheelHandler }); this.mouseWheelHandler = null; } catch (ClassNotFoundException e) { // must be running on JRE 1.3.1, so just ignore this } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Reads a data entity and returns it as a byte array. The specified user must * be authorized to read the data entity resource. * /* www . j av a2 s .c om*/ * @param scope * The scope of the data package. * @param identifier * The identifier of the data package. * @param revision * The revision of the data package. * @param entityId * The entityId of the data package. * @param user * The user name * @return a File object containing the locally stored entity data */ public File getDataEntityFile(String scope, Integer identifier, String revision, String entityId, AuthToken authToken, String user) throws ClassNotFoundException, SQLException, ClientProtocolException, IOException, Exception { File file = null; boolean hasDataPackage = false; Integer revisionInt = new Integer(revision); String resourceId = composeResourceId(ResourceType.data, scope, identifier, revisionInt, entityId); try { DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); hasDataPackage = dataPackageRegistry.hasDataPackage(scope, identifier, revision); if (!hasDataPackage) { String message = "Attempting to read a data entity that does not exist in PASTA: " + resourceId; throw new ResourceNotFoundException(message); } /* * If we have the data package but it was previously deleted (i.e. * de-activated) * * Note: This logic is no longer valid as of Ticket #912: * https://trac.lternet.edu/trac/NIS/ticket/912 * boolean isDeactivatedDataPackage = dataPackageRegistry .isDeactivatedDataPackage(scope, identifier); if (isDeactivatedDataPackage) { String message = "Attempting to read a data entity that was previously deleted from PASTA: " + resourceId; throw new ResourceDeletedException(message); }*/ /* * Now that we know that the data package is in the registry, check * whether the user is authorized to read the data entity. */ Authorizer authorizer = new Authorizer(dataPackageRegistry); boolean isAuthorized = authorizer.isAuthorized(authToken, resourceId, Rule.Permission.read); if (!isAuthorized) { String message = "User " + user + " does not have permission to read this data entity: " + resourceId; throw new UnauthorizedException(message); } DataManagerClient dataManagerClient = new DataManagerClient(); String resourceLocation = dataPackageRegistry.getResourceLocation(resourceId); file = dataManagerClient.getDataEntityFile(resourceLocation, scope, identifier, revision, entityId); } catch (ClassNotFoundException e) { logger.error("Error connecting to Data Package Registry: " + e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error("Error connecting to Data Package Registry: " + e.getMessage()); e.printStackTrace(); throw (e); } return file; }