Search in sources :

Example 16 with PermissionException

use of org.vcell.util.PermissionException in project vcell by virtualcell.

the class BiomodelSimulationStartServerResource method start.

@Override
public Representation start() {
    VCellApiApplication application = ((VCellApiApplication) getApplication());
    User vcellUser = application.getVCellUser(getChallengeResponse(), AuthenticationPolicy.prohibitInvalidCredentials);
    RestDatabaseService restDatabaseService = application.getRestDatabaseService();
    try {
        SimulationRep simRep = restDatabaseService.startSimulation(this, vcellUser);
        Representation representation = new StringRepresentation("simulation started", MediaType.TEXT_PLAIN);
        redirectSeeOther("/" + VCellApiApplication.SIMTASK + "?" + SimulationTasksServerResource.PARAM_SIM_ID + "=" + simRep.getKey().toString() + "&" + SimulationTasksServerResource.PARAM_STATUS_COMPLETED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_DISPATCHED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_FAILED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_QUEUED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_RUNNING + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_STOPPED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_WAITING + "=on" + "&" + SimulationTasksServerResource.PARAM_START_ROW + "=1" + "&" + SimulationTasksServerResource.PARAM_MAX_ROWS + "=" + Integer.toString(simRep.getScanCount() * 4));
        return representation;
    } catch (PermissionException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "not authorized to start simulation");
    } catch (ObjectNotFoundException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "simulation not found");
    } catch (Exception e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
    }
}
Also used : PermissionException(org.vcell.util.PermissionException) User(org.vcell.util.document.User) StringRepresentation(org.restlet.representation.StringRepresentation) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) VCellApiApplication(org.vcell.rest.VCellApiApplication) StringRepresentation(org.restlet.representation.StringRepresentation) Representation(org.restlet.representation.Representation) ResourceException(org.restlet.resource.ResourceException) SimulationRep(cbit.vcell.modeldb.SimulationRep) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResourceException(org.restlet.resource.ResourceException)

Example 17 with PermissionException

use of org.vcell.util.PermissionException in project vcell by virtualcell.

the class BiomodelVCMLModelInfoResource method getBiomodel.

private BioModel getBiomodel(KeyValue bmKey, User vcellUser) {
    RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
    try {
        // VCellApiApplication application = ((VCellApiApplication)getApplication());
        BigString cachedVcml = restDatabaseService.getBioModelXML(bmKey, vcellUser);
        BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(cachedVcml.toString()));
        return bioModel;
    } catch (PermissionException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "permission denied to requested resource");
    } catch (ObjectNotFoundException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "biomodel not found");
    } catch (Exception e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
    }
}
Also used : PermissionException(org.vcell.util.PermissionException) BioModel(cbit.vcell.biomodel.BioModel) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) VCellApiApplication(org.vcell.rest.VCellApiApplication) ResourceException(org.restlet.resource.ResourceException) BigString(org.vcell.util.BigString) XMLSource(cbit.vcell.xml.XMLSource) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResourceException(org.restlet.resource.ResourceException)

Example 18 with PermissionException

use of org.vcell.util.PermissionException in project vcell by virtualcell.

the class BiomodelVCMLModelInfoResource method getBiomodel.

private BioModel getBiomodel(String modelName, User vcellUser) {
    RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
    try {
        // VCellApiApplication application = ((VCellApiApplication)getApplication());
        final VCInfoContainer vcInfoContainer = restDatabaseService.getVCInfoContainer(vcellUser);
        for (int i = 0; i < vcInfoContainer.getBioModelInfos().length; i++) {
            if (vcInfoContainer.getBioModelInfos()[i].getVersion().getName().equals(modelName)) {
                BigString cachedVcml = restDatabaseService.getBioModelXML(vcInfoContainer.getBioModelInfos()[i].getVersion().getVersionKey(), vcellUser);
                BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(cachedVcml.toString()));
                return bioModel;
            }
        }
        throw new Exception("VCDocument named '" + modelName + "'" + " not found");
    } catch (PermissionException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "permission denied to requested resource");
    } catch (ObjectNotFoundException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "biomodel not found");
    } catch (Exception e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
    }
}
Also used : PermissionException(org.vcell.util.PermissionException) BioModel(cbit.vcell.biomodel.BioModel) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) VCInfoContainer(org.vcell.util.document.VCInfoContainer) VCellApiApplication(org.vcell.rest.VCellApiApplication) ResourceException(org.restlet.resource.ResourceException) BigString(org.vcell.util.BigString) XMLSource(cbit.vcell.xml.XMLSource) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResourceException(org.restlet.resource.ResourceException)

