Package org.gatein.mop.api.workspace

Examples of org.gatein.mop.api.workspace.Navigation


         toUpdate.add(source.handle);
      }
      @Override
      public void onMove(NodeContext<N> target, NodeContext<N> from, NodeContext<N> to, NodeContext<N> previous) throws NavigationServiceException
      {
         Navigation sourceNav = session.findObjectById(ObjectType.NAVIGATION, target.data.id);
         Navigation fromNav = session.findObjectById(ObjectType.NAVIGATION, from.data.id);
         Navigation toNav = session.findObjectById(ObjectType.NAVIGATION, to.data.id);

         //
         toEvict.add(sourceNav.getObjectId());
         toEvict.add(fromNav.getObjectId());
         toEvict.add(toNav.getObjectId());
         int index;
         if (previous != null)
         {
            Navigation previousNav = session.findObjectById(ObjectType.NAVIGATION, previous.data.id);
            index = previousNav.getIndex() + 1;
         }
         else
         {
            index = 0;
         }
View Full Code Here


         toUpdate.add(from.handle);
         toUpdate.add(to.handle);
      }
      public void onRename(NodeContext<N> target, NodeContext<N> parent, String name) throws NavigationServiceException
      {
         Navigation sourceNav = session.findObjectById(ObjectType.NAVIGATION, target.data.id);
         Navigation parentNav = session.findObjectById(ObjectType.NAVIGATION, parent.data.id);

         //
         toEvict.add(sourceNav.getObjectId());
         toEvict.add(parentNav.getObjectId());
         sourceNav.setName(name);

         //
         target.data = new NodeData(sourceNav);
         target.name = null;
View Full Code Here

         pageRef
      );

      //
      String parentId;
      Navigation parent = navigation.getParent();
      if (parent != null)
      {
         parentId = parent.getObjectId();
      }
      else
      {
         parentId = null;
      }
View Full Code Here

        ObjectType<Site> objectType = objectType(type);
        Collection<Site> sites = session.getWorkspace().getSites(objectType);

        List<NavigationContext> navigations = new LinkedList<NavigationContext>();
        for (Site site : sites) {
            Navigation defaultNavigation = site.getRootNavigation().getChild("default");
            if (defaultNavigation != null) {
                SiteKey key = new SiteKey(type, site.getName());
                navigations.add(new NavigationContext(new NavigationData(key, defaultNavigation)));
            }
        }
View Full Code Here

        if (site == null) {
            throw new NavigationServiceException(NavigationError.NAVIGATION_NO_SITE);
        }

        //
        Navigation rootNode = site.getRootNavigation();

        //
        Navigation defaultNode = rootNode.getChild("default");
        if (defaultNode == null) {
            defaultNode = rootNode.addChild("default");
        }

        //
        NavigationState state = navigation.state;
        if (state != null) {
            Integer priority = state.getPriority();
            defaultNode.getAttributes().setValue(MappedAttributes.PRIORITY, priority);
        }

        //
        dataCache.removeNavigationData(session, navigation.key);
