private LocalDashboardItemModuleId getLocalDashboardItemModuleId(final PortletConfiguration portletConfiguration) { final ModuleCompleteKey fullModuleKey = portletConfiguration.getCompleteModuleKey().get(); final Option<OpenSocialDashboardItemModuleId> openSocialId = portletConfiguration.getOpenSocialSpecUri().map( new Function<URI, OpenSocialDashboardItemModuleId>() { @Override public OpenSocialDashboardItemModuleId apply(final URI openSocialSpecUri) { return new OpenSocialDashboardItemModuleId(openSocialSpecUri); } }); return new LocalDashboardItemModuleId(fullModuleKey, openSocialId); }
private void removeDashboardItemProperties(final PortletConfiguration portletConfiguration) { if (isLocalDashboardItemWithoutReplacementUri(portletConfiguration.getOpenSocialSpecUri(), portletConfiguration.getCompleteModuleKey())) { removeLocalDashboardItemPreferences(portletConfiguration.getId()); } else { removeOpenSocialGadgetPreferences(portletConfiguration.getId()); } }
@Override public DashboardItemState apply(final PortletConfiguration portletConfiguration) { final Option<URI> openSocialSpecUri = portletConfiguration.getOpenSocialSpecUri(); final Option<ModuleCompleteKey> moduleKey = portletConfiguration.getCompleteModuleKey(); // The case when dashboard-item replaces an open-social based gadget if (openSocialSpecUri.isDefined() && moduleKey.isDefined()) { return createLocalDashboardItem(portletConfiguration); } // the case when we simply add a dashboard-item to the dashboard else if (moduleKey.isDefined()) { return createLocalDashboardItem(portletConfiguration); } // gadget else if (openSocialSpecUri.isDefined()) { return createOpenSocialGadget(portletConfiguration, openSocialSpecUri.get()); } // should not happen else { final URI uriToLegacyGadget = URI.create("/invalid/legacy/portlet/Please_remove_this_gadget_from_your_dashboard!"); return createOpenSocialGadget(portletConfiguration, uriToLegacyGadget); } }
/** * Copy the passed portlet configuration. * * @param portletConfiguration the portlet configuration to copy. * @return the new deeply copied portlet configuration. The underlying property set is cloned into a new memory * property set. */ private PortletConfiguration copyConfiguration(final PortletConfiguration portletConfiguration) { if (portletConfiguration != null) { return new PortletConfigurationImpl(portletConfiguration.getId(), portletConfiguration.getDashboardPageId(), portletConfiguration.getColumn(), portletConfiguration.getRow(), portletConfiguration.getOpenSocialSpecUri(), portletConfiguration.getColor(), portletConfiguration.getUserPrefs(), portletConfiguration.getCompleteModuleKey()); } else { return null; } }
toAdd.getOpenSocialSpecUri(), toAdd.getColor(), toAdd.getUserPrefs(), toAdd.getCompleteModuleKey());
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()); } } }
gv.set(Columns.MODULE_KEY, pc.getCompleteModuleKey().map(new Function<ModuleCompleteKey, String>() updateUserPrefs(pc.getId(), pc.getUserPrefs(), pc.getOpenSocialSpecUri(), pc.getCompleteModuleKey());
public void visit(final AddGadgetChange addGadgetChange) { final DashboardState.ColumnIndex column = addGadgetChange.getColumnIndex(); final Iterable<DashboardItemState> dashboardItems = updateDashboardState.getDashboardColumns().getItemsInColumn(column); final DashboardItemState newItemState = addGadgetChange.getDashboardItemState(); final Long portalPageId = toLong(updateDashboardState.getId()); final PortletConfiguration pc = toPortletConfiguration(newItemState, portalPageId, column.index(), addGadgetChange.getRowIndex()); portletConfigurationStore.addDashboardItem(pc.getDashboardPageId(), pc.getId(), pc.getColumn(), pc.getRow(), pc.getOpenSocialSpecUri(), pc.getColor(), pc.getUserPrefs(), pc.getCompleteModuleKey()); moveDashboardItemsOnePositionDown(dashboardItems, addGadgetChange.getRowIndex() + 1, column.index()); }