Example 19 with PermissionException

use of org.vcell.util.PermissionException in project vcell by virtualcell.

the class BiomodelSimulationStopServerResource method stop.

@Override
public Representation stop() {
    VCellApiApplication application = ((VCellApiApplication) getApplication());
    User vcellUser = application.getVCellUser(getChallengeResponse(), AuthenticationPolicy.prohibitInvalidCredentials);
    RestDatabaseService restDatabaseService = application.getRestDatabaseService();
    try {
        SimulationRep simRep = restDatabaseService.stopSimulation(this, vcellUser);
        Representation representation = new StringRepresentation("simulation stopped", MediaType.TEXT_PLAIN);
        redirectSeeOther("/" + VCellApiApplication.SIMTASK + "?" + SimulationTasksServerResource.PARAM_SIM_ID + "=" + simRep.getKey().toString() + "&" + SimulationTasksServerResource.PARAM_STATUS_COMPLETED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_DISPATCHED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_FAILED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_QUEUED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_RUNNING + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_STOPPED + "=on" + "&" + SimulationTasksServerResource.PARAM_STATUS_WAITING + "=on" + "&" + SimulationTasksServerResource.PARAM_START_ROW + "=1" + "&" + SimulationTasksServerResource.PARAM_MAX_ROWS + "=" + Integer.toString(simRep.getScanCount() * 4));
        return representation;
    } catch (PermissionException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "not authorized to stop simulation");
    } catch (ObjectNotFoundException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "simulation not found");
    } catch (Exception e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
    }
}
Also used : PermissionException(org.vcell.util.PermissionException) User(org.vcell.util.document.User) StringRepresentation(org.restlet.representation.StringRepresentation) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) VCellApiApplication(org.vcell.rest.VCellApiApplication) StringRepresentation(org.restlet.representation.StringRepresentation) Representation(org.restlet.representation.Representation) ResourceException(org.restlet.resource.ResourceException) SimulationRep(cbit.vcell.modeldb.SimulationRep) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResourceException(org.restlet.resource.ResourceException)

Example 20 with PermissionException

use of org.vcell.util.PermissionException in project vcell by virtualcell.

the class BiomodelVCMLServerResource method getBiomodelVCML.

private String getBiomodelVCML(User vcellUser) {
    // if (!application.authenticate(getRequest(), getResponse())){
    // // not authenticated
    // return new SimulationTaskRepresentation[0];
    // }else{
    RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
    try {
        String cachedVcml = restDatabaseService.query(this, vcellUser);
        BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(cachedVcml));
        String latestVcml = XmlHelper.bioModelToXML(bioModel);
        return latestVcml;
    } catch (PermissionException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "permission denied to requested resource");
    } catch (ObjectNotFoundException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "biomodel not found");
    } catch (Exception e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
    }
// }
}
Also used : PermissionException(org.vcell.util.PermissionException) BioModel(cbit.vcell.biomodel.BioModel) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) VCellApiApplication(org.vcell.rest.VCellApiApplication) ResourceException(org.restlet.resource.ResourceException) XMLSource(cbit.vcell.xml.XMLSource) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResourceException(org.restlet.resource.ResourceException)

Aggregations

PermissionException (org.vcell.util.PermissionException)28 ResourceException (org.restlet.resource.ResourceException)18 VCellApiApplication (org.vcell.rest.VCellApiApplication)17 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)17 DataAccessException (org.vcell.util.DataAccessException)9 KeyValue (org.vcell.util.document.KeyValue)8 User (org.vcell.util.document.User)8 BioModel (cbit.vcell.biomodel.BioModel)6 SimulationRep (cbit.vcell.modeldb.SimulationRep)6 XMLSource (cbit.vcell.xml.XMLSource)6 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)5 BigString (org.vcell.util.BigString)5 PublicationRep (cbit.vcell.modeldb.PublicationRep)4 ExpressionException (cbit.vcell.parser.ExpressionException)4 PublicationRepresentation (org.vcell.rest.common.PublicationRepresentation)4 BioModelRep (cbit.vcell.modeldb.BioModelRep)3 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)3 BigDecimal (java.math.BigDecimal)3 PreparedStatement (java.sql.PreparedStatement)3