53 lines
1.8 KiB
Java
53 lines
1.8 KiB
Java
package org.gcube.application.perform.service.rest;
|
|
|
|
import java.util.List;
|
|
|
|
import javax.inject.Inject;
|
|
import javax.ws.rs.PUT;
|
|
import javax.ws.rs.Path;
|
|
import javax.ws.rs.QueryParam;
|
|
import javax.ws.rs.WebApplicationException;
|
|
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.DBField;
|
|
import org.gcube.application.perform.service.engine.model.DBQueryDescriptor;
|
|
import org.gcube.application.perform.service.engine.model.importer.ImportRoutineDescriptor;
|
|
import org.gcube.smartgears.annotations.ManagedBy;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@Path(ServiceConstants.Snapshot.PATH)
|
|
@ManagedBy(PerformServiceManager.class)
|
|
public class Snapshot {
|
|
|
|
private static final Logger log= LoggerFactory.getLogger(Snapshot.class);
|
|
|
|
@Inject
|
|
private Importer importer;
|
|
|
|
@PUT
|
|
public void snapshot(@QueryParam(ServiceConstants.Snapshot.BATCH_TYPE_PARAMETER) String batchType,
|
|
@QueryParam(ServiceConstants.Snapshot.FARM_ID_PARAMETER)Long farmid) {
|
|
|
|
InterfaceCommons.checkMandatory(batchType, ServiceConstants.Snapshot.BATCH_TYPE_PARAMETER);
|
|
InterfaceCommons.checkMandatory(farmid, ServiceConstants.Snapshot.FARM_ID_PARAMETER);
|
|
try {
|
|
List<ImportRoutineDescriptor> found=importer.getDescriptors(new DBQueryDescriptor().add(
|
|
DBField.ImportRoutine.fields.get(DBField.ImportRoutine.FARM_ID), farmid).
|
|
add(DBField.ImportRoutine.fields.get(DBField.ImportRoutine.BATCH_TYPE), batchType));
|
|
|
|
|
|
|
|
}catch(Throwable t) {
|
|
log.warn("Unexpected Exception ",t);
|
|
throw new WebApplicationException("Unexpected Exception.", t,Response.Status.INTERNAL_SERVER_ERROR);
|
|
}
|
|
|
|
}
|
|
|
|
}
|