agave-apps/apps-core/src/main/java/org/iplantc/service/apps/managers/ApplicationManager.java
/**
	 * Checks that the user has proper permissions on the underlying {@link ExecutionSystem}
	 * and the given {@link Software} object to submit a job. Existence of the {@link Software#getDeploymentPath()} 
	 * is also verified. If missing, and the app is disabled and notifications are thrown.
	 * 
	 * @param software the app for which to check avail and permissions
	 * @param username the user to check
	 * @return true if the app can be run, false otherwise
	 */
Checks that the user has proper permissions on the underlying  ExecutionSystem
and the given  Software object to submit a job. Existence of the  Software#getDeploymentPath()
is also verified. If missing, and the app is disabled and notifications are thrown.

@param software the app for which to check avail and permissions
@param username the user to check
@return true if the app can be run, false otherwise
Checks that the user has proper permissions on the underlying ExecutionSystem and the given Software object to submit a job . Existence of the Software#getDeploymentPath () is also verified . If missing and the app is disabled and notifications are thrown . @param software the app for which to check avail and permissions @param username the user to check @return true if the app can be run false otherwise
public static boolean isInvokableByUser(Software software, String username) 
	throws SoftwareException
	{
		if (software == null) {
			throw new SoftwareException("No shared app found matching that name");
		} 
		else {
			if (!software.isAvailable())
			{
				throw new SoftwareException("App is not available for execution");
			}
			else 
			{
				RemoteDataClient dataClient = null;
				try {
					dataClient = software.getStorageSystem().getRemoteDataClient();
					dataClient.authenticate();
					String wrapperPath = null;
					if (software.isPubliclyAvailable()) {
						wrapperPath = software.getDeploymentPath();
					} else {
						wrapperPath = software.getDeploymentPath() + '/' + software.getExecutablePath();
					}
					if (dataClient.doesExist(wrapperPath))
					{
						SoftwarePermissionManager pemManager = new SoftwarePermissionManager(software);
						return pemManager.canExecute(username) && 
								software.getExecutionSystem().getUserRole(username).canUse();
					} 
					else 
					{
						log.error("Disabling application " + 
								software.getUniqueName() + "(" + software.getId() + ") due to missing wrapper script." );
						software.setAvailable(false);
						SoftwareDao.persist(software);
						String message = "Unable to locate app templatePath at " + 
								software.getDeploymentPath() + "/" + software.getExecutablePath() +
								" on system " + software.getStorageSystem().getSystemId() + 
								". App is not available for execution and will be disabled.";
						SoftwareEventProcessor eventProcessor = new SoftwareEventProcessor();
						eventProcessor.processSoftwareContentEvent(software, 
								SoftwareEventType.DISABLED,
								message,
								username);
						throw new SoftwareException(message);
					}
				}
				catch (SoftwareException e) {
					throw e;
				}
				catch (RemoteDataException e) {
				    throw new SoftwareException("Unable to locate application assets on remote system. "
				            + "Remote server responded with: " + e.getMessage(), e);
				}
				catch (Exception e)
				{
					throw new SoftwareException("Unable to locate app " + software.getUniqueName() + " for invocation", e);
				}
				finally {
					try { if (dataClient != null) dataClient.disconnect(); } catch(Exception ignored) {}
                }
			}
		}
	}
public static boolean isInvokableByUser ( Software software , String username ) throws SoftwareException { if ( software == null ) { throw new SoftwareException ( "No shared app found matching that name" ) ; } else { if ( ! software . isAvailable ( ) ) { throw new SoftwareException ( "App is not available for execution" ) ; } else { RemoteDataClient dataClient = null ; try { dataClient = software . getStorageSystem ( ) . getRemoteDataClient ( ) ; dataClient . authenticate ( ) ; String wrapperPath = null ; if ( software . isPubliclyAvailable ( ) ) { wrapperPath = software . getDeploymentPath ( ) ; } else { wrapperPath = software . getDeploymentPath ( ) + '/' + software . getExecutablePath ( ) ; } if ( dataClient . doesExist ( wrapperPath ) ) { SoftwarePermissionManager pemManager = new SoftwarePermissionManager ( software ) ; return pemManager . canExecute ( username ) && software . getExecutionSystem ( ) . getUserRole ( username ) . canUse ( ) ; } else { log . error ( "Disabling application " + software . getUniqueName ( ) + "(" + software . getId ( ) + ") due to missing wrapper script." ) ; software . setAvailable ( false ) ; SoftwareDao . persist ( software ) ; String message = "Unable to locate app templatePath at " + software . getDeploymentPath ( ) + "/" + software . getExecutablePath ( ) + " on system " + software . getStorageSystem ( ) . getSystemId ( ) + ". App is not available for execution and will be disabled." ; SoftwareEventProcessor eventProcessor = new SoftwareEventProcessor ( ) ; eventProcessor . processSoftwareContentEvent ( software , SoftwareEventType . DISABLED , message , username ) ; throw new SoftwareException ( message ) ; } } catch ( SoftwareException e ) { throw e ; } catch ( RemoteDataException e ) { throw new SoftwareException ( "Unable to locate application assets on remote system. " + "Remote server responded with: " + e . getMessage ( ) , e ) ; } catch ( Exception e ) { throw new SoftwareException ( "Unable to locate app " + software . getUniqueName ( ) + " for invocation" , e ) ; } finally { try { if ( dataClient != null ) dataClient . disconnect ( ) ; } catch ( Exception ignored ) { } } } } }
Checks that the user has proper permissions on the underlying {@link ExecutionSystem}
 and the given {@link Software} object to submit a job.
Checks that the user has proper permissions on the underlying { @link ExecutionSystem } and the given { @link Software } object to submit a job .