agave-systems/systems-api/src/main/java/org/iplantc/service/systems/resources/SystemManagementResource.java
/* 
	 * Handles delete operations on RemoteSystem objects. Deleting a system marks
	 * it as hidden in the database so we don't break references made by apps.
	 * There is currently no service endpoint to unhide and reactivate apps.
	 */
Handles delete operations on RemoteSystem objects. Deleting a system marks
it as hidden in the database so we don't break references made by apps.
There is currently no service endpoint to unhide and reactivate apps.
Handles delete operations on RemoteSystem objects . Deleting a system marks it as hidden in the database so we don ' t break references made by apps . There is currently no service endpoint to unhide and reactivate apps .
@Override
	public void removeRepresentations() throws ResourceException
	{
		AgaveLogServiceClient.log(AgaveLogServiceClient.ServiceKeys.SYSTEMS02.name(), 
				AgaveLogServiceClient.ActivityKeys.SystemsDelete.name(), 
				username, "", getRequest().getClientInfo().getUpstreamAddress());
		if (!ServiceUtils.isValid(systemId))
		{
			getResponse().setEntity(
					new IplantErrorRepresentation("Invalid system name. " +
							"Please specify an system using its system id."));
			getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
			return;
		} 
		try
		{
			RemoteSystem system = dao.findActiveAndInactiveSystemBySystemId(systemId);
			try {
				if (systemManager.isManageableByUser(system, username)) 
				{
					system.setAvailable(false);
					dao.persist(system);
					eventProcessor.processSystemUpdateEvent(system, SystemEventType.DELETED, username);
					getResponse().setEntity(new IplantSuccessRepresentation());
					getResponse().setStatus(Status.SUCCESS_OK);
				} 
				else {
					throw new SystemException("User does not have permission to delete this system");
				}
			} catch (SystemException e) {
				getResponse().setEntity(
						new IplantErrorRepresentation(e.getMessage()));
				getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
				return;
			}
			if ((system.isOwnedBy(username) && !system.isPubliclyAvailable()) || ServiceUtils.isAdmin(username)) {
			} else {
				getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN);
				getResponse().setEntity(new IplantErrorRepresentation(
						"User does not have permission to delete this system"));
			}
		}
		catch (HibernateException e)
		{
			log.error(e);
			getResponse().setEntity(
					new IplantErrorRepresentation("Internal error while deleting system."));
			getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
		}
		catch (Exception e)
		{
			log.error(e);
			getResponse().setEntity(
					new IplantErrorRepresentation("Unexpected error deleting system"));
			getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
		}
	}
@ Override public void removeRepresentations ( ) throws ResourceException { AgaveLogServiceClient . log ( AgaveLogServiceClient . ServiceKeys . SYSTEMS02 . name ( ) , AgaveLogServiceClient . ActivityKeys . SystemsDelete . name ( ) , username , "" , getRequest ( ) . getClientInfo ( ) . getUpstreamAddress ( ) ) ; if ( ! ServiceUtils . isValid ( systemId ) ) { getResponse ( ) . setEntity ( new IplantErrorRepresentation ( "Invalid system name. " + "Please specify an system using its system id." ) ) ; getResponse ( ) . setStatus ( Status . CLIENT_ERROR_BAD_REQUEST ) ; return ; } try { RemoteSystem system = dao . findActiveAndInactiveSystemBySystemId ( systemId ) ; try { if ( systemManager . isManageableByUser ( system , username ) ) { system . setAvailable ( false ) ; dao . persist ( system ) ; eventProcessor . processSystemUpdateEvent ( system , SystemEventType . DELETED , username ) ; getResponse ( ) . setEntity ( new IplantSuccessRepresentation ( ) ) ; getResponse ( ) . setStatus ( Status . SUCCESS_OK ) ; } else { throw new SystemException ( "User does not have permission to delete this system" ) ; } } catch ( SystemException e ) { getResponse ( ) . setEntity ( new IplantErrorRepresentation ( e . getMessage ( ) ) ) ; getResponse ( ) . setStatus ( Status . CLIENT_ERROR_UNAUTHORIZED ) ; return ; } if ( ( system . isOwnedBy ( username ) && ! system . isPubliclyAvailable ( ) ) || ServiceUtils . isAdmin ( username ) ) { } else { getResponse ( ) . setStatus ( Status . CLIENT_ERROR_FORBIDDEN ) ; getResponse ( ) . setEntity ( new IplantErrorRepresentation ( "User does not have permission to delete this system" ) ) ; } } catch ( HibernateException e ) { log . error ( e ) ; getResponse ( ) . setEntity ( new IplantErrorRepresentation ( "Internal error while deleting system." ) ) ; getResponse ( ) . setStatus ( Status . CLIENT_ERROR_BAD_REQUEST ) ; } catch ( Exception e ) { log . error ( e ) ; getResponse ( ) . setEntity ( new IplantErrorRepresentation ( "Unexpected error deleting system" ) ) ; getResponse ( ) . setStatus ( Status . SERVER_ERROR_INTERNAL ) ; } }
Handles delete operations on RemoteSystem objects.
Handles delete operations on RemoteSystem objects .
// we can't delete systems due to their associated app-dependencies, so we // hide them so we can keep accurate history and throw proper exception messages.  //					NotificationManager.process(system.getUuid(), "DELTED", username);