git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application/perform-service@176412 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
eb77600697
commit
1eb4ba6a00
4
.project
4
.project
|
@ -16,12 +16,12 @@
|
|||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<faceted-project>
|
||||
<fixed facet="wst.jsdt.web"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
<installed facet="jst.web" version="2.5"/>
|
||||
<installed facet="jst.jaxrs" version="2.0"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
<installed facet="jst.web" version="3.0"/>
|
||||
</faceted-project>
|
||||
|
|
39
pom.xml
39
pom.xml
|
@ -16,9 +16,7 @@
|
|||
<properties>
|
||||
<webappDirectory>${project.basedir}/src/main/webapp/WEB-INF</webappDirectory>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
<jersey-version>2.14</jersey-version> <!-- 2.22 -->
|
||||
<jersey-cdi-version>2.14</jersey-cdi-version>
|
||||
<weld-version>2.2.4.Final</weld-version>
|
||||
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -43,6 +41,11 @@
|
|||
<artifactId>common-smartgears</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-dbcp2</artifactId>
|
||||
|
@ -61,36 +64,38 @@
|
|||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.14.8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- weld -->
|
||||
<!-- <dependency> <groupId>javax.enterprise</groupId> <artifactId>cdi-api</artifactId>
|
||||
<version>1.2</version> </dependency> <dependency> <groupId>org.jboss.weld.servlet</groupId>
|
||||
<artifactId>weld-servlet</artifactId> <version>${weld-version}</version>
|
||||
2.0.4 doesn't find implementations. 2.2.4 doesn't find CDI... </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.enterprise</groupId>
|
||||
<artifactId>cdi-api</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.weld.servlet</groupId>
|
||||
<artifactId>weld-servlet</artifactId>
|
||||
<version>${weld-version}</version> <!-- 2.0.4 doesn't find implementations. 2.2.4 doesn't find CDI... -->
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- DM -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.analysis</groupId>
|
||||
<artifactId>data-miner-manager-cl</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
|
@ -23,6 +23,8 @@ public class LocalConfiguration {
|
|||
public static final String PERFORMANCE_DB_ENDPOINT_CATEGORY="performance-db.ep.name";
|
||||
|
||||
|
||||
public static final String IMPORTER_COMPUTATION_ID="dm.importer.computationid";
|
||||
|
||||
static LocalConfiguration instance=null;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package org.gcube.application.perform.service;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
|
||||
|
||||
@ApplicationPath(ServiceConstants.APPLICATION_PATH)
|
||||
public class PerformService {
|
||||
|
||||
public PerformService() {
|
||||
super();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,8 @@ package org.gcube.application.perform.service;
|
|||
|
||||
public interface ServiceConstants {
|
||||
|
||||
public static final String APPLICATION_PATH="/gcube/service/";
|
||||
|
||||
public static interface Mappings{
|
||||
public static final String PATH="mappings";
|
||||
public static final String BATCHES_METHOD="batch";
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.sql.Connection;
|
|||
import java.sql.SQLException;
|
||||
|
||||
import org.gcube.application.perform.service.engine.model.ISQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.InternalException;
|
||||
|
||||
public interface DataBaseManager {
|
||||
|
||||
|
@ -13,7 +14,7 @@ public interface DataBaseManager {
|
|||
}
|
||||
|
||||
|
||||
public Connection getConnection() throws SQLException;
|
||||
public Connection getConnection() throws SQLException, InternalException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
|||
import org.gcube.application.perform.service.LocalConfiguration;
|
||||
import org.gcube.application.perform.service.engine.model.DatabaseConnectionDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.ISQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.InternalException;
|
||||
import org.gcube.application.perform.service.engine.utils.ISUtils;
|
||||
|
||||
import lombok.Synchronized;
|
||||
|
@ -58,7 +59,7 @@ public class DataBaseManagerImpl implements DataBaseManager{
|
|||
}
|
||||
|
||||
|
||||
private synchronized DatabaseConnectionDescriptor getDB() {
|
||||
private synchronized DatabaseConnectionDescriptor getDB() throws InternalException {
|
||||
if(dbDescriptor==null) {
|
||||
dbDescriptor=ISUtils.queryForDatabase(queryDescriptor);
|
||||
}
|
||||
|
@ -66,13 +67,13 @@ public class DataBaseManagerImpl implements DataBaseManager{
|
|||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
public Connection getConnection() throws SQLException, InternalException {
|
||||
DataSource ds=getDataSource();
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private DataSource getDataSource() {
|
||||
private DataSource getDataSource() throws InternalException {
|
||||
DatabaseConnectionDescriptor dbDescriptor=getDB();
|
||||
|
||||
if(!datasources.containsKey(dbDescriptor.getUrl())) {
|
||||
|
|
|
@ -6,12 +6,13 @@ import java.util.List;
|
|||
import org.gcube.application.perform.service.engine.dm.DMException;
|
||||
import org.gcube.application.perform.service.engine.model.BeanNotFound;
|
||||
import org.gcube.application.perform.service.engine.model.DBQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.InternalException;
|
||||
import org.gcube.application.perform.service.engine.model.importer.ImportRequest;
|
||||
import org.gcube.application.perform.service.engine.model.importer.ImportRoutineDescriptor;
|
||||
|
||||
public interface Importer {
|
||||
|
||||
|
||||
public ImportRoutineDescriptor importExcel(ImportRequest request) throws DMException, BeanNotFound, SQLException;
|
||||
public List<ImportRoutineDescriptor> getDescriptors(DBQueryDescriptor query);
|
||||
public ImportRoutineDescriptor importExcel(ImportRequest request) throws DMException, BeanNotFound, SQLException, InternalException;
|
||||
public List<ImportRoutineDescriptor> getDescriptors(DBQueryDescriptor query) throws SQLException, InternalException;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,12 @@ import java.sql.Connection;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.perform.service.LocalConfiguration;
|
||||
import org.gcube.application.perform.service.engine.dm.DMException;
|
||||
|
@ -17,7 +22,13 @@ import org.gcube.application.perform.service.engine.model.ISQueryDescriptor;
|
|||
import org.gcube.application.perform.service.engine.model.InternalException;
|
||||
import org.gcube.application.perform.service.engine.model.importer.ImportRequest;
|
||||
import org.gcube.application.perform.service.engine.model.importer.ImportRoutineDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.importer.ImportStatus;
|
||||
import org.gcube.application.perform.service.engine.utils.CommonUtils;
|
||||
import org.gcube.application.perform.service.engine.utils.ScopeUtils;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||
|
||||
import lombok.Synchronized;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -25,10 +36,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class ImporterImpl implements Importer {
|
||||
|
||||
private static final String ORPHAN_IMPORTS="";
|
||||
private static final String ACQUIRE_PS="";
|
||||
private static final String GET_BY_ID="";
|
||||
private static final String INSERT_ROUTINE="";
|
||||
|
||||
|
||||
|
||||
private static ISQueryDescriptor isQueryDescriptor=null;
|
||||
|
@ -47,31 +55,37 @@ public class ImporterImpl implements Importer {
|
|||
|
||||
|
||||
private static final String getHostname() {
|
||||
throw new RuntimeException("IMPLEMENT THIS");
|
||||
ApplicationContext context=ContextProvider.get();
|
||||
ContainerConfiguration configuration=context.container().configuration();
|
||||
|
||||
return configuration.hostname();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void init() throws InternalException{
|
||||
try {
|
||||
log.info("Initializing IMPORTER");
|
||||
DataBaseManager db=DataBaseManager.get(getISQueryDescriptor());
|
||||
Connection conn=db.getConnection();
|
||||
conn.setAutoCommit(true);
|
||||
PreparedStatement psOrphans=conn.prepareStatement(ORPHAN_IMPORTS);
|
||||
PreparedStatement psAcquire=conn.prepareStatement(ACQUIRE_PS);
|
||||
|
||||
|
||||
PreparedStatement psOrphans=Queries.ORPHAN_IMPORTS.prepare(conn);
|
||||
PreparedStatement psAcquire=Queries.ACQUIRE_PS.prepare(conn);
|
||||
// set ps
|
||||
ResultSet rsOrphans=psOrphans.executeQuery();
|
||||
long monitoredCount=0l;
|
||||
while(rsOrphans.next()) {
|
||||
Long id=rsOrphans.getLong(ImportRoutine.ID);
|
||||
try {
|
||||
ImportRoutineDescriptor desc=rowToDescriptor(rsOrphans);
|
||||
ImportRoutineDescriptor desc=Queries.rowToDescriptor(rsOrphans);
|
||||
String hostname=getHostname();
|
||||
DBQueryDescriptor acquireDesc=new DBQueryDescriptor().
|
||||
add(ImportRoutine.fields.get(ImportRoutine.LOCK), hostname).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.ID), id);
|
||||
|
||||
// "acquire"
|
||||
// set lock = hostname where ID =? and LOCK is null
|
||||
// Acquired = updated rows == 1
|
||||
psAcquire.setString(1, hostname);
|
||||
psAcquire.setLong(2, id);
|
||||
Queries.ACQUIRE_PS.fill(psAcquire, acquireDesc);
|
||||
|
||||
if(psAcquire.executeUpdate()>0) {
|
||||
log.debug("Acquired {} ",id);
|
||||
|
@ -91,7 +105,7 @@ public class ImporterImpl implements Importer {
|
|||
|
||||
|
||||
@Override
|
||||
public ImportRoutineDescriptor importExcel(ImportRequest request) throws DMException, BeanNotFound, SQLException {
|
||||
public ImportRoutineDescriptor importExcel(ImportRequest request) throws DMException, SQLException, InternalException {
|
||||
log.debug("Submitting {} ",request);
|
||||
ComputationId id=submit(request);
|
||||
log.debug("Registering {} computationID {} ",request,id);
|
||||
|
@ -108,42 +122,91 @@ public class ImporterImpl implements Importer {
|
|||
DMUtils.monitor(DMUtils.getComputation(desc), new ImporterMonitor(desc,getISQueryDescriptor()));
|
||||
}
|
||||
|
||||
private ComputationId submit(ImportRequest request) {
|
||||
|
||||
|
||||
|
||||
private ComputationId submit(ImportRequest request) throws DMException {
|
||||
/**
|
||||
* dataminer-prototypes.d4science.org/wps/WebProcessingService?
|
||||
* request=Execute&service=WPS&Version=1.0.0&gcube-token=***REMOVED***&lang=en-US&
|
||||
* Identifier=org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.PERFORMFISH_DATA_EXTRACTOR
|
||||
* &
|
||||
* DataInputs=
|
||||
* InputData=https%3A%2F%2Fdata.d4science.org%2Fshub%2F9689bbe2-148f-4406-ab69-6e0f6ab892ca;
|
||||
* BatchType=GROW_OUT_AGGREGATED;
|
||||
* FarmID=ID
|
||||
*/
|
||||
|
||||
throw new RuntimeException("IMPLEMENT THIS SHIT");
|
||||
Map<String,String> parameters=new HashMap<>();
|
||||
parameters.put("InputData", request.getSource());
|
||||
parameters.put("BatchType", request.getBatchType());
|
||||
parameters.put("FarmID", request.getFarmId().toString());
|
||||
|
||||
return DMUtils.submitJob(LocalConfiguration.getProperty(LocalConfiguration.IMPORTER_COMPUTATION_ID), parameters);
|
||||
}
|
||||
|
||||
private ImportRoutineDescriptor register(ComputationId computationId,ImportRequest request) throws SQLException {
|
||||
|
||||
ImportRoutineDescriptor toReturn=new ImportRoutineDescriptor();
|
||||
// SET FIELDS into OBJECT
|
||||
|
||||
|
||||
private ImportRoutineDescriptor register(ComputationId computationId,ImportRequest request) throws SQLException, InternalException {
|
||||
|
||||
DBQueryDescriptor insertionRow=new DBQueryDescriptor().
|
||||
add(ImportRoutine.fields.get(ImportRoutine.BATCH_TYPE), request.getBatchType()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.CALLER), CommonUtils.encryptString(ScopeUtils.getCaller())).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.COMPUTATION_ID), computationId.getId()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.COMPUTATION_OPID), computationId.getOperatorId()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.COMPUTATION_OPNAME), computationId.getOperatorName()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.COMPUTATION_REQ), computationId.getEquivalentRequest()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.COMPUTATION_URL), computationId.getUrlId()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.FARM_ID), request.getFarmId()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.LOCK), getHostname()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.SOURCE_URL), request.getSource()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.SOURCE_VERSION), request.getVersion()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.START), Instant.now()).
|
||||
add(ImportRoutine.fields.get(ImportRoutine.STATUS),ImportStatus.ACCEPTED.toString());
|
||||
|
||||
|
||||
DataBaseManager db=DataBaseManager.get(getISQueryDescriptor());
|
||||
Connection conn=db.getConnection();
|
||||
PreparedStatement ps=conn.prepareStatement(INSERT_ROUTINE);
|
||||
// set fields
|
||||
conn.setAutoCommit(true);
|
||||
|
||||
throw new RuntimeException("IMPLEMENT THIS SHIT");
|
||||
PreparedStatement ps=Queries.INSERT_ROUTINE.prepare(conn,Statement.RETURN_GENERATED_KEYS);
|
||||
Queries.INSERT_ROUTINE.fill(ps, insertionRow);
|
||||
ps.executeUpdate();
|
||||
|
||||
ResultSet rs=ps.getGeneratedKeys();
|
||||
rs.next();
|
||||
|
||||
PreparedStatement psGet=Queries.GET_BY_ID.get(conn,
|
||||
new DBQueryDescriptor().add(ImportRoutine.fields.get(ImportRoutine.ID), rs.getLong(ImportRoutine.ID)));
|
||||
ResultSet rsGet=psGet.executeQuery();
|
||||
rsGet.next();
|
||||
return Queries.rowToDescriptor(rsGet);
|
||||
}
|
||||
|
||||
private ImportRoutineDescriptor getDescriptorById(Long id) throws BeanNotFound, SQLException {
|
||||
private ImportRoutineDescriptor getDescriptorById(Long id) throws SQLException, InternalException {
|
||||
DataBaseManager db=DataBaseManager.get(getISQueryDescriptor());
|
||||
Connection conn=db.getConnection();
|
||||
PreparedStatement ps=conn.prepareStatement(GET_BY_ID);
|
||||
Connection conn=db.getConnection();
|
||||
|
||||
PreparedStatement ps=Queries.GET_BY_ID.get(conn,
|
||||
new DBQueryDescriptor().add(ImportRoutine.fields.get(ImportRoutine.ID), id));
|
||||
ps.setLong(1, id);
|
||||
ResultSet rs=ps.executeQuery();
|
||||
if(rs.next()) return rowToDescriptor(rs);
|
||||
if(rs.next()) return Queries.rowToDescriptor(rs);
|
||||
else throw new BeanNotFound("Unable to find Routine with ID "+id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ImportRoutineDescriptor> getDescriptors(DBQueryDescriptor desc) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public List<ImportRoutineDescriptor> getDescriptors(DBQueryDescriptor desc) throws SQLException, InternalException {
|
||||
DataBaseManager db=DataBaseManager.get(getISQueryDescriptor());
|
||||
Connection conn=db.getConnection();
|
||||
|
||||
PreparedStatement ps=Queries.FILTER_IMPORTS.get(conn, desc);
|
||||
ResultSet rs=ps.executeQuery();
|
||||
ArrayList<ImportRoutineDescriptor> toReturn=new ArrayList<>();
|
||||
while (rs.next())
|
||||
toReturn.add(Queries.rowToDescriptor(rs));
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,8 +214,6 @@ public class ImporterImpl implements Importer {
|
|||
|
||||
|
||||
|
||||
private static ImportRoutineDescriptor rowToDescriptor(ResultSet rs) {
|
||||
throw new RuntimeException("IMPLEMENT THIS SHIT");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,12 +4,14 @@ import java.sql.SQLException;
|
|||
|
||||
import org.gcube.application.perform.service.engine.model.BeanNotFound;
|
||||
import org.gcube.application.perform.service.engine.model.DBQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.InternalException;
|
||||
import org.gcube.application.perform.service.engine.model.InvalidRequestException;
|
||||
import org.gcube.application.perform.service.engine.model.anagraphic.Batch;
|
||||
import org.gcube.application.perform.service.engine.model.anagraphic.Farm;
|
||||
|
||||
public interface MappingManager {
|
||||
|
||||
public Batch getBatch(DBQueryDescriptor desc) throws BeanNotFound, SQLException;
|
||||
public Farm getFarm(DBQueryDescriptor desc)throws BeanNotFound, SQLException;
|
||||
public Batch getBatch(DBQueryDescriptor desc) throws BeanNotFound, SQLException, InvalidRequestException, InternalException;
|
||||
public Farm getFarm(DBQueryDescriptor desc)throws BeanNotFound, SQLException,InvalidRequestException, InternalException;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import org.gcube.application.perform.service.engine.model.BeanNotFound;
|
|||
import org.gcube.application.perform.service.engine.model.DBField;
|
||||
import org.gcube.application.perform.service.engine.model.DBQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.ISQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.InternalException;
|
||||
import org.gcube.application.perform.service.engine.model.InvalidRequestException;
|
||||
import org.gcube.application.perform.service.engine.model.anagraphic.Batch;
|
||||
import org.gcube.application.perform.service.engine.model.anagraphic.Farm;
|
||||
|
||||
|
@ -19,17 +21,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
@Slf4j
|
||||
public class MappingManagerImpl implements MappingManager {
|
||||
|
||||
|
||||
private static final String INSERT_BATCH="INSERT INTO batches (id,uuid,farmid,type,name) VALUES (SELECT (max(id)+1 from batches),?,?,?,?) ON CONFLICT DO NOTHING";
|
||||
private static final String GET_BATCH_BY_ID="Select * from batches where id = ?";
|
||||
private static final String GET_BATCH_BY_DESCRIPTIVE_KEY="Select * from batches where farmid=? AND type=? AND name= ?";
|
||||
|
||||
|
||||
private static final String GET_FARM_BY_ID=String.format("SELECT f.farmid as $1%s, f.uuid as %2$s, c.companyid as %3$s, c.uuid as %4$s, a.associationid as %5$s, a.uuid as %6$s FROM "
|
||||
+ "farms as f INNER JOIN companies as c ON f.companyid=c.companyid INNER JOIN associations as a ON c.associationid=a.associationid WHERE f.farmid = ?",
|
||||
DBField.Farm.FARM_ID,DBField.Farm.UUID,DBField.Farm.COMPANY_ID,DBField.Farm.COMPANY_UUID,DBField.Farm.ASSOCIATION_ID,DBField.Farm.ASSOCIATION_UUID);
|
||||
|
||||
|
||||
private static ISQueryDescriptor isQueryDescriptor=null;
|
||||
|
||||
|
@ -49,32 +40,22 @@ public class MappingManagerImpl implements MappingManager {
|
|||
|
||||
|
||||
@Override
|
||||
public Batch getBatch(DBQueryDescriptor desc) throws BeanNotFound,SQLException{
|
||||
public Batch getBatch(DBQueryDescriptor desc) throws SQLException, InternalException{
|
||||
DataBaseManager db=DataBaseManager.get(getISQueryDescriptor());
|
||||
|
||||
String type=desc.getCondition().get(DBField.Batch.fields.get(DBField.Batch.BATCH_TYPE));
|
||||
String name=desc.getCondition().get(DBField.Batch.fields.get(DBField.Batch.BATCH_NAME));
|
||||
Long farmid=Long.parseLong(desc.getCondition().get(DBField.Batch.fields.get(DBField.Batch.FARM_ID)));
|
||||
|
||||
Connection conn=db.getConnection();
|
||||
PreparedStatement psSearch=conn.prepareStatement(GET_BATCH_BY_DESCRIPTIVE_KEY);
|
||||
psSearch.setLong(1, farmid);
|
||||
psSearch.setString(2, type);
|
||||
psSearch.setString(3, name);
|
||||
Query getQuery=Queries.GET_BATCH_BY_DESCRIPTIVE_KEY;
|
||||
PreparedStatement psSearch=getQuery.get(conn, desc);
|
||||
|
||||
ResultSet rs=psSearch.executeQuery();
|
||||
|
||||
if(rs.next())
|
||||
return rowToBatch(rs);
|
||||
return Queries.rowToBatch(rs);
|
||||
|
||||
// ID NOT FOUND, TRY TO REGISTER IT
|
||||
|
||||
log.trace("Registering new Batch [name {} , type {}, farmid {} ] ",name,type,farmid);
|
||||
PreparedStatement psInsert=conn.prepareStatement(INSERT_BATCH);
|
||||
psInsert.setString(1, UUID.randomUUID().toString());
|
||||
psInsert.setLong(2,farmid);
|
||||
psInsert.setString(3, type);
|
||||
psInsert.setString(4, name);
|
||||
|
||||
log.trace("Registering new Batch from condition {}",desc);
|
||||
PreparedStatement psInsert=Queries.INSERT_BATCH.get(conn, desc);
|
||||
|
||||
boolean inserted=psInsert.executeUpdate()==1;
|
||||
if(inserted) {
|
||||
conn.commit();
|
||||
|
@ -83,52 +64,31 @@ public class MappingManagerImpl implements MappingManager {
|
|||
rs=psSearch.executeQuery();
|
||||
|
||||
if(rs.next())
|
||||
return rowToBatch(rs);
|
||||
else throw new BeanNotFound(String.format("Unable to find Bean [farmid=%1$d, type=%2$s,name=%3$s]",farmid,type,name));
|
||||
return Queries.rowToBatch(rs);
|
||||
else throw new BeanNotFound(String.format("Unable to find Bean with ",desc));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Farm getFarm(DBQueryDescriptor desc) throws BeanNotFound,SQLException{
|
||||
public Farm getFarm(DBQueryDescriptor desc) throws SQLException, InternalException{
|
||||
DataBaseManager db=DataBaseManager.get(getISQueryDescriptor());
|
||||
|
||||
|
||||
Connection conn=db.getConnection();
|
||||
PreparedStatement psGet=null;
|
||||
DBField IDField=DBField.Farm.fields.get(DBField.Farm.FARM_ID);
|
||||
if(desc.getCondition().containsKey(IDField)) {
|
||||
// get By ID
|
||||
psGet=conn.prepareStatement(GET_FARM_BY_ID);
|
||||
psGet.setLong(1,Long.parseLong(desc.getCondition().get(IDField)));
|
||||
if(desc.getCondition().containsKey(IDField)) {
|
||||
psGet=Queries.GET_FARM_BY_ID.get(conn, desc);
|
||||
}
|
||||
|
||||
ResultSet rs=psGet.executeQuery();
|
||||
if(!rs.next())
|
||||
throw new BeanNotFound("Farm not found. Condition was "+desc);
|
||||
|
||||
return rowToFarm(rs);
|
||||
return Queries.rowToFarm(rs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static Batch rowToBatch(ResultSet rs) throws SQLException {
|
||||
Batch toReturn=new Batch();
|
||||
toReturn.setFarmId(rs.getLong(DBField.Batch.FARM_ID));
|
||||
toReturn.setId(rs.getLong(DBField.Batch.BATCH_ID));
|
||||
toReturn.setName(rs.getString(DBField.Batch.BATCH_NAME));
|
||||
toReturn.setType(rs.getString(DBField.Batch.BATCH_TYPE));
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
private static Farm rowToFarm(ResultSet rs) throws SQLException {
|
||||
Farm toReturn=new Farm();
|
||||
toReturn.setAssociationId(rs.getLong(DBField.Farm.ASSOCIATION_ID));
|
||||
toReturn.setAssociationUUID(rs.getString(DBField.Farm.ASSOCIATION_UUID));
|
||||
toReturn.setCompanyId(rs.getLong(DBField.Farm.COMPANY_ID));
|
||||
toReturn.setCompanyUUID(rs.getString(DBField.Farm.COMPANY_UUID));
|
||||
toReturn.setId(rs.getLong(DBField.Farm.FARM_ID));
|
||||
toReturn.setUUID(rs.getString(DBField.Farm.UUID));
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.application.perform.service.engine;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.gcube.application.perform.service.engine.model.DBField;
|
||||
import org.gcube.application.perform.service.engine.model.anagraphic.Batch;
|
||||
import org.gcube.application.perform.service.engine.model.anagraphic.Farm;
|
||||
import org.gcube.application.perform.service.engine.model.importer.ImportRoutineDescriptor;
|
||||
|
||||
public class Queries {
|
||||
|
||||
public static final Query GET_BATCH_BY_DESCRIPTIVE_KEY= new Query("Select * from batches where farmid=? AND type=? AND name= ?",
|
||||
new DBField[] {});
|
||||
|
||||
public static final Query INSERT_BATCH=new Query("INSERT INTO batches (id,uuid,farmid,type,name) VALUES (SELECT (max(id)+1 from batches),?,?,?,?) ON CONFLICT DO NOTHING",
|
||||
new DBField[] {});
|
||||
|
||||
public static final Query GET_FARM_BY_ID=new Query(String.format("SELECT f.farmid as $1%s, f.uuid as %2$s, c.companyid as %3$s, c.uuid as %4$s, a.associationid as %5$s, a.uuid as %6$s FROM "
|
||||
+ "farms as f INNER JOIN companies as c ON f.companyid=c.companyid INNER JOIN associations as a ON c.associationid=a.associationid WHERE f.farmid = ?",
|
||||
DBField.Farm.FARM_ID,DBField.Farm.UUID,DBField.Farm.COMPANY_ID,DBField.Farm.COMPANY_UUID,DBField.Farm.ASSOCIATION_ID,DBField.Farm.ASSOCIATION_UUID),
|
||||
new DBField[] {});
|
||||
|
||||
public static final Query GET_BATCH_BY_ID=new Query("Select * from batches where id = ?",
|
||||
new DBField[] {});
|
||||
|
||||
|
||||
// "acquire"
|
||||
// set lock = hostname where ID =? and LOCK is null
|
||||
// Acquired = updated rows == 1
|
||||
public static final Query ORPHAN_IMPORTS=new Query("",new DBField[]{});
|
||||
public static final Query ACQUIRE_PS=new Query("",new DBField[]{});
|
||||
public static final Query GET_BY_ID=new Query("",new DBField[]{});
|
||||
public static final Query INSERT_ROUTINE=new Query("",new DBField[]{});
|
||||
|
||||
public static final Query FILTER_IMPORTS=new Query("",new DBField[]{});
|
||||
|
||||
|
||||
|
||||
// LOADERS
|
||||
|
||||
public static Batch rowToBatch(ResultSet rs) throws SQLException {
|
||||
Batch toReturn=new Batch();
|
||||
toReturn.setFarmId(rs.getLong(DBField.Batch.FARM_ID));
|
||||
toReturn.setId(rs.getLong(DBField.Batch.BATCH_ID));
|
||||
toReturn.setName(rs.getString(DBField.Batch.BATCH_NAME));
|
||||
toReturn.setType(rs.getString(DBField.Batch.BATCH_TYPE));
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
public static Farm rowToFarm(ResultSet rs) throws SQLException {
|
||||
Farm toReturn=new Farm();
|
||||
toReturn.setAssociationId(rs.getLong(DBField.Farm.ASSOCIATION_ID));
|
||||
toReturn.setAssociationUUID(rs.getString(DBField.Farm.ASSOCIATION_UUID));
|
||||
toReturn.setCompanyId(rs.getLong(DBField.Farm.COMPANY_ID));
|
||||
toReturn.setCompanyUUID(rs.getString(DBField.Farm.COMPANY_UUID));
|
||||
toReturn.setId(rs.getLong(DBField.Farm.FARM_ID));
|
||||
toReturn.setUUID(rs.getString(DBField.Farm.UUID));
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
public static ImportRoutineDescriptor rowToDescriptor(ResultSet rs) {
|
||||
throw new RuntimeException("IMPLEMENT THIS SHIT");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package org.gcube.application.perform.service.engine;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.gcube.application.perform.service.engine.model.DBField;
|
||||
import org.gcube.application.perform.service.engine.model.DBQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.InvalidRequestException;
|
||||
|
||||
|
||||
public class Query {
|
||||
|
||||
private final String query;
|
||||
private final ArrayList<DBField> psFields;
|
||||
|
||||
public Query(String query,DBField[] fields) {
|
||||
this.query=query;
|
||||
this.psFields=new ArrayList<>(Arrays.asList(fields));
|
||||
}
|
||||
|
||||
|
||||
public PreparedStatement prepare(Connection conn, int statementOption) throws SQLException {
|
||||
return conn.prepareStatement(getQuery(),statementOption);
|
||||
}
|
||||
public PreparedStatement prepare(Connection conn) throws SQLException {
|
||||
return conn.prepareStatement(getQuery());
|
||||
}
|
||||
|
||||
|
||||
public PreparedStatement get(Connection conn, DBQueryDescriptor desc) throws SQLException, InvalidRequestException {
|
||||
PreparedStatement ps=prepare(conn);
|
||||
return fill(ps,desc);
|
||||
}
|
||||
|
||||
public PreparedStatement fill(PreparedStatement ps,DBQueryDescriptor desc) throws SQLException, InvalidRequestException{
|
||||
ArrayList<DBField> fields=getPSFields();
|
||||
for(int i=0;i<fields.size();i++) {
|
||||
DBField field=fields.get(i);
|
||||
if(!desc.getCondition().containsKey(field))
|
||||
throw new InvalidRequestException("Missing field "+field);
|
||||
else ps.setObject(i+1, desc.getCondition().get(field), field.getType());
|
||||
}
|
||||
return ps;
|
||||
}
|
||||
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
public ArrayList<DBField> getPSFields(){
|
||||
return psFields;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -41,6 +41,10 @@ public class DMUtils {
|
|||
monitor.start();
|
||||
}
|
||||
|
||||
public static ComputationId submitJob(String operatorId, Map<String,String> parameters) throws DMException {
|
||||
return submitJob(getClient(),operatorId,parameters);
|
||||
}
|
||||
|
||||
public static ComputationId submitJob(SClient client, String operatorId, Map<String,String> parameters) throws DMException {
|
||||
try {
|
||||
log.debug("Looking for operator by Id {} ",operatorId);
|
||||
|
|
|
@ -5,19 +5,26 @@ import java.util.Map.Entry;
|
|||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DBQueryDescriptor {
|
||||
|
||||
private Map<DBField,String> condition;
|
||||
private Map<DBField,Object> condition;
|
||||
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder=new StringBuilder();
|
||||
for(Entry<DBField,String> entry : condition.entrySet()) {
|
||||
for(Entry<DBField,Object> entry : condition.entrySet()) {
|
||||
builder.append(String.format("%1$s = %2$s AND ", entry.getKey().getFieldName(),entry.getValue()));
|
||||
}
|
||||
return builder.substring(0,builder.lastIndexOf(" AND ")).toString();
|
||||
}
|
||||
|
||||
public DBQueryDescriptor add(DBField field,Object obj) {
|
||||
condition.put(field, obj);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.application.perform.service.engine.model;
|
||||
|
||||
public class InvalidRequestException extends InternalException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidRequestException() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public InvalidRequestException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public InvalidRequestException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public InvalidRequestException(String message) {
|
||||
super(message);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public InvalidRequestException(Throwable cause) {
|
||||
super(cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,18 @@
|
|||
package org.gcube.application.perform.service.engine.model.importer;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
public class ImportRequest {
|
||||
|
||||
private String source;
|
||||
private String version;
|
||||
private String batchType;
|
||||
private Long farmId;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package org.gcube.application.perform.service.engine.utils;
|
||||
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
|
||||
public class CommonUtils {
|
||||
|
||||
public static String decryptString(String toDecrypt){
|
||||
try{
|
||||
return StringEncrypter.getEncrypter().decrypt(toDecrypt);
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException("Unable to decrypt : "+toDecrypt,e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String encryptString(String toEncrypt){
|
||||
try{
|
||||
return StringEncrypter.getEncrypter().encrypt(toEncrypt);
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException("Unable to encrypt : "+toEncrypt,e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,54 @@
|
|||
package org.gcube.application.perform.service.engine.utils;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.perform.service.engine.model.DatabaseConnectionDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.ISQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.InternalException;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class ISUtils {
|
||||
|
||||
|
||||
public static DatabaseConnectionDescriptor queryForDatabase(ISQueryDescriptor desc) {
|
||||
throw new RuntimeException("Implment me, asshole!");
|
||||
public static DatabaseConnectionDescriptor queryForDatabase(ISQueryDescriptor desc) throws InternalException {
|
||||
|
||||
log.debug("Querying for Service Endpoints {} ",desc,ScopeUtils.getCurrentScope());
|
||||
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
|
||||
if(desc.getCategory()!=null)
|
||||
query.addCondition("$resource/Profile/Category/text() eq '"+desc.getCategory()+"'");
|
||||
|
||||
if(desc.getPlatformName()!=null)
|
||||
query.addCondition("$resource/Profile/Platform/Name/text() eq '"+desc.getPlatformName()+"'");
|
||||
|
||||
if(desc.getResourceName()!=null)
|
||||
query.addCondition("$resource/Profile/Name/text() eq '"+desc.getCategory()+"'");
|
||||
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
|
||||
List<ServiceEndpoint> found=client.submit(query);
|
||||
|
||||
if(found.size()==0) throw new InternalException("Unable to find Service Endpoint "+desc+" in "+ScopeUtils.getCurrentScope());
|
||||
if(found.size()>1) log.warn("Multiple Endpoints "+desc+" found in "+ScopeUtils.getCurrentScope());
|
||||
AccessPoint point= found.get(0).profile().accessPoints().iterator().next();
|
||||
|
||||
String url="jdbc:postgresql://"+point.address()+"/"+point.name();
|
||||
|
||||
DatabaseConnectionDescriptor toReturn= new DatabaseConnectionDescriptor(point.username(), url, CommonUtils.decryptString(point.password()));
|
||||
log.debug("Going to use DB : "+toReturn);
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,5 +42,10 @@ public class ScopeUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getCaller() {
|
||||
return SecurityTokenProvider.instance.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.application.perform.service.rest;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
@ -11,6 +12,7 @@ import javax.ws.rs.core.Response;
|
|||
|
||||
import org.gcube.application.perform.service.PerformServiceManager;
|
||||
import org.gcube.application.perform.service.ServiceConstants;
|
||||
import org.gcube.application.perform.service.engine.Importer;
|
||||
import org.gcube.application.perform.service.engine.model.importer.ImportRoutineDescriptor;
|
||||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
|
||||
|
@ -20,6 +22,10 @@ import org.gcube.smartgears.annotations.ManagedBy;
|
|||
public class Import {
|
||||
|
||||
|
||||
@Inject
|
||||
private Importer importer;
|
||||
|
||||
|
||||
/**
|
||||
* Launches DM Import
|
||||
*
|
||||
|
|
|
@ -19,6 +19,8 @@ import org.gcube.application.perform.service.engine.MappingManager;
|
|||
import org.gcube.application.perform.service.engine.model.BeanNotFound;
|
||||
import org.gcube.application.perform.service.engine.model.DBField;
|
||||
import org.gcube.application.perform.service.engine.model.DBQueryDescriptor;
|
||||
import org.gcube.application.perform.service.engine.model.InternalException;
|
||||
import org.gcube.application.perform.service.engine.model.InvalidRequestException;
|
||||
import org.gcube.application.perform.service.engine.model.anagraphic.Batch;
|
||||
import org.gcube.application.perform.service.engine.model.anagraphic.Farm;
|
||||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
|
@ -54,20 +56,24 @@ public class Mappings {
|
|||
InterfaceCommons.checkMandatory(type, ServiceConstants.Mappings.BATCH_TYPE_PARAMETER);
|
||||
InterfaceCommons.checkMandatory(farmid, ServiceConstants.Mappings.FARM_ID_PARAMETER);
|
||||
|
||||
HashMap<DBField,String> condition=new HashMap<DBField,String>();
|
||||
HashMap<DBField,Object> condition=new HashMap<DBField,Object>();
|
||||
|
||||
condition.put(DBField.Batch.fields.get(DBField.Batch.BATCH_NAME), name);
|
||||
condition.put(DBField.Batch.fields.get(DBField.Batch.BATCH_TYPE), type);
|
||||
condition.put(DBField.Batch.fields.get(DBField.Batch.FARM_ID), farmid.toString());
|
||||
condition.put(DBField.Batch.fields.get(DBField.Batch.FARM_ID), farmid);
|
||||
|
||||
DBQueryDescriptor desc=new DBQueryDescriptor(condition);
|
||||
|
||||
try{
|
||||
return mappings.getBatch(desc);
|
||||
}catch(BeanNotFound e) {
|
||||
throw new WebApplicationException("Unable to find Farm with condition "+desc,Response.Status.BAD_REQUEST);
|
||||
throw new WebApplicationException("Unable to find Batch with condition "+desc,Response.Status.BAD_REQUEST);
|
||||
}catch(SQLException e) {
|
||||
throw new WebApplicationException("Unexpected Exception occurred while dealing with database.", e,Response.Status.INTERNAL_SERVER_ERROR);
|
||||
} catch (InvalidRequestException e) {
|
||||
throw new WebApplicationException("Unable to search for Batch. ",e,Response.Status.BAD_REQUEST);
|
||||
} catch (InternalException e) {
|
||||
throw new WebApplicationException("Unexpected Exception.", e,Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +95,7 @@ public class Mappings {
|
|||
|
||||
try {
|
||||
InterfaceCommons.checkMandatory(farmid, ServiceConstants.Mappings.FARM_ID_PARAMETER);
|
||||
desc=new DBQueryDescriptor(Collections.singletonMap(DBField.Farm.fields.get(DBField.Farm.FARM_ID), farmid.toString()));
|
||||
desc=new DBQueryDescriptor(Collections.singletonMap(DBField.Farm.fields.get(DBField.Farm.FARM_ID), farmid));
|
||||
}catch(WebApplicationException e) {
|
||||
try {
|
||||
InterfaceCommons.checkMandatory(farmuuid, ServiceConstants.Mappings.FARM_UUID_PARAMETER);
|
||||
|
@ -105,6 +111,10 @@ public class Mappings {
|
|||
throw new WebApplicationException("Unable to find Farm with condition "+desc,Response.Status.BAD_REQUEST);
|
||||
}catch(SQLException e) {
|
||||
throw new WebApplicationException("Unexpected Exception occurred while dealing with database.", e,Response.Status.INTERNAL_SERVER_ERROR);
|
||||
} catch (InvalidRequestException e) {
|
||||
throw new WebApplicationException("Unable to search for Farm. ",e,Response.Status.BAD_REQUEST);
|
||||
} catch (InternalException e) {
|
||||
throw new WebApplicationException("Unexpected Exception.", e,Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<web-app>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>org.gcube.application.perform.service.PerformService</servlet-name>
|
||||
<url-pattern>/gcube/service/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
Loading…
Reference in New Issue