Package org.brixcms.workspace

Examples of org.brixcms.workspace.Workspace


    private boolean checkSession(String workspaceId) {
        return brix.getWorkspaceManager().workspaceExists(workspaceId);
    }

    private String getDefaultWorkspaceName() {
        final Workspace workspace = brix.getConfig().getMapper().getWorkspaceForRequest(RequestCycle.get(), brix);
        return (workspace != null) ? workspace.getId() : null;
    }
View Full Code Here


                return new WorkspaceModel(listViewModel.getObject().get(index));
            }

            @Override
            protected void populateItem(final ListItem<Workspace> item) {
                Workspace workspace = item.getModelObject();
                final String name = SnapshotPlugin.get().getUserVisibleName(workspace, true);
                final String comment = SnapshotPlugin.get().getComment(workspace);

                Link<Object> link = new Link<Object>("browse") {
                    @Override
                    public void onClick() {
                        Workspace workspace = item.getModelObject();
                        model.setObject(workspace);
                    }
                };
                item.add(link);

                Link restoreLink = new Link<Void>("restore") {
                    @Override
                    public void onClick() {
                        Workspace target = ManageSnapshotsPanel.this.getModelObject();
                        SnapshotPlugin.get().restoreSnapshot(item.getModelObject(), target);
                        getSession().info(ManageSnapshotsPanel.this.getString("restoreSuccessful"));
                    }

                    /**
                     * Take care that restoring is only allowed in case the workspaces aren't the same
                     */
                    @Override
                    public boolean isEnabled() {
                        if (item.getModelObject().getId().equals(ManageSnapshotsPanel.this.getModelObject().getId())) {
                            return false;
                        }
                        return true;
                    }

                    @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);
            }
        };

View Full Code Here

    }

    private List<WorkspaceEntry> loadWorkspaces() {
        Brix brix = Brix.get();
        List<WorkspaceEntry> workspaces = new ArrayList<WorkspaceEntry>();
        Workspace currentWorkspace = getCurrentWorkspaceId() != null ? brix.getWorkspaceManager()
                .getWorkspace(getCurrentWorkspaceId()) : null;

        for (Plugin p : brix.getPlugins()) {
            List<Workspace> filtered = brix.filterVisibleWorkspaces(p.getWorkspaces(
                    currentWorkspace, true), Context.PRESENTATION);
View Full Code Here

    public void createSnapshot(Workspace workspace, String comment) {
        if (!SitePlugin.get().isSiteWorkspace(workspace)) {
            throw new IllegalStateException("Workspace must be a Site workspace");
        }

        Workspace targetWorkspace = brix.getWorkspaceManager().createWorkspace();
        targetWorkspace.setAttribute(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE);
        targetWorkspace.setAttribute(WORKSPACE_ATTRIBUTE_SITE_NAME, SitePlugin.get().getWorkspaceName(workspace));
        targetWorkspace.setAttribute(WORKSPACE_COMMENT, comment);

        setCreated(targetWorkspace, new Date());

        JcrSession originalSession = brix.getCurrentSession(workspace.getId());

        JcrSession targetSession = brix.getCurrentSession(targetWorkspace.getId());
        brix.clone(originalSession, targetSession);
    }
View Full Code Here

    private List<Workspace> getWorkspaces() {
        Brix brix = getBrix();
        List<Workspace> workspaces = new ArrayList<Workspace>();

        Workspace current = getModelObject();

        for (Plugin p : brix.getPlugins()) {
            List<Workspace> filtered = brix.filterVisibleWorkspaces(
                    p.getWorkspaces(current, false), Context.ADMINISTRATION);
            for (Workspace w : filtered) {
View Full Code Here

    private List<Workspace> getAvailableWorkspaces() {
        Brix brix = Brix.get();
        List<Workspace> workspaces = new ArrayList<Workspace>();

        Workspace current = getModelObject();

        for (Plugin p : brix.getPlugins()) {
            List<Workspace> filtered = brix.filterVisibleWorkspaces(
                    p.getWorkspaces(current, false), Context.ADMINISTRATION);
            for (Workspace w : filtered) {
View Full Code Here

        }
    }

    private boolean isCurrentWorkspaceValid() {
        WorkspaceManager manager = getBrix().getWorkspaceManager();
        Workspace workspace = getModelObject();
        return workspace != null && manager.workspaceExists(workspace.getId());
    }
View Full Code Here

            final String wn = getProperties().getJcrDefaultWorkspace();
            final SitePlugin sp = SitePlugin.get(brix);


            if (!sp.siteExists(wn, defaultState)) {
                Workspace w = sp.createSite(wn, defaultState);
                JcrSession session = brix.getCurrentSession(w.getId());

                session.importXML("/", getClass().getResourceAsStream("workspace.xml"),
                        ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);

                brix.initWorkspace(w, session);
View Full Code Here

                workspaceModel)};
        return Arrays.asList(tabs);
    }

    public void createPrototype(Workspace originalWorkspace, String prototypeName) {
        Workspace workspace = brix.getWorkspaceManager().createWorkspace();
        workspace.setAttribute(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE);
        setPrototypeName(workspace, prototypeName);

        JcrSession originalSession = brix.getCurrentSession(originalWorkspace.getId());
        JcrSession destSession = brix.getCurrentSession(workspace.getId());
        brix.clone(originalSession, destSession);
    }
View Full Code Here

    public void createPrototype(List<JcrNode> nodes, String prototypeName) {
        if (nodes.isEmpty()) {
            throw new IllegalStateException("Node list can not be empty.");
        }
        Workspace workspace = brix.getWorkspaceManager().createWorkspace();
        workspace.setAttribute(Brix.WORKSPACE_ATTRIBUTE_TYPE, WORKSPACE_TYPE);
        setPrototypeName(workspace, prototypeName);

        JcrSession destSession = brix.getCurrentSession(workspace.getId());

        JcrUtil.cloneNodes(nodes, destSession.getRootNode());
        destSession.save();
    }
View Full Code Here

TOP

Related Classes of org.brixcms.workspace.Workspace

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.