Search in sources :

Example 1 with GWTJahiaPublicationInfo

use of org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo in project jahia by Jahia.

the class NodeHelper method populatePublicationInfos.

private void populatePublicationInfos(GWTJahiaNode n, JCRNodeWrapper node) {
    if (logger.isDebugEnabled()) {
        logger.debug("populate publication infos for {}", node.getPath());
    }
    try {
        JCRSiteNode siteNode = node.getResolveSite();
        if (siteNode != null) {
            JCRSessionWrapper session = node.getSession();
            Map<String, GWTJahiaPublicationInfo> aggregatedPublicationInfosByLanguage = publication.getAggregatedPublicationInfosByLanguage(node, siteNode.getLanguages(), session, true, true);
            n.setAggregatedPublicationInfos(aggregatedPublicationInfosByLanguage);
            Map<String, List<GWTJahiaPublicationInfo>> fullPublicationInfosByLanguage = publication.getFullPublicationInfosByLanguage(Arrays.asList(node.getIdentifier()), siteNode.getLanguages(), session, false);
            n.setFullPublicationInfos(fullPublicationInfosByLanguage);
            // populate publication info
            for (Map.Entry<String, List<GWTJahiaPublicationInfo>> entry : fullPublicationInfosByLanguage.entrySet()) {
                GWTJahiaPublicationInfo pubInfo = aggregatedPublicationInfosByLanguage.get(entry.getKey());
                if (pubInfo != null && !entry.getValue().isEmpty()) {
                    GWTJahiaPublicationInfo fullPubInfo = entry.getValue().iterator().next();
                    pubInfo.setWorkflowGroup(fullPubInfo.getWorkflowGroup());
                    pubInfo.setWorkflowDefinition(fullPubInfo.getWorkflowDefinition());
                }
            }
        }
    } catch (UnsupportedRepositoryOperationException e) {
        // do nothing
        logger.debug(e.getMessage());
    } catch (RepositoryException e) {
        logger.error(e.getMessage(), e);
    } catch (GWTJahiaServiceException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : GWTJahiaServiceException(org.jahia.ajax.gwt.client.service.GWTJahiaServiceException) JCRSiteNode(org.jahia.services.content.decorator.JCRSiteNode) GWTJahiaPublicationInfo(org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo)

Example 2 with GWTJahiaPublicationInfo

use of org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo in project jahia by Jahia.

the class PublicationHelper method convert.

private static GWTJahiaPublicationInfo convert(ComplexPublicationService.FullPublicationInfo info, JCRSessionWrapper session) {
    GWTJahiaPublicationInfo gwtInfo = new GWTJahiaPublicationInfo(info.getNodeIdentifier(), info.getPublicationStatus());
    gwtInfo.setPath(info.getNodePath());
    gwtInfo.setTitle(info.getNodeTitle());
    gwtInfo.setNodetype(info.getNodeType() != null ? info.getNodeType().getLabel(session.getLocale()) : "");
    if (info.getNodeType().isNodeType("jnt:page")) {
        gwtInfo.set("isPage", Boolean.TRUE);
    }
    gwtInfo.setMainUUID(info.getPublicationRootNodeIdentifier());
    gwtInfo.setMainPath(info.getPublicationRootNodePath());
    gwtInfo.setMainPathIndex(info.getPublicationRootNodePathIndex());
    gwtInfo.setLocked(info.isLocked());
    gwtInfo.setWorkInProgress(info.isWorkInProgress());
    gwtInfo.setWorkflowTitle(info.getWorkflowTitle());
    gwtInfo.setWorkflowDefinition(info.getWorkflowDefinition());
    gwtInfo.setWorkflowGroup(info.getWorkflowGroup());
    gwtInfo.setIsAllowedToPublishWithoutWorkflow(info.isAllowedToPublishWithoutWorkflow());
    gwtInfo.setLanguage(info.getLanguage());
    gwtInfo.setI18NUuid(info.getTranslationNodeIdentifier());
    Collection<String> deletedTranslationNodeIdentifiers = info.getDeletedTranslationNodeIdentifiers();
    if (!deletedTranslationNodeIdentifiers.isEmpty()) {
        gwtInfo.setDeletedI18nUuid(StringUtils.join(deletedTranslationNodeIdentifiers, ' '));
    }
    gwtInfo.setIsNonRootMarkedForDeletion(info.isNonRootMarkedForDeletion());
    return gwtInfo;
}
Also used : GWTJahiaPublicationInfo(org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo)

Example 3 with GWTJahiaPublicationInfo

use of org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo in project jahia by Jahia.

the class PublicationHelper method getAggregatedPublicationInfosByLanguage.

/**
 * Get the publication status information for a particular path.
 *
 * @param node node to get publication info for
 * @param currentUserSession
 * @param includeReferences
 * @param includeSubNodes
 * @return a GWTJahiaPublicationInfo object filled with the right status for the publication state of this path
 * @throws org.jahia.ajax.gwt.client.service.GWTJahiaServiceException in case of any RepositoryException
 */
public Map<String, GWTJahiaPublicationInfo> getAggregatedPublicationInfosByLanguage(JCRNodeWrapper node, Set<String> languages, JCRSessionWrapper currentUserSession, boolean includeReferences, boolean includeSubNodes) throws GWTJahiaServiceException {
    try {
        HashMap<String, GWTJahiaPublicationInfo> infos = new HashMap<String, GWTJahiaPublicationInfo>(languages.size());
        for (String language : languages) {
            ComplexPublicationService.AggregatedPublicationInfo aggregatedInfo = complexPublicationService.getAggregatedPublicationInfo(node.getIdentifier(), language, includeSubNodes, includeReferences, currentUserSession);
            GWTJahiaPublicationInfo gwtInfo = new GWTJahiaPublicationInfo(node.getIdentifier(), aggregatedInfo.getPublicationStatus());
            gwtInfo.setLocked(aggregatedInfo.isLocked());
            gwtInfo.setWorkInProgress(aggregatedInfo.isWorkInProgress());
            gwtInfo.setIsAllowedToPublishWithoutWorkflow(aggregatedInfo.isAllowedToPublishWithoutWorkflow());
            gwtInfo.setIsNonRootMarkedForDeletion(aggregatedInfo.isNonRootMarkedForDeletion());
            infos.put(language, gwtInfo);
        }
        return infos;
    } catch (Exception e) {
        logger.error("Cannot get publication status for node " + node.getPath() + ". Cause: " + e.getLocalizedMessage(), e);
        throw new GWTJahiaServiceException("Cannot get publication status for node " + node.getPath() + ". Cause: " + e.getLocalizedMessage(), e);
    }
}
Also used : GWTJahiaServiceException(org.jahia.ajax.gwt.client.service.GWTJahiaServiceException) GWTJahiaPublicationInfo(org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo) GWTJahiaServiceException(org.jahia.ajax.gwt.client.service.GWTJahiaServiceException) SchedulerException(org.quartz.SchedulerException) RepositoryException(javax.jcr.RepositoryException)

Example 4 with GWTJahiaPublicationInfo

use of org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo in project jahia by Jahia.

the class SwitchModeActionItem method handleNewLinkerSelection.

public void handleNewLinkerSelection() {
    if (showOpenInNewWindowSubmenu) {
        Menu m = new Menu();
        MenuItem menuItem = new MenuItem(Messages.get("label.openInNewWindow", "Open in new window"));
        menuItem.setIcon(ToolbarIconProvider.getInstance().getIcon("openWindow"));
        menuItem.addStyleName(getGwtToolbarItem().getClassName() + "-openWindow");
        menuItem.addSelectionListener(new SelectionListener<MenuEvent>() {

            @Override
            public void componentSelected(MenuEvent ce) {
                onComponentSelection(true);
            }
        });
        m.add(menuItem);
        setSubMenu(m);
    }
    final String workspace = getPropertyValue(getGwtToolbarItem(), "workspace");
    if ((linker instanceof EditLinker && ((EditLinker) linker).isInSettingsPage()) || !hasPermission(linker.getSelectionContext().getMainNode()) || !isNodeTypeAllowed(linker.getSelectionContext().getMainNode())) {
        setEnabled(false);
    } else {
        if (workspace.equalsIgnoreCase("live")) {
            final GWTJahiaNode node = linker.getSelectionContext().getMainNode();
            if (node == null) {
                setEnabled(false);
            } else {
                GWTJahiaPublicationInfo publicationInfo = node.getAggregatedPublicationInfo() != null ? node.getAggregatedPublicationInfo() : node.getQuickPublicationInfo();
                if (publicationInfo.getStatus() == GWTJahiaPublicationInfo.NOT_PUBLISHED || publicationInfo.getStatus() == GWTJahiaPublicationInfo.UNPUBLISHED) {
                    setEnabled(false);
                } else {
                    setEnabled(true);
                }
            }
        } else {
            setEnabled(true);
        }
    }
}
Also used : EditLinker(org.jahia.ajax.gwt.client.widget.edit.EditLinker) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) GWTJahiaPublicationInfo(org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo) MenuItem(com.extjs.gxt.ui.client.widget.menu.MenuItem) Menu(com.extjs.gxt.ui.client.widget.menu.Menu) MenuEvent(com.extjs.gxt.ui.client.event.MenuEvent)

Example 5 with GWTJahiaPublicationInfo

use of org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo in project jahia by Jahia.

the class PublishActionItem method handleNewLinkerSelection.

@Override
public void handleNewLinkerSelection() {
    setEnabled(false);
    this.getGwtToolbarItem().setHideWhenDisabled(false);
    LinkerSelectionContext ctx = linker.getSelectionContext();
    boolean hasOnlyOneLanguage = JahiaGWTParameters.getSiteLanguages().size() == 1;
    GWTJahiaNode gwtJahiaNode = ctx.getSingleSelection();
    if (allLanguages) {
        if (hasOnlyOneLanguage) {
            setEnabled(false);
            return;
        }
        if (ctx.getMultipleSelection() != null && ctx.getMultipleSelection().size() > 1) {
            if (isNotChildOfMarkedForDeletion(ctx) && hasPermission(ctx.getSelectionPermissions()) && supportPublication(ctx.getMultipleSelection()) && isNodeTypeAllowed(ctx.getMultipleSelection())) {
                setEnabled(true);
                if (allSubTree) {
                    updateTitle(Messages.get("label.publish.all.selected.items.all.languages", "Publish all under selected items in all languages"));
                } else {
                    updateTitle(Messages.get(checkForUnpublication ? "label.unPublish.selected.items.all.languages" : "label.publish.selected.items.all.languages", checkForUnpublication ? "Unpublish all selected items in all languages" : "Publish all selected items in all languages"));
                }
            }
        } else {
            if (isWorkInProgress(gwtJahiaNode)) {
                setEnabled(false);
            } else if (gwtJahiaNode != null) {
                String title;
                if (allSubTree) {
                    title = Messages.getWithArgs("label.publishall.all.languages", "Publish all under {0} in all languages", new String[] { gwtJahiaNode.getDisplayName() });
                } else {
                    title = Messages.getWithArgs(checkForUnpublication ? "label.unPublish.languages" : "label.publish.languages", checkForUnpublication ? "Unpublish {0} in all languages" : "Publish {0} in all languages", new String[] { gwtJahiaNode.getDisplayName() });
                }
                updateItem(ctx, gwtJahiaNode, title);
            }
        }
    } else if (allSubTree) {
        if (ctx.getMultipleSelection() != null && ctx.getMultipleSelection().size() > 1) {
            if (isNotChildOfMarkedForDeletion(ctx) && hasPermission(ctx.getSelectionPermissions()) && supportPublication(ctx.getMultipleSelection()) && isNodeTypeAllowed(ctx.getMultipleSelection())) {
                setEnabled(true);
                updateTitle(Messages.get("label.publish.all.selected.items"));
            }
        } else {
            if (isWorkInProgress(gwtJahiaNode)) {
                setEnabled(false);
            } else if (gwtJahiaNode != null) {
                String title = Messages.get("label.publishall") + " " + gwtJahiaNode.getDisplayName() + " - " + JahiaGWTParameters.getLanguageDisplayName();
                updateItem(ctx, gwtJahiaNode, title);
            }
        }
    } else {
        if (ctx.getMultipleSelection() != null && ctx.getMultipleSelection().size() > 1) {
            if (isNotChildOfMarkedForDeletion(ctx) && hasPermission(ctx.getSelectionPermissions()) && supportPublication(ctx.getMultipleSelection()) && isNodeTypeAllowed(ctx.getMultipleSelection())) {
                setEnabled(true);
                updateTitle(getGwtToolbarItem().getTitle());
            }
        } else {
            if (isWorkInProgress(gwtJahiaNode)) {
                setEnabled(false);
            } else if (gwtJahiaNode != null && isNotChildOfMarkedForDeletion(ctx) && Boolean.TRUE.equals(gwtJahiaNode.get("supportsPublication")) && hasPermission(gwtJahiaNode) && isNodeTypeAllowed(gwtJahiaNode)) {
                setEnabled(true);
                if (!checkForUnpublication && gwtJahiaNode.getAggregatedPublicationInfo() != null) {
                    GWTJahiaPublicationInfo info = gwtJahiaNode.getAggregatedPublicationInfo();
                    GWTJahiaWorkflowDefinition def = null;
                    if (gwtJahiaNode.getWorkflowInfo() != null) {
                        def = gwtJahiaNode.getWorkflowInfo().getPossibleWorkflows().get(new GWTJahiaWorkflowType("publish"));
                    }
                    setEnabled(info.isPublishable() && (def != null || info.isAllowedToPublishWithoutWorkflow()));
                }
                if (gwtJahiaNode.isFile() || gwtJahiaNode.isNodeType("nt:folder")) {
                    updateTitle(getGwtToolbarItem().getTitle() + " " + gwtJahiaNode.getDisplayName());
                } else {
                    updateTitle(getGwtToolbarItem().getTitle() + " " + gwtJahiaNode.getDisplayName() + " - " + JahiaGWTParameters.getLanguageDisplayName());
                }
            }
        }
    }
    if (checkForUnpublication) {
        if (ctx.getMultipleSelection() != null && ctx.getMultipleSelection().size() > 1) {
            for (GWTJahiaNode node : ctx.getMultipleSelection()) {
                GWTJahiaPublicationInfo publicationInfo = node.getAggregatedPublicationInfo() != null ? node.getAggregatedPublicationInfo() : node.getQuickPublicationInfo();
                if (publicationInfo != null && !publicationInfo.isUnpublishable()) {
                    setEnabled(false);
                    break;
                }
            }
        } else if (gwtJahiaNode != null) {
            GWTJahiaPublicationInfo publicationInfo = gwtJahiaNode.getAggregatedPublicationInfo() != null ? gwtJahiaNode.getAggregatedPublicationInfo() : gwtJahiaNode.getQuickPublicationInfo();
            if (publicationInfo != null && !publicationInfo.isUnpublishable()) {
                setEnabled(false);
            }
        }
    }
}
Also used : GWTJahiaWorkflowDefinition(org.jahia.ajax.gwt.client.data.workflow.GWTJahiaWorkflowDefinition) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) GWTJahiaWorkflowType(org.jahia.ajax.gwt.client.data.workflow.GWTJahiaWorkflowType) LinkerSelectionContext(org.jahia.ajax.gwt.client.widget.LinkerSelectionContext) GWTJahiaPublicationInfo(org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo)

