use of eu.esdihumboldt.hale.server.templates.war.components.TemplateUploadForm in project hale by halestudio.
the class UploadTemplatePage method addControls.
@Override
protected void addControls(boolean loggedIn) {
super.addControls(loggedIn);
add(new TemplateUploadForm("upload", null));
}
use of eu.esdihumboldt.hale.server.templates.war.components.TemplateUploadForm in project hale by halestudio.
the class UpdateTemplatePage method addControls.
@Override
protected void addControls() {
StringValue idParam = getPageParameters().get(0);
if (!idParam.isNull() && !idParam.isEmpty()) {
String templateId = idParam.toString();
OrientGraph graph = DatabaseHelper.getGraph();
try {
Template template = null;
try {
template = Template.getByTemplateId(graph, templateId);
} catch (NonUniqueResultException e) {
log.error("Duplicate template representation: " + templateId, e);
}
if (template != null) {
// get associated user
Vertex v = template.getV();
Iterator<Vertex> owners = v.getVertices(Direction.OUT, "owner").iterator();
if (// user is admin
UserUtil.isAdmin() || // or user is owner
(owners.hasNext() && UserUtil.getLogin().equals(new User(owners.next(), graph).getLogin()))) {
// template name
add(new Label("name", template.getName()));
// upload form
add(new TemplateUploadForm("upload-form", templateId));
} else {
throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_FORBIDDEN);
}
} else {
throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "Template not found.");
}
} finally {
graph.shutdown();
}
} else
throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_BAD_REQUEST, "Template identifier must be specified.");
}
Aggregations