Package org.brixcms.plugin.snapshot.auth

Examples of org.brixcms.plugin.snapshot.auth.RestoreSnapshotAction


                    }

                    @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

TOP

Related Classes of org.brixcms.plugin.snapshot.auth.RestoreSnapshotAction

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.