valia.tsagkalidou 2008-10-22 13:00:13 +00:00
parent 3e381d5793
commit 5b53903af0
2 changed files with 207 additions and 105 deletions

View File

@ -198,7 +198,7 @@ public class D4ScienceSession{
}
/**
* @param notification the name of the notification to send notifiaction
* @param notification the name of the notification to send notification
* @throws InterruptedException when the thread is interrupted
*/
public void notifyAllWaiting(String notification) throws InterruptedException

View File

@ -1,12 +1,15 @@
package org.gcube.application.framework.core.vremanagement.impl;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.application.framework.core.cache.HarvestersManager;
import org.gcube.application.framework.core.security.PortalSecurityManager;
import org.gcube.application.framework.core.session.D4ScienceSession;
import org.gcube.application.framework.core.vremanagement.VREGeneratorI;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.common.core.types.VOID;
import org.gcube.searchservice.searchlibrary.isharvester.ISInfo;
import org.gcube.vremanagement.vremodeler.stubs.CheckedRows;
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
import org.gcube.vremanagement.vremodeler.stubs.DHNArray;
@ -17,23 +20,22 @@ import org.gcube.vremanagement.vremodeler.stubs.SetMDFormatArgs;
import org.gcube.vremanagement.vremodeler.stubs.VdlRequest;
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerFactoryServiceAddressingLocator;
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerServiceAddressingLocator;
import org.globus.wsrf.encoding.DeserializationException;
import org.globus.wsrf.encoding.ObjectDeserializer;
import org.xml.sax.InputSource;
import java.io.StringReader;
import java.rmi.RemoteException;
import java.util.concurrent.atomic.AtomicInteger;
import javax.xml.rpc.ServiceException;
public class VREGenerator implements VREGeneratorI {
public class VREGenerator implements VREGeneratorI{
D4ScienceSession session;
ModelerServicePortType modelPortType;
GCUBESecurityManagerImpl managerSec;
protected static AtomicInteger vreId = new AtomicInteger(0);
/**
* @param session
@ -45,26 +47,29 @@ public class VREGenerator implements VREGeneratorI{
modelPortType = deserializeEPR(epr);
managerSec = new PortalSecurityManager(session);
}
/**
* @param session
*/
public VREGenerator(D4ScienceSession session) {
super();
this.session = session;
managerSec = new PortalSecurityManager(session);
modelPortType = null;
}
ModelerServicePortType deserializeEPR(String epr)
{
ModelerServicePortType deserializeEPR(String epr) {
StringReader stringReader = new StringReader(epr);
InputSource inputSource = new InputSource(stringReader);
EndpointReferenceType endpointReferenceType = null;
try {
endpointReferenceType = (EndpointReferenceType) ObjectDeserializer.deserialize(inputSource, EndpointReferenceType.class);
endpointReferenceType = (EndpointReferenceType) ObjectDeserializer
.deserialize(inputSource, EndpointReferenceType.class);
ModelerServiceAddressingLocator mSALocator = new ModelerServiceAddressingLocator();
modelPortType = GCUBERemotePortTypeContext.getProxy(mSALocator.getModelerServicePortTypePort(endpointReferenceType), session.getScope(),managerSec);
modelPortType = GCUBERemotePortTypeContext.getProxy(mSALocator
.getModelerServicePortTypePort(endpointReferenceType),
session.getScope(), managerSec);
return modelPortType;
} catch (Exception e) {
e.printStackTrace();
@ -72,52 +77,127 @@ public class VREGenerator implements VREGeneratorI{
}
}
public static void getAllVREs()
{
public static String getAllVREs(D4ScienceSession session) {
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(
session.getScope());
EndpointReferenceType serviceEPR = new EndpointReferenceType();
ModelerFactoryPortType mFPType = null;
ModelerFactoryServiceAddressingLocator mFSLocator = new ModelerFactoryServiceAddressingLocator();
PortalSecurityManager manager = new PortalSecurityManager(session);
String[] modelerURIs;
try {
modelerURIs = disInfo.getEndPointForVREModelerService();
} catch (Exception e1) {
e1.printStackTrace();
return "";
}
for (int i = 0; i < modelerURIs.length; i++) {
try {
System.out.println("getModelFactoryPortTypePort(epr)");
serviceEPR.setAddress(new Address(modelerURIs[vreId
.getAndIncrement()
% modelerURIs.length]));
mFPType = GCUBERemotePortTypeContext.getProxy(mFSLocator
.getModelerFactoryPortTypePort(serviceEPR), session
.getScope(), manager);
return mFPType.getAllDLs(new VOID());
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
return "";
}
/* (non-Javadoc)
public static void removeVRE(D4ScienceSession session, String id) {
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(
session.getScope());
EndpointReferenceType serviceEPR = new EndpointReferenceType();
ModelerFactoryPortType mFPType = null;
ModelerFactoryServiceAddressingLocator mFSLocator = new ModelerFactoryServiceAddressingLocator();
PortalSecurityManager manager = new PortalSecurityManager(session);
String[] modelerURIs;
try {
modelerURIs = disInfo.getEndPointForVREModelerService();
} catch (Exception e1) {
e1.printStackTrace();
return;
}
for (int i = 0; i < modelerURIs.length; i++) {
try {
System.out.println("getModelFactoryPortTypePort(epr)");
serviceEPR.setAddress(new Address(modelerURIs[vreId
.getAndIncrement()
% modelerURIs.length]));
mFPType = GCUBERemotePortTypeContext.getProxy(mFSLocator
.getModelerFactoryPortTypePort(serviceEPR), session
.getScope(), manager);
mFPType.removeDL(id);
break;
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/*
* (non-Javadoc)
*
* @see org.gcube.application.framework.VVREGeneratorI#checkVREStatus()
*/
public String[][] checkVREStatus() throws RemoteException {
// TODO pou vrisketai auti i sunartisi sta stubs?????
return null;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.gcube.application.framework.VVREGeneratorI#deployVRE()
*/
public void deployVRE() throws RemoteException {
modelPortType.deployDL(new VOID());
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.gcube.application.framework.VVREGeneratorI#getCollection()
*/
public String getCollection() throws RemoteException {
return modelPortType.getCollection(new VOID());
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.gcube.application.framework.VVREGeneratorI#getGHNs()
*/
public String getGHNs() throws RemoteException {
return modelPortType.getDHNs(new VOID());
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.gcube.application.framework.VVREGeneratorI#getVREModel()
*/
public String getVREModel() throws RemoteException {
@ -125,67 +205,78 @@ public class VREGenerator implements VREGeneratorI{
return null;
}
/* (non-Javadoc)
* @see org.gcube.application.framework.VVREGeneratorI#getExistingNamesVREs()
/*
* (non-Javadoc)
*
* @see
* org.gcube.application.framework.VVREGeneratorI#getExistingNamesVREs()
*/
public String[] getExistingNamesVREs() {
// return getModelPortType().get(new VOID());
// return getModelPortType().get(new VOID());
return null;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.gcube.application.framework.VVREGeneratorI#getFunctionality()
*/
public String getFunctionality() throws RemoteException {
return modelPortType.getFunctionality(new VOID());
}
/* (non-Javadoc)
* @see org.gcube.application.framework.VVREGeneratorI#getMetadataRelatedToCollection()
/*
* (non-Javadoc)
*
* @see
* org.gcube.application.framework.VVREGeneratorI#getMetadataRelatedToCollection
* ()
*/
public String getMetadataRelatedToCollection() throws RemoteException {
return modelPortType.getMetadataRelatedToCollection(new VOID());
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.gcube.application.framework.VVREGeneratorI#getQuality()
*/
public String getQuality() throws RemoteException {
return modelPortType.getQuality(new VOID());
}
/* (non-Javadoc)
* @see org.gcube.application.framework.VVREGeneratorI#setCollection(java.lang.String[])
/*
* (non-Javadoc)
*
* @see
* org.gcube.application.framework.VVREGeneratorI#setCollection(java.lang
* .String[])
*/
public void setCollection(String[] collections) throws RemoteException {
modelPortType.setCollection(new CollectionArray(collections));
}
/* (non-Javadoc)
* @see org.gcube.application.framework.VVREGeneratorI#setGHNs(java.lang.String[])
/*
* (non-Javadoc)
*
* @see
* org.gcube.application.framework.VVREGeneratorI#setGHNs(java.lang.String
* [])
*/
public void setGHNs(String[] GHNElements) throws RemoteException {
modelPortType.setDHNs(new DHNArray(GHNElements));
}
/* (non-Javadoc)
* @see org.gcube.application.framework.VVREGeneratorI#setVREModel(java.lang.String, java.lang.String, java.lang.String, java.lang.String, long, long)
/*
* (non-Javadoc)
*
* @see
* org.gcube.application.framework.VVREGeneratorI#setVREModel(java.lang.
* String, java.lang.String, java.lang.String, java.lang.String, long, long)
*/
public void setVREModel(String VREName, String VREDescription, String VREDesigner, String VREManager, long startTime, long endTime) throws RemoteException {
public void setVREModel(String VREName, String VREDescription,
String VREDesigner, String VREManager, long startTime, long endTime)
throws RemoteException {
VdlRequest vdlReq = new VdlRequest();
vdlReq.setDLDescription(VREDescription);
vdlReq.setDLDesigner(VREDesigner);
@ -196,36 +287,32 @@ public class VREGenerator implements VREGeneratorI{
modelPortType.setDLModel(vdlReq);
}
/* (non-Javadoc)
* @see org.gcube.application.framework.VVREGeneratorI#setVREtoPendingState()
/*
* (non-Javadoc)
*
* @see
* org.gcube.application.framework.VVREGeneratorI#setVREtoPendingState()
*/
public void setVREtoPendingState() throws RemoteException {
modelPortType.setDLtoPendingState(new VOID());
}
public void setFunctionality(String[] csIDElement, String[] functionalityIDElement)
throws RemoteException {
public void setFunctionality(String[] csIDElement,
String[] functionalityIDElement) throws RemoteException {
FunctionalityIDArray functArray = new FunctionalityIDArray();
functArray.setCsIDElement(csIDElement);
functArray.setFunctionalityIDElement(functionalityIDElement);
modelPortType.setFunctionality(functArray );
modelPortType.setFunctionality(functArray);
}
public void setMetadataRelatedToCollection(String[] collectionIDArray, boolean[][] checkedArray, String[] mdFormatIDArray)
public void setMetadataRelatedToCollection(String[] collectionIDArray,
boolean[][] checkedArray, String[] mdFormatIDArray)
throws RemoteException {
SetMDFormatArgs mdFormat = new SetMDFormatArgs();
int numRows = checkedArray.length;
CheckedRows[] checkedRows = new CheckedRows[numRows];
for(int i=0; i<numRows; i++){
for (int i = 0; i < numRows; i++) {
CheckedRows row = new CheckedRows(checkedArray[i]);
checkedRows[i] = row;
}
@ -235,56 +322,71 @@ public class VREGenerator implements VREGeneratorI{
modelPortType.setMetadataRelatedToCollection(mdFormat);
}
public void setQuality(String quality) throws RemoteException {
modelPortType.setQuality(quality);
}
private void getModelPortType(){
private void getModelPortType() {
System.out.println("--- Get ModelPortType ---");
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(
session.getScope());
EndpointReferenceType epr = null;
EndpointReferenceType serviceEPR = new EndpointReferenceType();
ModelerFactoryPortType mFPType = null;
ModelerServicePortType mServicePortType = null;
EndpointReferenceType VREEndpointReferenceType;
if(modelPortType==null){
if (modelPortType == null) {
System.out.println("VREEndpointReferenceType==null");
ModelerFactoryServiceAddressingLocator mFSLocator = new ModelerFactoryServiceAddressingLocator();
String[] modelerURIs;
try {
System.out.println("getModelFactoryPortTypePort(epr)");
mFPType = GCUBERemotePortTypeContext.getProxy(mFSLocator.getModelerFactoryPortTypePort(epr),
session.getScope(),managerSec);
VREEndpointReferenceType = mFPType.createResource(new VOID());
ModelerServiceAddressingLocator mSALocator = new ModelerServiceAddressingLocator();
mServicePortType = GCUBERemotePortTypeContext.getProxy(mSALocator.getModelerServicePortTypePort(VREEndpointReferenceType), session.getScope(),managerSec);
// Attaching Credential to port type
System.out.println("Attaching Credential to port type");
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
modelerURIs = disInfo.getEndPointForVREModelerService();
} catch (Exception e1) {
e1.printStackTrace();
return;
}
}
else
{
for (int i = 0; i < modelerURIs.length; i++) {
try {
System.out.println("getModelFactoryPortTypePort(epr)");
serviceEPR.setAddress(new Address(modelerURIs[vreId
.getAndIncrement()
% modelerURIs.length]));
mFPType = GCUBERemotePortTypeContext.getProxy(mFSLocator
.getModelerFactoryPortTypePort(serviceEPR), session
.getScope(), managerSec);
VREEndpointReferenceType = mFPType
.createResource(new VOID());
mFPType.getAllDLs(new VOID());
ModelerServiceAddressingLocator mSALocator = new ModelerServiceAddressingLocator();
modelPortType = GCUBERemotePortTypeContext
.getProxy(
mSALocator
.getModelerServicePortTypePort(VREEndpointReferenceType),
session.getScope(), managerSec);
// Attaching Credential to port type
System.out.println("Attaching Credential to port type");
break;
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
System.out.println("modelPortType!=null");
System.out.println(modelPortType.toString());
}
System.out.println("--- Get ModelPortType done ---");
modelPortType = mServicePortType;
}
public String getDLepr() {
return modelPortType.toString();
}
}