use of org.apache.wicket.util.string.StringValue 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.");
}
use of org.apache.wicket.util.string.StringValue in project the-app by devops-dojo.
the class DirectBuyRequestCycleListener method onBeginRequest.
@Override
public void onBeginRequest(RequestCycle cycle) {
StringValue directBuyParameterValue = cycle.getRequest().getRequestParameters().getParameterValue(DIRECT_BUY_PARAMETER);
if (!directBuyParameterValue.isEmpty()) {
try {
ProductInfo productInfo = productService.findByQuery(ProductQuery.create().withUrlname(directBuyParameterValue.toString()));
if (productInfo != null) {
cart.addItem(productInfo);
} else {
ShopSession.get().error(String.format("Das Product '%s' konnte nicht gefunden werden.", directBuyParameterValue));
}
Url urlWithoutDirectBuy = removeDirectBuyFromUrl(cycle);
redirectTo(cycle, urlWithoutDirectBuy);
} catch (Exception e) {
ShopSession.get().error(DIRECT_BUY_PROCESSING_FAILED_MESSAGE);
LOGGER.error(DIRECT_BUY_PROCESSING_FAILED_MESSAGE, e);
}
}
}
use of org.apache.wicket.util.string.StringValue in project oc-explorer by devgateway.
the class EditUserPage method onInitialize.
@Override
protected void onInitialize() {
Person person = SecurityUtil.getCurrentAuthenticatedPerson();
if (!SecurityUtil.isCurrentUserAdmin()) {
if (person.getId() != getPageParameters().get(WebConstants.PARAM_ID).toLong()) {
setResponsePage(getApplication().getHomePage());
}
}
super.onInitialize();
userName.required();
userName.getField().add(new UsernamePatternValidator());
StringValue idPerson = getPageParameters().get(WebConstants.PARAM_ID);
if (!idPerson.isNull()) {
userName.getField().add(new UniqueUsernameValidator(idPerson.toLong()));
} else {
userName.getField().add(new UniqueUsernameValidator());
}
userName.setIsFloatedInput(true);
editForm.add(userName);
MetaDataRoleAuthorizationStrategy.authorize(userName, Component.ENABLE, SecurityConstants.Roles.ROLE_ADMIN);
firstName.required();
firstName.setIsFloatedInput(true);
editForm.add(firstName);
lastName.required();
lastName.setIsFloatedInput(true);
editForm.add(lastName);
email.required();
email.getField().add(EmailAddressValidator.getInstance());
if (!idPerson.isNull()) {
email.getField().add(new UniqueEmailAddressValidator(idPerson.toLong()));
} else {
email.getField().add(new UniqueEmailAddressValidator());
}
email.setIsFloatedInput(true);
editForm.add(email);
title.setIsFloatedInput(true);
editForm.add(title);
group.required();
group.setIsFloatedInput(true);
editForm.add(group);
MetaDataRoleAuthorizationStrategy.authorize(group, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
editForm.add(defaultDashboard);
MetaDataRoleAuthorizationStrategy.authorize(defaultDashboard, Component.ENABLE, SecurityConstants.Roles.ROLE_ADMIN);
roles.required();
roles.getField().setOutputMarkupId(true);
roles.setIsFloatedInput(true);
editForm.add(roles);
MetaDataRoleAuthorizationStrategy.authorize(roles, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
// stop resetting the password fields each time they are rendered
password.getField().setResetPassword(false);
cpassword.getField().setResetPassword(false);
if (SecurityUtil.isCurrentUserAdmin() && !SecurityUtil.isUserAdmin(compoundModel.getObject()) && idPerson.isNull()) {
// hide the change password checkbox and set it's model to true
compoundModel.getObject().setChangePass(true);
changePass.setVisibilityAllowed(false);
} else {
compoundModel.getObject().setChangePass(compoundModel.getObject().getChangePassword());
password.getField().setEnabled(compoundModel.getObject().getChangePassword());
cpassword.getField().setEnabled(compoundModel.getObject().getChangePassword());
}
changePass.setIsFloatedInput(true);
editForm.add(changePass);
password.getField().add(new PasswordPatternValidator());
password.setOutputMarkupId(true);
password.setIsFloatedInput(true);
editForm.add(password);
cpassword.setOutputMarkupId(true);
cpassword.setIsFloatedInput(true);
editForm.add(cpassword);
editForm.add(new EqualPasswordInputValidator(password.getField(), cpassword.getField()));
enabled.setIsFloatedInput(true);
editForm.add(enabled);
MetaDataRoleAuthorizationStrategy.authorize(enabled, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
changePassword.setIsFloatedInput(true);
editForm.add(changePassword);
MetaDataRoleAuthorizationStrategy.authorize(changePassword, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
MetaDataRoleAuthorizationStrategy.authorize(deleteButton, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
}
use of org.apache.wicket.util.string.StringValue in project webanno by webanno.
the class AnnotationPage method createUrlFragmentBehavior.
private UrlParametersReceivingBehavior createUrlFragmentBehavior() {
return new UrlParametersReceivingBehavior() {
private static final long serialVersionUID = -3860933016636718816L;
@Override
protected void onParameterArrival(IRequestParameters aRequestParameters, AjaxRequestTarget aTarget) {
aTarget.addChildren(getPage(), IFeedback.class);
StringValue project = aRequestParameters.getParameterValue(PAGE_PARAM_PROJECT_ID);
StringValue document = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT_ID);
StringValue focus = aRequestParameters.getParameterValue(PAGE_PARAM_FOCUS);
handleParameters(aTarget, project, document, focus, false);
}
};
}
use of org.apache.wicket.util.string.StringValue in project syncope by apache.
the class AbstractWorkflowResource method getWorkflowDefinition.
protected WorkflowDefinitionTO getWorkflowDefinition(final Attributes attributes) {
final StringValue modelId = attributes.getRequest().getQueryParameters().getParameterValue(Constants.MODEL_ID_PARAM);
WorkflowDefinitionTO workflowDefinition = modelId == null || modelId.isNull() ? null : restClient.getDefinitions().stream().filter(object -> modelId.toString().equals(object.getModelId())).findAny().orElse(null);
if (workflowDefinition == null) {
throw new NotFoundException("Workflow definition with modelId " + modelId);
}
return workflowDefinition;
}
Aggregations