agave-systems/systems-api/src/main/java/org/iplantc/service/systems/resources/BatchQueueManagementResource.java
/* 
	 * Deletes roles for a system. If no user is specified, it deletes all roles.
	 * Otherwise only the user roles are deleted.
	 */
Deletes roles for a system. If no user is specified, it deletes all roles.
Otherwise only the user roles are deleted.
Deletes roles for a system . If no user is specified it deletes all roles . Otherwise only the user roles are deleted .
@Override
	public void removeRepresentations() throws ResourceException
	{
		this.username = getAuthenticatedUsername();
		AgaveLogServiceClient.log(AgaveLogServiceClient.ServiceKeys.SYSTEMS02.name(), 
				AgaveLogServiceClient.ActivityKeys.SystemBatchQueueDelete.name(), 
				username, "", getRequest().getClientInfo().getUpstreamAddress());
		if (StringUtils.isEmpty(systemId))
        {
            throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                    "Invalid system id. Please specify an system using its system id.", 
					new SystemArgumentException());
        } 
        try
        {
        	RemoteSystem system = dao.findActiveAndInactiveSystemBySystemId(systemId);
            if (system == null)
            {
                throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND,
                        "No system found matching " + systemId, 
						new FileNotFoundException());
            }
            else if ( ! (system instanceof ExecutionSystem))
            {
                throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                        "Invalid system id. " + systemId + " is a storage system. "
                      + "Only execution systems have batch queues.", 
						new SystemArgumentException());
            }
            SystemManager systemManager = new SystemManager();
            if (systemManager.isVisibleByUser(system, username))
            {
                if (StringUtils.isEmpty(queueId) ) 
                {
                    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                            "Invalid system queue id. Please specify an system queue using its id. ", 
							new SystemArgumentException());
                } 
                else 
                {
                    BatchQueue batchQueue = batchQueueDao.findBySystemIdAndName(systemId, queueId);
                    batchQueueDao.delete(batchQueue);
				}	
				getResponse().setEntity(new IplantSuccessRepresentation());
			} 
			else 
			{
				throw new ResourceException(Status.CLIENT_ERROR_FORBIDDEN,
						"User does not have the necessary role to update this system queue",
						new PermissionException());
			}
		}
		catch (ResourceException e) {
			getResponse().setEntity(
					new IplantErrorRepresentation(e.getMessage()));
			getResponse().setStatus(e.getStatus());
		}
        catch (SystemException e) {
        	getResponse().setEntity(
					new IplantErrorRepresentation(e.getMessage()));
			getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
        }
		catch (Exception e)
		{
			getResponse().setEntity(
					new IplantErrorRepresentation("An unexpected error occurred removing the system queue. "
                            + "If this persists, please contact your system admin"));
			getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
		}
	}
@ Override public void removeRepresentations ( ) throws ResourceException { this . username = getAuthenticatedUsername ( ) ; AgaveLogServiceClient . log ( AgaveLogServiceClient . ServiceKeys . SYSTEMS02 . name ( ) , AgaveLogServiceClient . ActivityKeys . SystemBatchQueueDelete . name ( ) , username , "" , getRequest ( ) . getClientInfo ( ) . getUpstreamAddress ( ) ) ; if ( StringUtils . isEmpty ( systemId ) ) { throw new ResourceException ( Status . CLIENT_ERROR_BAD_REQUEST , "Invalid system id. Please specify an system using its system id." , new SystemArgumentException ( ) ) ; } try { RemoteSystem system = dao . findActiveAndInactiveSystemBySystemId ( systemId ) ; if ( system == null ) { throw new ResourceException ( Status . CLIENT_ERROR_NOT_FOUND , "No system found matching " + systemId , new FileNotFoundException ( ) ) ; } else if ( ! ( system instanceof ExecutionSystem ) ) { throw new ResourceException ( Status . CLIENT_ERROR_BAD_REQUEST , "Invalid system id. " + systemId + " is a storage system. " + "Only execution systems have batch queues." , new SystemArgumentException ( ) ) ; } SystemManager systemManager = new SystemManager ( ) ; if ( systemManager . isVisibleByUser ( system , username ) ) { if ( StringUtils . isEmpty ( queueId ) ) { throw new ResourceException ( Status . CLIENT_ERROR_BAD_REQUEST , "Invalid system queue id. Please specify an system queue using its id. " , new SystemArgumentException ( ) ) ; } else { BatchQueue batchQueue = batchQueueDao . findBySystemIdAndName ( systemId , queueId ) ; batchQueueDao . delete ( batchQueue ) ; } getResponse ( ) . setEntity ( new IplantSuccessRepresentation ( ) ) ; } else { throw new ResourceException ( Status . CLIENT_ERROR_FORBIDDEN , "User does not have the necessary role to update this system queue" , new PermissionException ( ) ) ; } } catch ( ResourceException e ) { getResponse ( ) . setEntity ( new IplantErrorRepresentation ( e . getMessage ( ) ) ) ; getResponse ( ) . setStatus ( e . getStatus ( ) ) ; } catch ( SystemException e ) { getResponse ( ) . setEntity ( new IplantErrorRepresentation ( e . getMessage ( ) ) ) ; getResponse ( ) . setStatus ( Status . CLIENT_ERROR_BAD_REQUEST ) ; } catch ( Exception e ) { getResponse ( ) . setEntity ( new IplantErrorRepresentation ( "An unexpected error occurred removing the system queue. " + "If this persists, please contact your system admin" ) ) ; getResponse ( ) . setStatus ( Status . SERVER_ERROR_INTERNAL ) ; } }
Deletes roles for a system.
Deletes roles for a system .
// add the owner 