Aggregations

GWTJahiaPublicationInfo (org.jahia.ajax.gwt.client.data.publication.GWTJahiaPublicationInfo)17 GWTJahiaNode (org.jahia.ajax.gwt.client.data.node.GWTJahiaNode)5 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)4 RowLayout (com.extjs.gxt.ui.client.widget.layout.RowLayout)4 Button (com.extjs.gxt.ui.client.widget.button.Button)3 BorderLayoutData (com.extjs.gxt.ui.client.widget.layout.BorderLayoutData)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 XTemplate (com.extjs.gxt.ui.client.core.XTemplate)2 ModelData (com.extjs.gxt.ui.client.data.ModelData)2 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)2 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)2 AbstractImagePrototype (com.google.gwt.user.client.ui.AbstractImagePrototype)2 EmptyLinker (org.jahia.ajax.gwt.client.EmptyLinker)2 BaseAsyncCallback (org.jahia.ajax.gwt.client.core.BaseAsyncCallback)2 GWTJahiaNodeProperty (org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeProperty)2 GWTJahiaWorkflowDefinition (org.jahia.ajax.gwt.client.data.workflow.GWTJahiaWorkflowDefinition)2 GWTJahiaServiceException (org.jahia.ajax.gwt.client.service.GWTJahiaServiceException)2 ManagerLinker (org.jahia.ajax.gwt.client.widget.content.ManagerLinker)2 EngineCards (org.jahia.ajax.gwt.client.widget.contentengine.EngineCards)2 EngineContainer (org.jahia.ajax.gwt.client.widget.contentengine.EngineContainer)2