@Override public void saveLegacyPortletConfiguration(final PortletConfiguration portletConfiguration) { notNull("portletConfiguration", portletConfiguration); //check the PC exists! final Long id = portletConfiguration.getId(); final PortletConfiguration pc = portletConfigurationManager.getByPortletId(id); if (pc != null) { portletConfigurationManager.store(portletConfiguration); } else { throw new IllegalStateException("Trying to update portletConfiguration that doesn't exist with id '" + id + "'."); } }
@Override public List<List<PortletConfiguration>> getPortletConfigurations(final Long portalPageId) { final List<List<PortletConfiguration>> columns = new ArrayList<List<PortletConfiguration>>(); final List<PortletConfiguration> portletConfigurations = portletConfigurationManager.getByPortalPage(portalPageId); final PortalPage portalPage = getPortalPageById(portalPageId); if ((portalPage != null) && !portletConfigurations.isEmpty()) { initColumns(portalPage.getLayout().getNumberOfColumns(), columns); for (final PortletConfiguration portletConfiguration : portletConfigurations) { final int column = portletConfiguration.getColumn(); columns.get(column).add(portletConfiguration); } //Once all portlet configs are inserted, sort each column then make it an unmodifieable list. for (int i = 0; i < columns.size(); i++) { final List<PortletConfiguration> column = columns.get(i); Collections.sort(column); columns.set(i, Collections.<PortletConfiguration> unmodifiableList(column)); } } return Collections.unmodifiableList(columns); }
@Override public void delete(final Long portalPageId) { notNull("portalPageId", portalPageId); // // delete all PortletConfigs associated with the page first. The underlying portletConfigurationManager/Store // also cleans associated propertySets // final List<PortletConfiguration> portlectConfigurations = portletConfigurationManager.getByPortalPage(portalPageId); for (final PortletConfiguration portletConfiguration : portlectConfigurations) { portletConfigurationManager.delete(portletConfiguration); } final SharedEntity identifier = new SharedEntity.Identifier(portalPageId, PortalPage.ENTITY_TYPE, (ApplicationUser) null); portalPageStore.delete(portalPageId); shareManager.deletePermissions(identifier); indexer.deIndex(identifier).await(); eventPublisher.publish(new DashboardDeleted(identifier, authenticationContext.getUser())); }
portletConfigurationManager.store(portletConfiguration); log.info("Finished upgrading. (" + portlet.getKey() + ")");
private void clonePortletsFromOnePageToAnother(final ApplicationUser owner, final PortalPage clonePortalPage, final PortalPage targetPortalPage) { notNull("owner", owner); notNull("clonePortalPage", clonePortalPage); notNull("targetPortalPage", targetPortalPage); final GadgetPermissionManager gadgetPermissionManager = getGadgetPermissionManager(); final List<PortletConfiguration> pcsToClone = portletConfigurationManager.getByPortalPage(clonePortalPage.getId()); for (final PortletConfiguration pc : pcsToClone) { Option<PluginGadgetSpec> pluginGadgetSpec = gadgetPermissionManager.getPluginGadgetSpec(pc.getOpenSocialSpecUri().getOrNull()); final boolean userHasPermissionToOpenSocialGadget = (pluginGadgetSpec.isDefined()) && ALLOW.equals(gadgetPermissionManager.voteOn(pluginGadgetSpec.get(), owner)); final boolean isDashboardItem = pc.getCompleteModuleKey().isDefined(); if (isDashboardItem || userHasPermissionToOpenSocialGadget) { portletConfigurationManager.addDashBoardItem( targetPortalPage.getId(), pc.getColumn(), pc.getRow(), pc.getOpenSocialSpecUri(), pc.getColor(), pc.getUserPrefs(), pc.getCompleteModuleKey()); } } }