package edu.usc.glidein.service.impl;

import java.rmi.RemoteException;

import org.apache.log4j.Logger;
import org.globus.wsrf.ResourceContext;
import org.globus.wsrf.ResourceKey;

import edu.usc.glidein.stubs.types.EmptyObject;
import edu.usc.glidein.stubs.types.Glidein;

public class GlideinService
{
	private Logger logger = Logger.getLogger(GlideinService.class);
	
	private GlideinResourceHome getResourceHome() throws RemoteException
	{
		try {
			Object resourceHome = ResourceContext.getResourceContext().getResourceHome();
			GlideinResourceHome glideinResourceHome = (GlideinResourceHome) resourceHome;
			return glideinResourceHome;
		} catch (Exception e) {
			String message = "Unable to find glidein resource home";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}
	}
	
	private GlideinResource getResource() throws RemoteException
	{
		try {
			Object resource = ResourceContext.getResourceContext().getResource();
			GlideinResource glideinResource = (GlideinResource) resource;
			return glideinResource;
		} catch (Exception e) {
			String message = "Unable to find glidein resource";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}
	}
	
	private ResourceKey getResourceKey() throws RemoteException 
	{
		try {
			return ResourceContext.getResourceContext().getResourceKey();
		} catch (Exception e) {
			String message = "Unable to find glidein resource key";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}
	}
	
	public Glidein getGlidein(EmptyObject empty) throws RemoteException
	{
		return getResource().getGlidein();
	}
	
	public EmptyObject submit(EmptyObject empty) throws RemoteException
	{
		getResource().submit();
		return new EmptyObject();
	}
	
	public EmptyObject remove(EmptyObject empty) throws RemoteException
	{
		getResourceHome().remove(getResourceKey());
		return new EmptyObject();
	}
}

@@ -141,44 +141,8 @@
 ext;
-%0Aimport org.globus.wsrf.ResourceKey;
 %0A%0Aim
@@ -333,447 +333,8 @@
 ;%0A%09%0A
-%09private GlideinResourceHome getResourceHome() throws RemoteException%0A%09%7B%0A%09%09try %7B%0A%09%09%09Object resourceHome = ResourceContext.getResourceContext().getResourceHome();%0A%09%09%09GlideinResourceHome glideinResourceHome = (GlideinResourceHome) resourceHome;%0A%09%09%09return glideinResourceHome;%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09String message = %22Unable to find glidein resource home%22;%0A%09%09%09logger.error(message,e);%0A%09%09%09throw new RemoteException(message, e);%0A%09%09%7D%0A%09%7D%0A%09%0A
 %09pri
@@ -731,310 +731,8 @@
 %7D%0A%09%0A
-%09private ResourceKey getResourceKey() throws RemoteException %0A%09%7B%0A%09%09try %7B%0A%09%09%09return ResourceContext.getResourceContext().getResourceKey();%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09String message = %22Unable to find glidein resource key%22;%0A%09%09%09logger.error(message,e);%0A%09%09%09throw new RemoteException(message, e);%0A%09%09%7D%0A%09%7D%0A%09%0A
 %09pub
@@ -999,33 +999,29 @@
  remove(
-EmptyObject empty
+boolean force
 ) throws
@@ -1057,12 +1057,8 @@
 urce
-Home
 ().r
@@ -1067,24 +1067,13 @@
 ove(
-getResourceKey()
+force
 );%0A%09

Update remove Add force flag Remove unused methods