View Full Code Here

        if (site == null) {
            throw new NavigationServiceException(NavigationError.NAVIGATION_NO_SITE);
        }

        //
        Navigation rootNode = site.getRootNavigation();
        Navigation defaultNode = rootNode.getChild("default");

        //
        if (defaultNode != null) {
            // Invalidate cache
            dataCache.removeNavigation(navigation.key);
            String rootId = navigation.data.rootId;
            if (rootId != null) {
                dataCache.removeNodes(Collections.singleton(rootId));
            }

            // Destroy nav
            defaultNode.destroy();

            // Update state
            navigation.data = null;

            //
View Full Code Here

        }

        @Override
        public void onCreate(NodeContext<N> target, NodeContext<N> parent, NodeContext<N> previous, String name)
                throws NavigationServiceException {
            Navigation parentNav = session.findObjectById(ObjectType.NAVIGATION, parent.data.id);
            toEvict.add(parentNav.getObjectId());
            int index = 0;
            if (previous != null) {
                Navigation previousNav = session.findObjectById(ObjectType.NAVIGATION, previous.data.id);
                index = previousNav.getIndex() + 1;
            }

            //
            Navigation sourceNav = parentNav.addChild(index, name);

            //
            parent.data = new NodeData(parentNav);

            // Save the handle
            toPersist.put(target.handle, sourceNav.getObjectId());

            //
            target.data = new NodeData(sourceNav);
            target.handle = target.data.id;
            target.name = null;
View Full Code Here

            toUpdate.add(target.handle);
        }

        @Override
        public void onDestroy(NodeContext<N> target, NodeContext<N> parent) {
            Navigation parentNav = session.findObjectById(ObjectType.NAVIGATION, parent.data.id);
            Navigation sourceNav = session.findObjectById(ObjectType.NAVIGATION, target.data.id);

            //
            toEvict.add(parentNav.getObjectId());
            sourceNav.destroy();

            //
            parent.data = new NodeData(parentNav);
            toUpdate.add(parent.handle);
View Full Code Here

            }
        }

        @Override
        public void onUpdate(NodeContext<N> source, NodeState state) throws NavigationServiceException {
            Navigation sourceNav = session.findObjectById(ObjectType.NAVIGATION, source.data.id);

            //
            toEvict.add(sourceNav.getObjectId());
            Workspace workspace = sourceNav.getSite().getWorkspace();
            PageKey reference = state.getPageRef();
            if (reference != null) {
                ObjectType<? extends Site> siteType = Utils.objectType(reference.getSite().getType());
                Site site = workspace.getSite(siteType, reference.getSite().getName());
                org.gatein.mop.api.workspace.Page target = site.getRootPage().getChild("pages").getChild(reference.getName());
                PageLink link = sourceNav.linkTo(ObjectType.PAGE_LINK);
                link.setPage(target);
            } else {
                PageLink link = sourceNav.linkTo(ObjectType.PAGE_LINK);
                link.setPage(null);
            }

            //
            Described described = sourceNav.adapt(Described.class);
            described.setName(state.getLabel());

            //
            if (!sourceNav.isAdapted(RestrictAccess.class)) {
                // if RestrictAccess is not on the node yet, then it has a legacy Visible
                // so, we remove the Visible and replace with a RestrictAccess
                ChromatticSession chromatticSession = session.getManager().getLifeCycle().getContext().getSession();
                if (sourceNav.isAdapted(Visible.class)) {
                    chromatticSession.remove(sourceNav.adapt(Visible.class));
                }
                RestrictAccess restrictAccess = chromatticSession.create(RestrictAccess.class);
                chromatticSession.setEmbedded(sourceNav, RestrictAccess.class, restrictAccess);
            }

            //
            RestrictAccess restrictAccess = sourceNav.adapt(RestrictAccess.class);
            restrictAccess.setVisibility(state.getVisibility());
            restrictAccess.setStartPublicationDate(state.getStartPublicationDate());
            restrictAccess.setEndPublicationDate(state.getEndPublicationDate());
            restrictAccess.setRestrictOutsidePublicationWindow(state.isRestrictOutsidePublicationWindow());

            // Sync the attributes
            Attributes attrs = sourceNav.getAttributes();
            AttributesState.sync(state.getAttributesState(), CUSTOM_NODE_ATTRIBUTE_PREFIX, attrs);
            attrs.setValue(MappedAttributes.ICON, state.getIcon());

            //
            source.data = new NodeData(sourceNav);
View Full Code Here

        }

        @Override
        public void onMove(NodeContext<N> target, NodeContext<N> from, NodeContext<N> to, NodeContext<N> previous)
                throws NavigationServiceException {
            Navigation sourceNav = session.findObjectById(ObjectType.NAVIGATION, target.data.id);
            Navigation fromNav = session.findObjectById(ObjectType.NAVIGATION, from.data.id);
            Navigation toNav = session.findObjectById(ObjectType.NAVIGATION, to.data.id);

            //
            toEvict.add(sourceNav.getObjectId());
            toEvict.add(fromNav.getObjectId());
            toEvict.add(toNav.getObjectId());
            int index;
            if (previous != null) {
                Navigation previousNav = session.findObjectById(ObjectType.NAVIGATION, previous.data.id);
                index = previousNav.getIndex() + 1;
            } else {
                index = 0;
            }
            toNav.getChildren().add(index, sourceNav);
View Full Code Here

TOP

Related Classes of org.gatein.mop.api.workspace.Navigation

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.