From: <luk...@us...> - 2007-04-26 06:38:12
|
Revision: 728 http://svn.sourceforge.net/unicore/?rev=728&view=rev Author: lukichev Date: 2007-04-25 23:38:10 -0700 (Wed, 25 Apr 2007) Log Message: ----------- support for filesets in ExpertClient Modified Paths: -------------- unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/GlobalScope.java unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobImpl.java unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobManagementImpl.java unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowTargetSystemImpl.java Added Paths: ----------- unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobManagement.java Modified: unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/GlobalScope.java =================================================================== --- unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/GlobalScope.java 2007-04-26 06:33:04 UTC (rev 727) +++ unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/GlobalScope.java 2007-04-26 06:38:10 UTC (rev 728) @@ -39,6 +39,10 @@ import java.util.logging.Level; import java.util.logging.Logger; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; import org.w3c.dom.Document; @@ -62,11 +66,22 @@ public GlobalScope() { super(); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + + try { + documentBuilder = dbf.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + logger.log(Level.SEVERE, "Cannot create document builder", e); + } } private List<Element> variables = new Vector<Element>(); private Map<String,Map<String,Element>> name2parts = new HashMap<String,Map<String,Element>>(); + private DocumentBuilder documentBuilder; + /** * Add a new variable patr to the scope. * @param name - the name of the variable @@ -76,13 +91,13 @@ public synchronized void add(String name, String part, Element variable) { variables.add(variable); if (!name2parts.containsKey(name)) { - Map<String,Element> part2object = new HashMap<String,Element>(); - part2object.put(part, variable); + Map<String,Element> part2object = new HashMap<String,Element>(); + part2object.put(part, (Element)documentBuilder.newDocument().importNode(variable, true)); name2parts.put(name, part2object); } else { Map<String,Element> part2index = name2parts.get(name); if (!part2index.containsKey(part)) { - part2index.put(part, variable); + part2index.put(part, (Element)documentBuilder.newDocument().importNode(variable, true)); } } } @@ -185,8 +200,14 @@ variable.appendChild(variable.getOwnerDocument().importNode(value, true)); } catch (NoSuchDataException e) { Document doc; - doc = XmlObject.Factory.newDomImplementation().createDocument("http://gpe.intel.com/workflow", "Variable", null); - Element variable = doc.getDocumentElement(); + //doc = XmlObject.Factory.newDomImplementation().createDocument("http://gpe.intel.com/workflow", "Variable", null); + + doc = documentBuilder.newDocument(); + + //Element variable = doc.getDocumentElement(); + Element variable = doc.createElementNS("http://gpe.intel.com/workflow", "Variable"); + doc.appendChild(variable); + String _name = name!=null?name:""; String _part = part!=null?part:""; variable.setAttribute("name", _name); Modified: unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobImpl.java =================================================================== --- unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobImpl.java 2007-04-26 06:33:04 UTC (rev 727) +++ unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobImpl.java 2007-04-26 06:38:10 UTC (rev 728) @@ -39,6 +39,7 @@ import org.apache.xmlbeans.XmlObject; import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType; +import org.unigrids.x2006.x04.services.jms.OriginalJSDLDocument; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -185,9 +186,9 @@ * Get the original JSDL doc * @return the original JSDL doc */ - public JobDefinitionDocument getOriginalJSDL() { - JobDefinitionDocument doc = JobDefinitionDocument.Factory.newInstance(); - doc.setJobDefinition(value); + public OriginalJSDLDocument getOriginalJSDL() { + OriginalJSDLDocument doc = OriginalJSDLDocument.Factory.newInstance(); + doc.setOriginalJSDL(value); return doc; } Added: unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobManagement.java =================================================================== --- unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobManagement.java (rev 0) +++ unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobManagement.java 2007-04-26 06:38:10 UTC (rev 728) @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2000-2005, Intel Corporation All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.intel.gpe.services.uas.workflow; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.xml.namespace.QName; + +import com.intel.gpe.services.wes.ListDirectoryDocument; +import com.intel.gpe.services.wes.ListDirectoryResponseDocument; + +import de.fzj.unicore.uas.JobManagement; +import de.fzj.unicore.wsrflite.xmlbeans.BaseFault; + +@WebService(targetNamespace = "http://gpe.intel.com/services/wes") +public interface WorkflowJobManagement extends JobManagement { + + //Namespace + public static final String WJMS_NS="http://gpe.intel.com/services/wes"; + + //Porttype + public static final QName JMS_PORT=new QName(WJMS_NS,"WorkflowJobManagement"); + + @WebMethod(action = "http://gpe.intel.com/services/wes/WorkflowJobManagement/ListDirectory") + public ListDirectoryResponseDocument ListDirectory( + ListDirectoryDocument in) + throws BaseFault; + + +} Modified: unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobManagementImpl.java =================================================================== --- unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobManagementImpl.java 2007-04-26 06:33:04 UTC (rev 727) +++ unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowJobManagementImpl.java 2007-04-26 06:38:10 UTC (rev 728) @@ -33,6 +33,7 @@ import java.io.Serializable; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.List; import java.util.Map; @@ -40,16 +41,21 @@ import java.util.logging.Level; import java.util.logging.Logger; +import javax.wsdl.WSDLException; import javax.xml.namespace.QName; import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType; +import org.unigrids.services.atomic.types.GridFileDocument; +import org.unigrids.services.atomic.types.GridFileType; +import org.unigrids.services.atomic.types.PermissionsType; import org.unigrids.services.atomic.types.StorageReferenceType; import org.unigrids.services.atomic.types.StorageTypeEnumeration; import org.unigrids.x2006.x04.services.jms.AbortDocument; import org.unigrids.x2006.x04.services.jms.AbortResponseDocument; import org.unigrids.x2006.x04.services.jms.HoldDocument; import org.unigrids.x2006.x04.services.jms.HoldResponseDocument; +import org.unigrids.x2006.x04.services.jms.JobPropertiesDocument; import org.unigrids.x2006.x04.services.jms.ResumeDocument; import org.unigrids.x2006.x04.services.jms.ResumeResponseDocument; import org.unigrids.x2006.x04.services.jms.StartDocument; @@ -60,8 +66,14 @@ import schema.UnigridsSchemaAnchor; +import com.intel.gpe.clients.api.GridFile; import com.intel.gpe.clients.api.JobClient; import com.intel.gpe.clients.api.TargetSystemClient; +import com.intel.gpe.clients.api.exceptions.GPEDirectoryNotListedException; +import com.intel.gpe.clients.api.exceptions.GPEMiddlewareRemoteException; +import com.intel.gpe.clients.api.exceptions.GPEMiddlewareServiceException; +import com.intel.gpe.clients.api.exceptions.GPEResourceUnknownException; +import com.intel.gpe.clients.api.exceptions.GPESecurityException; import com.intel.gpe.clients.gpe.DefaultProperties; import com.intel.gpe.clients.impl.HandlerProvider; import com.intel.gpe.clients.impl.SecurityProvider; @@ -71,16 +83,22 @@ import com.intel.gpe.clients.impl.sms.StorageClientImpl; import com.intel.gpe.clients.impl.tss.TargetSystemClientImpl; import com.intel.gpe.services.jms.workflow.IWSDLProvider; +import com.intel.gpe.services.wes.ListDirectoryDocument; +import com.intel.gpe.services.wes.ListDirectoryResponseDocument; +import com.intel.gpe.services.wes.ListDirectoryDocument.ListDirectory; +import com.intel.gpe.util.filesets.FilePathUtils; import com.intel.gpe.wsclient.Handler; import com.intel.gpe.wsclient.transport.Transport; -import de.fzj.unicore.uas.JobManagement; import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.faults.JobNotStartedFault; +import de.fzj.unicore.uas.impl.UASWSResourceImpl; +import de.fzj.unicore.uas.impl.bp.BPSupportImpl; import de.fzj.unicore.uas.impl.job.JobManagementImpl; import de.fzj.unicore.uas.impl.job.rp.TSSReferenceResourceProperty; import de.fzj.unicore.uas.impl.job.rp.WorkingDirResourceProperty; import de.fzj.unicore.uas.impl.tss.rp.StorageReferenceResourceProperty; +import de.fzj.unicore.uas.security.UGSSecurityInHandler; import de.fzj.unicore.uas.security.Unicore5Tokens; import de.fzj.unicore.wsrflite.messaging.Message; import de.fzj.unicore.wsrflite.messaging.MessagingImpl; @@ -95,7 +113,7 @@ * @version $Id: WorkflowJobManagementImpl.java,v 1.3 2006/12/18 13:15:55 lukichev Exp $ * */ -public class WorkflowJobManagementImpl extends WSResourceImpl implements JobManagement { +public class WorkflowJobManagementImpl extends UASWSResourceImpl implements WorkflowJobManagement { protected static final long serialVersionUID=12347L; protected static Logger logger=Logger.getLogger(WorkflowJobManagementImpl.class.getName()); @@ -103,6 +121,10 @@ public static final String SECURITY_TOKEN = "uas.gpe.jobmanagement.security_token"; public static final String SPOOL_STORAGE_TARGET_SYSTEM = "uas.gpe.jobmanagement.spool_target_system"; + //Unicore/GS compatibility TODO + public static final String JMS_URI_UNICOREGS = "http://unigrids.org/2006/04/services/jms"; + public static final String UGS_OUTCOME = "outcome/"; + public static final QName Variable = new QName("http://gpe.intel.com/workflow", "Variable"); @@ -129,7 +151,7 @@ public AbortResponseDocument Abort(AbortDocument in) throws BaseFault { AbortResponseDocument res=AbortResponseDocument.Factory.newInstance(); try{ - res.addNewAbortResponse(); + res.addNewAbortResponse(); return res; }catch(Exception e){ logger.log(Level.WARNING,"Could not abort the job.",e); @@ -203,7 +225,7 @@ setUniqueID(UUID.randomUUID().toString()); }catch(Exception e){ - logger.log(Level.SEVERE,"Could not submit job the workflow engine.",e); + logger.log(Level.SEVERE,"Could not submit job to XNJS.",e); try{ super.destroy(); } @@ -398,11 +420,128 @@ return srp; } + public ListDirectoryResponseDocument ListDirectory(ListDirectoryDocument in) throws BaseFault { + + ListDirectory listDirectoryRequest = in.getListDirectory(); + + String baseDir = listDirectoryRequest.getPath(); + List<String> includes; + if (listDirectoryRequest.getIncludesArray() == null){ + includes = new ArrayList<String>(); + } else { + includes = Arrays.asList(listDirectoryRequest.getIncludesArray()); + } + List<String> excludes; + if (listDirectoryRequest.getExcludesArray() == null){ + excludes = new ArrayList<String>(); + } else { + excludes = Arrays.asList(listDirectoryRequest.getExcludesArray()); + } + boolean caseSensitive = listDirectoryRequest.getCaseSensitive(); + + Unicore5Tokens ugsTokens = (Unicore5Tokens) getSecurityContext().get(UGSSecurityInHandler.UGSToken); + + final GPEClientEngine clientEngine; + try { + clientEngine = new GPEClientEngine(ugsTokens.user, ugsTokens.endorser); + } catch (Exception e) { + logger.log(Level.SEVERE,"Could not create client engine.",e); + throw BaseFault.createFault(e.getMessage()); + } + + StorageClientImpl storageClient; + try { + storageClient = new StorageClientImpl( + new WSRFClientImpl( + listDirectoryRequest.getStorageEPR(), + new SecurityProvider() { + public Transport getTransport(URL url) { + return clientEngine.getTransport(url); + } + }, + new WSDLProviderImpl(), + new HandlerProvider() { + public List<Handler> getRequestHandlers() { + List<Handler> result = new ArrayList<Handler>(); + result.add(clientEngine.getSecurityHandler()); + return result; + } + public List<Handler> getResponseHandlers() { + List<Handler> result = new ArrayList<Handler>(); + return result; + } + + }, + new DefaultProperties()) + ); + } catch (WSDLException e) { + logger.log(Level.SEVERE,"Could not list remote directory.",e); + throw BaseFault.createFault(e.getMessage()); + } + + List<GridFileType> files; + try { + files = getFiles(storageClient, baseDir, baseDir, includes, excludes, caseSensitive); + } + catch (Exception e) { + logger.log(Level.SEVERE,"Could not list remote directory.",e); + throw BaseFault.createFault(e.getMessage()); + } + + ListDirectoryResponseDocument response = ListDirectoryResponseDocument.Factory.newInstance(); + response.addNewListDirectoryResponse().setGridFileArray(files.toArray(new GridFileType[files.size()])); + return response; + + } + + private List<GridFileType> getFiles(StorageClientImpl storage, String root, String baseDir, List<String> includes, + List<String> excludes, boolean caseSensitive) throws GPESecurityException, GPEMiddlewareServiceException, + GPEResourceUnknownException, GPEDirectoryNotListedException, GPEMiddlewareRemoteException { + List<GridFileType> result = new ArrayList<GridFileType>(); + + List<GridFile> files = storage.listDirectory(root); + for (GridFile gridFile : files) { + if (gridFile.isDirectory()) { + result.addAll(getFiles(storage, gridFile.getPath(), baseDir, includes, excludes, caseSensitive)); + } + else if (FilePathUtils.satisfy(gridFile.getPath(), baseDir, includes, excludes, caseSensitive, "/")) { + GridFileType file = GridFileDocument.Factory.newInstance().addNewGridFile(); + file.setPath(gridFile.getPath()); + file.setIsDirectory(gridFile.isDirectory()); + file.setIsOwner(gridFile.isOwner()); + file.setLastModified(gridFile.lastModified()); + + PermissionsType pt = file.addNewPermissions(); + pt.setExecutable(gridFile.getPermissions().getExecutable()); + pt.setReadable(gridFile.getPermissions().getReadable()); + pt.setWritable(gridFile.getPermissions().getWritable()); + + file.setSize(gridFile.getSize().longValue()); + + result.add(file); + } + } + + return result; + } + + @Override public QName getResourcePropertyDocumentQName() { - return null; + return JobPropertiesDocument.type.getDocumentElementName(); } + + @Override + protected void addWSResourceInterfaces(BPSupportImpl baseProfile) { + super.addWSResourceInterfaces(baseProfile); + //TODO check QName for this + //baseProfile.addWSResourceInterface(...); + } + - - + @Override + public QName getPortType() { + return JMS_PORT; + } + } \ No newline at end of file Modified: unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowTargetSystemImpl.java =================================================================== --- unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowTargetSystemImpl.java 2007-04-26 06:33:04 UTC (rev 727) +++ unicorex/uas-gpe-workflow/trunk/src/main/java/com/intel/gpe/services/uas/workflow/WorkflowTargetSystemImpl.java 2007-04-26 06:38:10 UTC (rev 728) @@ -47,6 +47,7 @@ import org.unigrids.x2006.x04.services.tss.ApplicationResourceType; import org.unigrids.x2006.x04.services.tss.SubmitDocument; import org.unigrids.x2006.x04.services.tss.SubmitResponseDocument; +import org.unigrids.x2006.x04.services.tss.TargetSystemPropertiesDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; import de.fzj.unicore.uas.TargetSystem; @@ -92,16 +93,7 @@ //baseProfile.addWSResourceInterface(...); } - private QName ourQName=new QName("http://intel.com/services/workflow","WorkflowTargetSystem"); - - @Override - public QName getPortType() { - //TODO - return ourQName; - } - - - public SubmitResponseDocument Submit(SubmitDocument in) throws BaseFault { + public SubmitResponseDocument Submit(SubmitDocument in) throws BaseFault { logger.info("Entering submit..."); if(logger.isLoggable(Level.FINEST)){ logger.finest("submit: "+in.toString()); @@ -130,6 +122,7 @@ map.put(JobManagementImpl.INITPARAM_TSS_UNIQUEID, getUniqueID()); map.put(WorkflowJobManagementImpl.INITPARAM_WORKFLOW_JOB, new WorkflowJobImpl(in.getSubmit().getJobDefinition())); + Unicore5Tokens ugsTokens = (Unicore5Tokens) getSecurityContext().get(UGSSecurityInHandler.UGSToken); map.put(WorkflowJobManagementImpl.SECURITY_TOKEN, ugsTokens); map.put(WorkflowJobManagementImpl.SPOOL_STORAGE_TARGET_SYSTEM, spoolTargetSystemURL); @@ -300,11 +293,14 @@ return super.getResourcePropertyObject(arg0); } - //TODO is there an RP document for this service? - @Override + @Override public QName getResourcePropertyDocumentQName() { - return null; + return TargetSystemPropertiesDocument.type.getDocumentElementName(); } - + @Override + public QName getPortType() { + return TSS_PORT; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |