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.Site;

public class SiteService 
{
	private Logger logger = Logger.getLogger(SiteService.class);
	
	private SiteResourceHome getResourceHome() throws RemoteException
	{
		try {
			return (SiteResourceHome)ResourceContext.getResourceContext().getResourceHome();
		} catch (Exception e) {
			String message = "Unable to find site resource home";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}	
	}
	
	private SiteResource getResource() throws RemoteException
	{
		try {
			return (SiteResource) ResourceContext.getResourceContext().getResource();
		} catch (Exception e) {
			String message = "Unable to find site resource";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}	
	}
	
	private ResourceKey getResourceKey() throws RemoteException
	{
		try {
			return (ResourceKey) ResourceContext.getResourceContext().getResourceKey();
		} catch (Exception e) {
			String message = "Unable to find site resource key";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}	
	}
	
	public Site getSite(EmptyObject empty) throws RemoteException {
		return getResource().getSite();
	}
	
	public EmptyObject delete(EmptyObject empty) throws RemoteException {
		getResource().delete();
		getResourceHome().remove(getResourceKey());
		return new EmptyObject();
	}
}
@@ -1358,25 +1358,26 @@
 oteException
- 
+%0A%09
 %7B%0A%09%09return g
@@ -1425,21 +1425,188 @@
 yObject 
-delet
+submit(EmptyObject empty) throws RemoteException%0A%09%7B%0A%09%09SiteResource resource = getResource();%0A%09%09resource.submit();%0A%09%09return new EmptyObject();%0A%09%7D%0A%09%0A%09public EmptyObject remov
 e(EmptyO
@@ -1644,36 +1644,130 @@
 tion
- 
+%0A%09
 %7B%0A%09%09
-getResource().delete();
+// Delete the resource from the databse%0A%09%09getResource().delete();%0A%09%09%0A%09%09// Remove the resource from the resource home
 %0A%09%09g
@@ -1809,16 +1809,19 @@
 Key());%0A
+%09%09%0A
 %09%09return

Add submit Change delete to remove