<commit_before>package edu.usc.glidein.service.impl;

import java.net.URL;
import java.rmi.RemoteException;

import javax.naming.NamingException;

import org.apache.axis.MessageContext;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.apache.log4j.Logger;
import org.globus.wsrf.ResourceContext;
import org.globus.wsrf.ResourceException;
import org.globus.wsrf.ResourceKey;
import org.globus.wsrf.container.ServiceHost;
import org.globus.wsrf.utils.AddressingUtils;

import edu.usc.glidein.stubs.types.Glidein;
import edu.usc.glidein.stubs.types.GlideinState;
import edu.usc.glidein.stubs.types.Glideins;
import edu.usc.glidein.util.AddressingUtil;

public class GlideinFactoryService
{
	private Logger logger = Logger.getLogger(GlideinFactoryService.class);
	
	public GlideinFactoryService() { }	
	
	public EndpointReferenceType createGlidein(Glidein glidein)
	throws RemoteException
	{
		// Initialize glidein
		glidein.setState(GlideinState.NEW);
		glidein.setShortMessage("Created");
		
		// Get site or fail
		try {
			SiteResourceHome siteHome = SiteResourceHome.getInstance();
			siteHome.find(AddressingUtil.getSiteKey(glidein.getSiteId()));
		} catch(NamingException ne) {
			throw new ResourceException("Unable to locate site",ne);
		}
		
		// Create a new resource
		ResourceKey key = null;
		try {
			ResourceContext rctx = ResourceContext.getResourceContext();
			GlideinResourceHome home = (GlideinResourceHome) rctx.getResourceHome();
			key = home.create(glidein);
		} catch (Exception e) {
			String message = "Unable to create glidein resource";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}
		
		// Create an endpoint reference for the new resource
		EndpointReferenceType epr = null;
		try {
			URL baseURL = ServiceHost.getBaseURL();
			MessageContext mctx = MessageContext.getCurrentContext();
			String svc = (String) mctx.getService().getOption("instance");
			String instanceURI = baseURL.toString() + svc;
			epr = AddressingUtils.createEndpointReference(instanceURI, key);
		} catch (Exception e) {
			String message = "Unable to create endpoint reference";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}
		
		// Return the endpoint reference to the client
		return epr;
	}
	
	public Glideins listGlideins(boolean longFormat)
	throws RemoteException
	{
		try {
			ResourceContext rctx = ResourceContext.getResourceContext();
			GlideinResourceHome home = (GlideinResourceHome) rctx.getResourceHome();
			Glidein[] glideins = home.list(longFormat);
			return new Glideins(glideins);
		} catch (Exception e) {
			String message = "Unable to list sites";
			logger.error(message,e);
			throw new RemoteException(message, e);
		}
	}
}<commit_msg>Don't log client exceptions Move glidein initialization to GlideinResource<commit_after>package edu.usc.glidein.service.impl;

import java.net.URL;
import java.rmi.RemoteException;

import javax.naming.NamingException;

import org.apache.axis.MessageContext;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.globus.wsrf.ResourceContext;
import org.globus.wsrf.ResourceException;
import org.globus.wsrf.ResourceKey;
import org.globus.wsrf.container.ServiceHost;
import org.globus.wsrf.utils.AddressingUtils;

import edu.usc.glidein.stubs.types.Glidein;
import edu.usc.glidein.stubs.types.Glideins;
import edu.usc.glidein.util.AddressingUtil;

public class GlideinFactoryService
{
	public EndpointReferenceType createGlidein(Glidein glidein)
	throws RemoteException
	{
		// Get site or fail
		try {
			SiteResourceHome siteHome = SiteResourceHome.getInstance();
			siteHome.find(AddressingUtil.getSiteKey(glidein.getSiteId()));
		} catch(NamingException ne) {
			throw new ResourceException("Unable to locate site",ne);
		}
		
		// Get resource home
		GlideinResourceHome home = null;
		try {
			home = GlideinResourceHome.getInstance();
		} catch (NamingException e) {
			throw new ResourceException("Unable to get GlideinResourceHome", e);
		}
		
		// Create glidein
		ResourceKey key = home.create(glidein);
		
		// Create an endpoint reference for the new resource
		EndpointReferenceType epr = null;
		try {
			URL baseURL = ServiceHost.getBaseURL();
			MessageContext mctx = MessageContext.getCurrentContext();
			String svc = (String) mctx.getService().getOption("instance");
			String instanceURI = baseURL.toString() + svc;
			epr = AddressingUtils.createEndpointReference(instanceURI, key);
		} catch (Exception e) {
			throw new RemoteException("Unable to create endpoint reference", e);
		}
		
		// Return the endpoint reference to the client
		return epr;
	}
	
	public Glideins listGlideins(boolean longFormat)
	throws RemoteException
	{
		try {
			ResourceContext rctx = ResourceContext.getResourceContext();
			GlideinResourceHome home = (GlideinResourceHome) rctx.getResourceHome();
			Glidein[] glideins = home.list(longFormat);
			return new Glideins(glideins);
		} catch (Exception e) {
			throw new ResourceException("Unable to list sites", e);
		}
	}
}
{'fraction_non_alphanumeric': 0.09902951079421668, 'fraction_numerical': 0.00019805902158843335, 'mean_word_length': 4.791284403669724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3017516', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1547, 'n_words': 352}