Package org.brixcms.auth

Examples of org.brixcms.auth.Action


                    }

                    @Override
                    public boolean isVisible() {
                        Workspace target = ManageSnapshotsPanel.this.getModelObject();
                        Action action = new RestoreSnapshotAction(Context.ADMINISTRATION, item
                                .getModelObject(), target);
                        return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
                    }
                };

                /*
                 * in case the link is enabled, make sure it is intended...
                 */
                if (restoreLink.isEnabled()) {
                    restoreLink.add(new SimpleAttributeModifier("onClick", "return confirm('" + getLocalizer().getString("restoreOnClick", this) + "')"));
                }

                item.add(restoreLink);

                item.add(new Link<Void>("delete") {
                    @Override
                    public void onClick() {
                        Workspace snapshot = item.getModelObject();
                        snapshot.delete();
                    }

                    @Override
                    public boolean isVisible() {
                        Action action = new DeleteSnapshotAction(Context.ADMINISTRATION, item
                                .getModelObject());
                        return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
                    }
                });

                item.add(new Label("label", name));

                item.add(new Label("commentlabel", comment));
            }
        });


        add(new Link<Object>("downloadWorkspace") {
            @Override
            public void onClick() {
                getRequestCycle().scheduleRequestHandlerAfterCurrent(new IRequestHandler() {
                    public void detach(IRequestCycle requestCycle) {
                    }

                    public void respond(IRequestCycle requestCycle) {
                        WebResponse resp = (WebResponse) requestCycle.getResponse();
                        resp.setAttachmentHeader("workspace.xml");
                        String id = ManageSnapshotsPanel.this.getModelObject().getId();
                        Brix brix = getBrix();
                        JcrSession session = brix.getCurrentSession(id);
                        HttpServletResponse containerResponse = (HttpServletResponse) resp.getContainerResponse();
                        ServletOutputStream containerResponseOutputStream = null;
                        try {
                            containerResponseOutputStream = containerResponse.getOutputStream();
                        }
                        catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                        session.exportSystemView(brix.getRootPath(), containerResponseOutputStream, false, false);
                    }
                });
            }
        });

        /**
         * Form to create a new Snapshot and put any comment to it
         */
        Form<Object> commentForm = new Form<Object>("commentForm") {
            @Override
            public boolean isVisible() {
                Workspace target = ManageSnapshotsPanel.this.getModelObject();
                Action action = new CreateSnapshotAction(Context.ADMINISTRATION, target);
                return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
            }
        };

        final TextArea<String> area = new TextArea<String>("area", new Model<String>());
        commentForm.add(area);

        commentForm.add(new SubmitLink("createSnapshot") {
            /**
             * @see org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit()
             */
            @Override
            public void onSubmit() {
                String comment = area.getModelObject();
                SnapshotPlugin.get().createSnapshot(ManageSnapshotsPanel.this.getModelObject(), comment);
                area.setModelObject("");
            }
        });
        add(commentForm);


        Form<Object> uploadForm = new Form<Object>("uploadForm") {
            @Override
            public boolean isVisible() {
                Workspace target = ManageSnapshotsPanel.this.getModelObject();
                Action action = new RestoreSnapshotAction(Context.ADMINISTRATION, target);
                return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
            }
        };

        final FileUploadField upload = new FileUploadField("upload", new Model());
View Full Code Here


            return Collections.emptyList();
        } else {
            List<org.brixcms.workspace.Workspace> result = new ArrayList<org.brixcms.workspace.Workspace>(
                    workspaces.size());
            for (org.brixcms.workspace.Workspace w : workspaces) {
                Action action = new ViewWorkspaceAction(context, w);
                if (getAuthorizationStrategy().isActionAuthorized(action)) {
                    result.add(w);
                }
            }
View Full Code Here

        @Override
        public boolean isVisible() {
            Workspace workspace = PublishingPanel.this.getModelObject();
            String state = SitePlugin.get().getWorkspaceState(workspace);
            Action action = new PublishWorkspaceAction(Context.ADMINISTRATION, workspace,
                    targetState);

            return requiredState.equals(state) &&
                    Brix.get().getAuthorizationStrategy().isActionAuthorized(
                            action);
View Full Code Here

                    }

                    @Override
                    public boolean isVisible() {
                        Workspace target = ManagePrototypesPanel.this.getModelObject();
                        Action action = new RestorePrototypeAction(Context.ADMINISTRATION, item.getModelObject(), target);
                        return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
                    }
                });

                item.add(new Link<Void>("delete") {
                    @Override
                    public void onClick() {
                        Workspace prototype = item.getModelObject();
                        prototype.delete();
                    }

                    @Override
                    public boolean isVisible() {
                        Action action = new DeletePrototypeAction(Context.ADMINISTRATION, item.getModelObject());
                        return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
                    }
                });
            }
        });

        Form<Object> form = new Form<Object>("form") {
            @Override
            public boolean isVisible() {
                Workspace current = ManagePrototypesPanel.this.getModelObject();
                Action action = new CreatePrototypeAction(Context.ADMINISTRATION, current);
                return getBrix().getAuthorizationStrategy().isActionAuthorized(action);
            }
        };

        TextField<String> prototypeName = new TextField<String>("prototypeName", new PropertyModel<String>(this,
View Full Code Here

        @Override
        public boolean isVisible() {
            final Brix brix = Brix.get();
            final Workspace workspace = getWorkspaceModel().getObject();
            final Action action = new AccessWebDavUrlPluginAction(workspace);
            final boolean granted = brix.getAuthorizationStrategy().isActionAuthorized(action);
            return granted;
        }
View Full Code Here

        boolean found = false;

        for (SiteNodePlugin plugin : plugins) {
            if (plugin.getConverterForNode(node) != null) {
                Action action = new ConvertNodeAction(Action.Context.ADMINISTRATION, node,
                        plugin.getNodeType());

                if (node.getBrix().getAuthorizationStrategy().isActionAuthorized(action)) {
                    found = true;
View Full Code Here

    public boolean canAddNodeChild(BrixNode node, Context context) {
        if (!isNodeEditable(node)) {
            return false;
        }
        Action action = new SiteNodeAction(context, Type.NODE_ADD_CHILD, node);
        return brix.getAuthorizationStrategy().isActionAuthorized(action);
    }
View Full Code Here

    public boolean canDeleteNode(BrixNode node, Context context) {
        if (!isNodeEditable(node)) {
            return false;
        }
        Action action = new SiteNodeAction(context, Type.NODE_DELETE, node);
        return brix.getAuthorizationStrategy().isActionAuthorized(action);
    }
View Full Code Here

    public boolean canEditNode(BrixNode node, Context context) {
        if (!isNodeEditable(node)) {
            return false;
        }
        Action action = new SiteNodeAction(context, Type.NODE_EDIT, node);
        return brix.getAuthorizationStrategy().isActionAuthorized(action);
    }
View Full Code Here

    public boolean canRenameNode(BrixNode node, Context context) {
        if (!isNodeEditable(node)) {
            return false;
        }
        Action action = new SiteNodeAction(context, Type.NODE_DELETE, node);
        return brix.getAuthorizationStrategy().isActionAuthorized(action);
    }
View Full Code Here

TOP

Related Classes of org.brixcms.auth.Action

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.