Examples of POMSessionManager


Examples of org.exoplatform.portal.pom.config.POMSessionManager

        InputStream inputStream = attachment.getStream();
        if (inputStream == null)
            throw new OperationException(operationContext.getOperationName(), "No data stream available for import.");

        final POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
        POMSession session = mgr.getSession();
        if (session == null)
            throw new OperationException(operationName, "MOP session was null");

        Workspace workspace = session.getWorkspace();
        if (workspace == null)
            throw new OperationException(operationName, "MOP workspace was null");

        DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
        if (dataStorage == null)
            throw new OperationException(operationName, "DataStorage was null");

        PageService pageService = operationContext.getRuntimeContext().getRuntimeComponent(PageService.class);
        if (pageService == null)
            throw new OperationException(operationName, "PageService was null");

        NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
        if (navigationService == null)
            throw new OperationException(operationName, "Navigation service was null");

        DescriptionService descriptionService = operationContext.getRuntimeContext().getRuntimeComponent(
                DescriptionService.class);
        if (descriptionService == null)
            throw new OperationException(operationName, "Description service was null");

        String mode = operationContext.getAttributes().getValue("importMode");
        if (mode == null || "".equals(mode))
            mode = "merge";

        ImportMode importMode;
        try {
            importMode = ImportMode.valueOf(mode.trim().toUpperCase());
        } catch (Exception e) {
            throw new OperationException(operationName, "Unknown importMode " + mode);
        }

        Map<SiteKey, MopImport> importMap = new HashMap<SiteKey, MopImport>();
        final NonCloseableZipInputStream zis = new NonCloseableZipInputStream(inputStream);
        ZipEntry entry;
        boolean empty = false;
        try {
            log.info("Preparing data for import.");
            while ((entry = zis.getNextEntry()) != null) {
                // Skip directories
                if (entry.isDirectory())
                    continue;
                // Skip empty entries (this allows empty zip files to not cause exceptions).
                empty = entry.getName().equals("");
                if (empty)
                    continue;

                // Parse zip entry
                String[] parts = parseEntry(entry);
                SiteKey siteKey = Utils.siteKey(parts[0], parts[1]);
                String file = parts[2];

                MopImport mopImport = importMap.get(siteKey);
                if (mopImport == null) {
                    mopImport = new MopImport();
                    importMap.put(siteKey, mopImport);
                }

                if (SiteLayoutExportTask.FILES.contains(file)) {
                    // Unmarshal site layout data
                    Marshaller<PortalConfig> marshaller = operationContext.getBindingProvider().getMarshaller(
                            PortalConfig.class, ContentType.XML);
                    PortalConfig portalConfig = marshaller.unmarshal(zis);
                    portalConfig.setType(siteKey.getTypeName());
                    if (!portalConfig.getName().equals(siteKey.getName())) {
                        throw new OperationException(operationName,
                                "Name of site does not match that of the zip entry site name.");
                    }

                    // Add import task to run later
                    mopImport.siteTask = new SiteLayoutImportTask(portalConfig, siteKey, dataStorage);
                } else if (file.equals(PageExportTask.FILE)) {
                    // Unmarshal page data
                    Marshaller<Page.PageSet> marshaller = operationContext.getBindingProvider().getMarshaller(
                            Page.PageSet.class, ContentType.XML);
                    Page.PageSet pages = marshaller.unmarshal(zis);
                    for (Page page : pages.getPages()) {
                        page.setOwnerType(siteKey.getTypeName());
                        page.setOwnerId(siteKey.getName());
                    }

                    // Obtain the site from the session when it's needed.
                    MOPSiteProvider siteProvider = new MOPSiteProvider() {
                        @Override
                        public Site getSite(SiteKey siteKey) {
                            return mgr.getSession().getWorkspace()
                                    .getSite(Utils.getObjectType(siteKey.getType()), siteKey.getName());
                        }
                    };
                    // Add import task to run later.
                    mopImport.pageTask = new PageImportTask(pages, siteKey, dataStorage, pageService, siteProvider);
View Full Code Here

Examples of org.exoplatform.portal.pom.config.POMSessionManager

        ObjectType<Site> objectType = Utils.getObjectType(Utils.getSiteType(siteType));
        if (objectType == null) {
            throw new ResourceNotFoundException("No site type found for " + siteType);
        }

        POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
        POMSession session = mgr.getSession();
        if (session == null)
            throw new OperationException(operationName, "MOP session was null");

        Workspace workspace = session.getWorkspace();
        if (workspace == null)
View Full Code Here

Examples of org.exoplatform.portal.pom.config.POMSessionManager

        InputStream inputStream = attachment.getStream();
        if (inputStream == null)
            throw new OperationException(operationContext.getOperationName(), "No data stream available for import.");

        final POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
        POMSession session = mgr.getSession();
        if (session == null)
            throw new OperationException(operationName, "MOP session was null");

        Workspace workspace = session.getWorkspace();
        if (workspace == null)
            throw new OperationException(operationName, "MOP workspace was null");

        DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
        if (dataStorage == null)
            throw new OperationException(operationName, "DataStorage was null");

        PageService pageService = operationContext.getRuntimeContext().getRuntimeComponent(PageService.class);
        if (pageService == null)
            throw new OperationException(operationName, "PageService was null");

        NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
        if (navigationService == null)
            throw new OperationException(operationName, "Navigation service was null");

        DescriptionService descriptionService = operationContext.getRuntimeContext().getRuntimeComponent(
                DescriptionService.class);
        if (descriptionService == null)
            throw new OperationException(operationName, "Description service was null");

        ChromatticManager chromatticManager = operationContext.getRuntimeContext().getRuntimeComponent(ChromatticManager.class);
        if (chromatticManager == null) throw new OperationException(operationName, "Chromattic manager was null");

        String mode = operationContext.getAttributes().getValue("importMode");
        if (mode == null || "".equals(mode))
            mode = "merge";

        ImportMode importMode;
        try {
            importMode = ImportMode.valueOf(mode.trim().toUpperCase());
        } catch (Exception e) {
            throw new OperationException(operationName, "Unknown importMode " + mode);
        }

        Map<SiteKey, MopImport> importMap = new HashMap<SiteKey, MopImport>();
        final NonCloseableZipInputStream zis = new NonCloseableZipInputStream(inputStream);
        ZipEntry entry;
        boolean empty = false;
        try {
            log.info("Preparing data for import.");
            while ((entry = zis.getNextEntry()) != null) {
                // Skip directories
                if (entry.isDirectory())
                    continue;
                // Skip empty entries (this allows empty zip files to not cause exceptions).
                empty = entry.getName().equals("");
                if (empty)
                    continue;

                // Parse zip entry
                String[] parts = parseEntry(entry);
                SiteKey siteKey = Utils.siteKey(parts[0], parts[1]);
                String file = parts[2];

                MopImport mopImport = importMap.get(siteKey);
                if (mopImport == null) {
                    mopImport = new MopImport();
                    importMap.put(siteKey, mopImport);
                }

                if (SiteLayoutExportTask.FILES.contains(file)) {
                    // Unmarshal site layout data
                    Marshaller<PortalConfig> marshaller = operationContext.getBindingProvider().getMarshaller(
                            PortalConfig.class, ContentType.XML);
                    PortalConfig portalConfig = marshaller.unmarshal(zis);
                    portalConfig.setType(siteKey.getTypeName());
                    if (!portalConfig.getName().equals(siteKey.getName())) {
                        throw new OperationException(operationName,
                                "Name of site does not match that of the zip entry site name.");
                    }

                    // Add import task to run later
                    mopImport.siteTask = new SiteLayoutImportTask(portalConfig, siteKey, dataStorage);
                } else if (file.equals(PageExportTask.FILE)) {
                    // Unmarshal page data
                    Marshaller<Page.PageSet> marshaller = operationContext.getBindingProvider().getMarshaller(
                            Page.PageSet.class, ContentType.XML);
                    Page.PageSet pages = marshaller.unmarshal(zis);
                    for (Page page : pages.getPages()) {
                        page.setOwnerType(siteKey.getTypeName());
                        page.setOwnerId(siteKey.getName());
                    }

                    // Obtain the site from the session when it's needed.
                    MOPSiteProvider siteProvider = new MOPSiteProvider() {
                        @Override
                        public Site getSite(SiteKey siteKey) {
                            return mgr.getSession().getWorkspace()
                                    .getSite(Utils.getObjectType(siteKey.getType()), siteKey.getName());
                        }
                    };
                    // Add import task to run later.
                    mopImport.pageTask = new PageImportTask(pages, siteKey, dataStorage, pageService, siteProvider);
View Full Code Here

Examples of org.exoplatform.portal.pom.config.POMSessionManager

        ObjectType<Site> objectType = Utils.getObjectType(Utils.getSiteType(siteType));
        if (objectType == null) {
            throw new ResourceNotFoundException("No site type found for " + siteType);
        }

        POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
        POMSession session = mgr.getSession();
        if (session == null)
            throw new OperationException(operationName, "MOP session was null");

        Workspace workspace = session.getWorkspace();
        if (workspace == null)
View Full Code Here

Examples of org.exoplatform.portal.pom.config.POMSessionManager

      if (attachment == null) throw new OperationException(operationContext.getOperationName(), "No attachment available for MOP import.");

      InputStream inputStream = attachment.getStream();
      if (inputStream == null) throw new OperationException(operationContext.getOperationName(), "No data stream available for import.");

      POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
      POMSession session = mgr.getSession();
      if (session == null) throw new OperationException(operationName, "MOP session was null");

      Workspace workspace = session.getWorkspace();
      if (workspace == null) throw new OperationException(operationName, "MOP workspace was null");
View Full Code Here

Examples of org.exoplatform.portal.pom.config.POMSessionManager

      if (objectType == null)
      {
         throw new ResourceNotFoundException("No site type found for " + siteType);
      }

      POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
      POMSession session = mgr.getSession();
      if (session == null) throw new OperationException(operationName, "MOP session was null");

      Workspace workspace = session.getWorkspace();
      if (workspace == null) throw new OperationException(operationName, "MOP workspace was null");
View Full Code Here

Examples of org.exoplatform.portal.pom.config.POMSessionManager

        InputStream inputStream = attachment.getStream();
        if (inputStream == null)
            throw new OperationException(operationContext.getOperationName(), "No data stream available for import.");

        final POMSessionManager mgr = operationContext.getRuntimeContext().getRuntimeComponent(POMSessionManager.class);
        POMSession session = mgr.getSession();
        if (session == null)
            throw new OperationException(operationName, "MOP session was null");

        Workspace workspace = session.getWorkspace();
        if (workspace == null)
            throw new OperationException(operationName, "MOP workspace was null");

        DataStorage dataStorage = operationContext.getRuntimeContext().getRuntimeComponent(DataStorage.class);
        if (dataStorage == null)
            throw new OperationException(operationName, "DataStorage was null");

        PageService pageService = operationContext.getRuntimeContext().getRuntimeComponent(PageService.class);
        if (pageService == null)
            throw new OperationException(operationName, "PageService was null");

        NavigationService navigationService = operationContext.getRuntimeContext().getRuntimeComponent(NavigationService.class);
        if (navigationService == null)
            throw new OperationException(operationName, "Navigation service was null");

        DescriptionService descriptionService = operationContext.getRuntimeContext().getRuntimeComponent(
                DescriptionService.class);
        if (descriptionService == null)
            throw new OperationException(operationName, "Description service was null");

        String mode = operationContext.getAttributes().getValue("importMode");
        if (mode == null || "".equals(mode))
            mode = "merge";

        ImportMode importMode;
        try {
            importMode = ImportMode.valueOf(mode.trim().toUpperCase());
        } catch (Exception e) {
            throw new OperationException(operationName, "Unknown importMode " + mode);
        }

        Map<SiteKey, MopImport> importMap = new HashMap<SiteKey, MopImport>();
        final NonCloseableZipInputStream zis = new NonCloseableZipInputStream(inputStream);
        ZipEntry entry;
        boolean empty = false;
        try {
            log.info("Preparing data for import.");
            while ((entry = zis.getNextEntry()) != null) {
                // Skip directories
                if (entry.isDirectory())
                    continue;
                // Skip empty entries (this allows empty zip files to not cause exceptions).
                empty = entry.getName().equals("");
                if (empty)
                    continue;

                // Parse zip entry
                String[] parts = parseEntry(entry);
                SiteKey siteKey = Utils.siteKey(parts[0], parts[1]);
                String file = parts[2];

                MopImport mopImport = importMap.get(siteKey);
                if (mopImport == null) {
                    mopImport = new MopImport();
                    importMap.put(siteKey, mopImport);
                }

                if (SiteLayoutExportTask.FILES.contains(file)) {
                    // Unmarshal site layout data
                    Marshaller<PortalConfig> marshaller = operationContext.getBindingProvider().getMarshaller(
                            PortalConfig.class, ContentType.XML);
                    PortalConfig portalConfig = marshaller.unmarshal(zis);
                    portalConfig.setType(siteKey.getTypeName());
                    if (!portalConfig.getName().equals(siteKey.getName())) {
                        throw new OperationException(operationName,
                                "Name of site does not match that of the zip entry site name.");
                    }

                    // Add import task to run later
                    mopImport.siteTask = new SiteLayoutImportTask(portalConfig, siteKey, dataStorage);
                } else if (file.equals(PageExportTask.FILE)) {
                    // Unmarshal page data
                    Marshaller<Page.PageSet> marshaller = operationContext.getBindingProvider().getMarshaller(
                            Page.PageSet.class, ContentType.XML);
                    Page.PageSet pages = marshaller.unmarshal(zis);
                    for (Page page : pages.getPages()) {
                        page.setOwnerType(siteKey.getTypeName());
                        page.setOwnerId(siteKey.getName());
                    }

                    // Obtain the site from the session when it's needed.
                    MOPSiteProvider siteProvider = new MOPSiteProvider() {
                        @Override
                        public Site getSite(SiteKey siteKey) {
                            return mgr.getSession().getWorkspace()
                                    .getSite(Utils.getObjectType(siteKey.getType()), siteKey.getName());
                        }
                    };
                    // Add import task to run later.
                    mopImport.pageTask = new PageImportTask(pages, siteKey, dataStorage, pageService, siteProvider);
View Full Code Here

Examples of org.exoplatform.portal.pom.config.POMSessionManager

             * (CacheService)container.getComponentInstanceOfType(CacheService.class); DistributedConsumerCache consumerCache =
             * new DistributedConsumerCache(cacheService); consumerRegistry.setConsumerCache(consumerCache); }
             */

            // create ConsumerStructureProvider and register it to listen to page events
            POMSessionManager sessionManager = (POMSessionManager) container
                    .getComponentInstanceOfType(POMSessionManager.class);
            PortalStructureAccess structureAccess = new MOPPortalStructureAccess(sessionManager);
            MOPConsumerStructureProvider structureprovider = new MOPConsumerStructureProvider(structureAccess);
            listenerService.addListener(EventType.PAGE_CREATED, structureprovider);
            listenerService.addListener(EventType.PAGE_DESTROYED, structureprovider);
View Full Code Here

Examples of org.exoplatform.portal.pom.config.POMSessionManager

             * (CacheService)container.getComponentInstanceOfType(CacheService.class); DistributedConsumerCache consumerCache =
             * new DistributedConsumerCache(cacheService); consumerRegistry.setConsumerCache(consumerCache); }
             */

            // create ConsumerStructureProvider and register it to listen to page events
            POMSessionManager sessionManager = (POMSessionManager) container
                    .getComponentInstanceOfType(POMSessionManager.class);
            PortalStructureAccess structureAccess = new MOPPortalStructureAccess(sessionManager);
            MOPConsumerStructureProvider structureprovider = new MOPConsumerStructureProvider(structureAccess);
            listenerService.addListener(EventType.PAGE_CREATED, structureprovider);
            listenerService.addListener(EventType.PAGE_DESTROYED, structureprovider);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.