Search in sources :

Example 31 with StringValue

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.");
}
Also used : NonUniqueResultException(eu.esdihumboldt.util.blueprints.entities.NonUniqueResultException) Vertex(com.tinkerpop.blueprints.Vertex) User(eu.esdihumboldt.hale.server.model.User) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) TemplateUploadForm(eu.esdihumboldt.hale.server.templates.war.components.TemplateUploadForm) Label(org.apache.wicket.markup.html.basic.Label) AbortWithHttpErrorCodeException(org.apache.wicket.request.http.flow.AbortWithHttpErrorCodeException) StringValue(org.apache.wicket.util.string.StringValue) Template(eu.esdihumboldt.hale.server.model.Template)

Example 32 with StringValue

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);
        }
    }
}
Also used : ProductInfo(io.github.zutherb.appstash.shop.service.product.model.ProductInfo) StringValue(org.apache.wicket.util.string.StringValue) Url(org.apache.wicket.request.Url)

Example 33 with StringValue

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);
}
Also used : StringValue(org.apache.wicket.util.string.StringValue) Person(org.devgateway.toolkit.persistence.dao.Person) EqualPasswordInputValidator(org.apache.wicket.markup.html.form.validation.EqualPasswordInputValidator)

Example 34 with StringValue

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);
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UrlParametersReceivingBehavior(de.tudarmstadt.ukp.clarin.webanno.support.wicketstuff.UrlParametersReceivingBehavior) StringValue(org.apache.wicket.util.string.StringValue) IRequestParameters(org.apache.wicket.request.IRequestParameters)

Example 35 with StringValue

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;
}
Also used : WorkflowRestClient(org.apache.syncope.client.console.rest.WorkflowRestClient) Logger(org.slf4j.Logger) WorkflowDefinitionTO(org.apache.syncope.common.lib.to.WorkflowDefinitionTO) Constants(org.apache.syncope.client.console.commons.Constants) LoggerFactory(org.slf4j.LoggerFactory) AbstractResource(org.apache.wicket.request.resource.AbstractResource) StringValue(org.apache.wicket.util.string.StringValue) NotFoundException(javax.ws.rs.NotFoundException) WorkflowDefinitionTO(org.apache.syncope.common.lib.to.WorkflowDefinitionTO) NotFoundException(javax.ws.rs.NotFoundException) StringValue(org.apache.wicket.util.string.StringValue)

Aggregations

StringValue (org.apache.wicket.util.string.StringValue)54 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 Test (org.junit.Test)7 Task (com.evolveum.midpoint.task.api.Task)6 Url (org.apache.wicket.request.Url)5 IOException (java.io.IOException)4 WebSession (org.apache.openmeetings.web.app.WebSession)4 RestartResponseException (org.apache.wicket.RestartResponseException)4 IRequestHandler (org.apache.wicket.request.IRequestHandler)3 AbstractResource (org.apache.wicket.request.resource.AbstractResource)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 ObjectViewDto (com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)2 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)2 Vertex (com.tinkerpop.blueprints.Vertex)2 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)2 Template (eu.esdihumboldt.hale.server.model.Template)2 User (eu.esdihumboldt.hale.server.model.User)2 NonUniqueResultException (eu.esdihumboldt.util.blueprints.entities.NonUniqueResultException)2