use of org.vcell.util.document.User in project vcell by virtualcell.
the class SimulationTaskServerResource method get_json.
@Override
public SimulationTaskRepresentation get_json() {
VCellApiApplication application = ((VCellApiApplication) getApplication());
User vcellUser = application.getVCellUser(getChallengeResponse(), AuthenticationPolicy.prohibitInvalidCredentials);
// return sim;
return null;
}
use of org.vcell.util.document.User in project vcell by virtualcell.
the class TestRestServerBlinov method getVCellApiApplication.
public static VCellApiApplication getVCellApiApplication() throws DataAccessException {
return new VCellApiApplication(getRestDatabaseService(), null, null, null, null, new Configuration(), null, null) {
@Override
public Restlet createInboundRoot() {
// TODO Auto-generated method stub
Router rootRouter = new Router(getContext());
// rootRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
rootRouter.attach("/" + BIOMODEL, BiomodelsServerResource.class);
rootRouter.attach("/" + BIOMODEL + "/{" + BIOMODELID + "}", BiomodelServerResource.class);
rootRouter.attach("/" + BIOMODEL + "/{" + BIOMODELID + "}/" + SBML_DOWNLOAD, BiomodelSBMLServerResource.class);
rootRouter.attach("/" + BIOMODEL + "/{" + BIOMODELID + "}/" + VCML_DOWNLOAD, BiomodelVCMLServerResource.class);
return rootRouter;
}
@Override
public User getVCellUser(ChallengeResponse response, AuthenticationPolicy authPolicy) {
// TODO Auto-generated method stub
return new User("gsoc", new KeyValue("0"));
}
};
}
use of org.vcell.util.document.User in project vcell by virtualcell.
the class LoginRestlet method handle.
@Override
public void handle(Request request, Response response) {
// String html =
// "<html>" +
// "/login ... should have been redirected."+
// "</html>";
// response.setEntity(html, MediaType.TEXT_HTML);
VCellApiApplication application = ((VCellApiApplication) getApplication());
User vcellUser = application.getVCellUser(request.getChallengeResponse(), AuthenticationPolicy.ignoreInvalidCredentials);
String jsonString = "{}";
if (vcellUser != null) {
jsonString = "{user: \"" + vcellUser.getName() + "\"}";
}
response.setEntity(new JsonRepresentation(jsonString));
}
use of org.vcell.util.document.User in project vcell by virtualcell.
the class PublicationsServerResource method get_html.
@Override
public Representation get_html() {
VCellApiApplication application = ((VCellApiApplication) getApplication());
User vcellUser = application.getVCellUser(getChallengeResponse(), AuthenticationPolicy.ignoreInvalidCredentials);
PublicationRepresentation[] publications = getPublicationRepresentations(vcellUser);
Map<String, Object> dataModel = new HashMap<String, Object>();
// +"?"+VCellApiApplication.REDIRECTURL_FORMNAME+"="+getRequest().getResourceRef().toUrl());
dataModel.put("loginurl", "/" + VCellApiApplication.LOGINFORM);
dataModel.put("logouturl", "/" + VCellApiApplication.LOGOUT + "?" + VCellApiApplication.REDIRECTURL_FORMNAME + "=" + Reference.encode(getRequest().getResourceRef().toUrl().toString()));
if (vcellUser != null) {
dataModel.put("userid", vcellUser.getName());
}
dataModel.put("pubId", getQueryValue(PARAM_PUB_ID));
dataModel.put("orderBy", getQueryValue(PARAM_ORDERBY));
dataModel.put("publications", Arrays.asList(publications));
Gson gson = new Gson();
dataModel.put("jsonResponse", gson.toJson(publications));
Configuration templateConfiguration = application.getTemplateConfiguration();
Representation formFtl = new ClientResource(LocalReference.createClapReference("/publications.ftl")).get();
TemplateRepresentation templateRepresentation = new TemplateRepresentation(formFtl, templateConfiguration, dataModel, MediaType.TEXT_HTML);
return templateRepresentation;
}
use of org.vcell.util.document.User in project vcell by virtualcell.
the class SimulationJobStatus method toRep.
public SimpleJobStatusRepresentation toRep() {
String vcellServerID = getServerID().toString();
String simulationKey = getVCSimulationIdentifier().getSimulationKey().toString();
int taskID = getTaskID();
int jobIndex = getJobIndex();
long submitDate = getSubmitDate().getTime();
User owner = getVCSimulationIdentifier().getOwner();
SimpleJobStatusRepresentation.SchedulerStatus schedulerStatus = SimpleJobStatusRepresentation.SchedulerStatus.valueOf(getSchedulerStatus().name());
SimpleJobStatusRepresentation.DetailedState detailedState = SimpleJobStatusRepresentation.DetailedState.valueOf(getSimulationMessage().getDetailedState().name());
String detailedStateMessage = getSimulationMessage().getDisplayMessage();
Long htcJobNumber = null;
String htcComputeServer = null;
SimpleJobStatusRepresentation.BatchSystemType htcBatchSystemType = null;
Date simexe_startDate = null;
Date simexe_latestUpdateDate = null;
Date simexe_endDate = null;
String computeHost = null;
Boolean hasData = null;
SimulationExecutionStatus simExeStatus = getSimulationExecutionStatus();
if (simExeStatus != null) {
HtcJobID htcJobID = simExeStatus.getHtcJobID();
if (htcJobID != null) {
htcJobNumber = htcJobID.getJobNumber();
htcComputeServer = htcJobID.getServer();
htcBatchSystemType = SimpleJobStatusRepresentation.BatchSystemType.valueOf(htcJobID.getBatchSystemType().name());
}
simexe_startDate = simExeStatus.getStartDate();
simexe_latestUpdateDate = simExeStatus.getLatestUpdateDate();
simexe_endDate = simExeStatus.getEndDate();
computeHost = simExeStatus.getComputeHost();
hasData = simExeStatus.hasData();
}
Integer queuePriority = null;
Date queueDate = null;
SimpleJobStatusRepresentation.SimulationQueueID queueId = null;
SimulationQueueEntryStatus simQueueStatus = getSimulationQueueEntryStatus();
if (simQueueStatus != null) {
queuePriority = simQueueStatus.getQueuePriority();
queueDate = simQueueStatus.getQueueDate();
queueId = SimpleJobStatusRepresentation.SimulationQueueID.valueOf(simQueueStatus.getQueueID().name());
}
SimpleJobStatusRepresentation rep = new SimpleJobStatusRepresentation(vcellServerID, simulationKey, taskID, jobIndex, new Date(submitDate), owner.getName(), owner.getID().toString(), schedulerStatus, detailedState, detailedStateMessage, htcJobNumber, htcComputeServer, htcBatchSystemType, queuePriority, queueDate, queueId, simexe_startDate, simexe_latestUpdateDate, simexe_endDate, computeHost, hasData);
return rep;
}
Aggregations