use of org.vcell.util.PermissionException in project vcell by virtualcell.
the class BiomodelsServerResource method getBiomodelRepresentations.
private BiomodelRepresentation[] getBiomodelRepresentations(User vcellUser) throws ParseException {
// if (!application.authenticate(getRequest(), getResponse())){
// // not authenticated
// return new SimulationTaskRepresentation[0];
// }else{
ArrayList<BiomodelRepresentation> biomodelReps = new ArrayList<BiomodelRepresentation>();
RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
try {
BioModelRep[] bioModelReps = restDatabaseService.query(this, vcellUser);
for (BioModelRep bioModelRep : bioModelReps) {
BiomodelRepresentation biomodelRep = new BiomodelRepresentation(bioModelRep);
biomodelReps.add(biomodelRep);
}
} catch (PermissionException ee) {
ee.printStackTrace();
throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "not authorized");
} catch (DataAccessException | SQLException | ExpressionException e) {
e.printStackTrace();
throw new RuntimeException("failed to retrieve biomodels from VCell Database : " + e.getMessage());
}
return biomodelReps.toArray(new BiomodelRepresentation[0]);
// }
}
use of org.vcell.util.PermissionException in project vcell by virtualcell.
the class RestDatabaseService method stopSimulation.
public SimulationRep stopSimulation(BiomodelSimulationStopServerResource resource, User vcellUser) throws PermissionException, ObjectNotFoundException, DataAccessException, SQLException {
// resource.getRequestAttributes().get(VCellApiApplication.SIMDATAID);
String simId = resource.getAttribute(VCellApiApplication.SIMULATIONID);
KeyValue simKey = new KeyValue(simId);
SimulationRep simRep = getSimulationRep(simKey);
if (simRep == null) {
throw new ObjectNotFoundException("Simulation with key " + simKey + " not found");
}
User owner = simRep.getOwner();
if (!owner.compareEqual(vcellUser)) {
throw new PermissionException("not authorized to stop simulation");
}
VCMessageSession rpcSession = vcMessagingService.createProducerSession();
try {
UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(), null);
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
e.printStackTrace();
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
rpcSimServerProxy.stopSimulation(vcellUser, vcSimID);
return simRep;
} finally {
rpcSession.close();
}
}
use of org.vcell.util.PermissionException in project vcell by virtualcell.
the class BiomodelServerResource method getBiomodelRepresentation.
private BiomodelRepresentation getBiomodelRepresentation(User vcellUser) {
// if (!application.authenticate(getRequest(), getResponse())){
// // not authenticated
// return new SimulationTaskRepresentation[0];
// }else{
RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
try {
BioModelRep bioModelRep = restDatabaseService.query(this, vcellUser);
BiomodelRepresentation biomodelRep = new BiomodelRepresentation(bioModelRep);
return biomodelRep;
} 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());
}
// }
}
use of org.vcell.util.PermissionException in project vcell by virtualcell.
the class SimulationControllerImpl method getOrCreateSolverController.
/**
* This method was created by a SmartGuide.
* @throws SolverException
* @throws DataAccessException
* @throws ConfigurationException
* @exception java.rmi.RemoteException The exception description.
* @throws JMSException
* @throws AuthenticationException
* @throws SQLException
* @throws FileNotFoundException
*/
LocalSolverController getOrCreateSolverController(SimulationTask simTask) throws FileNotFoundException, ConfigurationException, DataAccessException, AuthenticationException, SQLException, SolverException {
Simulation simulation = simTask.getSimulation();
VCSimulationIdentifier vcSimID = simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
if (vcSimID == null) {
throw new IllegalArgumentException("cannot run an unsaved simulation");
}
if (!simulation.getVersion().getOwner().equals(localVCellConnection.getUserLoginInfo().getUser())) {
throw new PermissionException("insufficient privilege: startSimulation()");
}
SimulationTaskID simTaskInfo = new SimulationTaskID(simTask);
LocalSolverController solverController = solverControllerHash.get(simTaskInfo);
if (solverController == null) {
solverController = createNewSolverController(simTask);
solverControllerHash.put(simTaskInfo, solverController);
}
return solverController;
}
use of org.vcell.util.PermissionException in project vcell by virtualcell.
the class SimulationContextDbDriver method deleteSimContextSQL.
/**
* removeModel method comment.
*/
private void deleteSimContextSQL(Connection con, User user, KeyValue simContextKey) throws SQLException, PermissionException, DataAccessException, DependencyException {
// log.print("deleteSimContextSQL(user=" + user + ", simContextKey=" + simContextKey + ")");
//
// check for external references (from BioModel)
//
failOnExternalRefs(con, BioModelSimContextLinkTable.table.simContextRef, BioModelSimContextLinkTable.table, simContextKey, SimContextTable.table);
KeyValue mathKey = getDeletableMathKeyFromSimContext(con, user, simContextKey);
//
// delete SimulationContext (Model and Geometry link tables are ON DELETE CASCADE)
//
String sql;
sql = DatabasePolicySQL.enforceOwnershipDelete(user, simContextTable, simContextTable.id.getQualifiedColName() + " = " + simContextKey);
updateCleanSQL(con, sql);
//
try {
mathDescDB.deleteVersionable(con, user, VersionableType.MathDescription, mathKey);
if (lg.isTraceEnabled()) {
lg.trace("SimulationContextDbDriver.delete(" + simContextKey + ") deletion of MathDescription(" + mathKey + ") succeeded");
}
} catch (PermissionException | DependencyException e) {
if (lg.isWarnEnabled()) {
lg.warn("SimulationContextDbDriver.delete(" + simContextKey + ") deletion of MathDescription(" + mathKey + ") failed: " + e.getMessage());
}
}
}
Aggregations