/** * 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; } }
if (pc.getKey() != null && pc.getKey().startsWith(labelPortletUpgradeTask.getPortletKey())) LOG.info("Upgrading portletconfig with id '" + pc.getId() + "'"); PropertySet portletPropertySet = propertySetFactory.buildNoncachingPropertySet(OfbizPortletConfigurationStore.TABLE, pc.getId()); Map<String, String> prefs = labelPortletUpgradeTask.convertUserPrefs(portletPropertySet); pc.getId(), pc.getDashboardPageId(), null, pc.getPortlet(), pc.getColumn(), pc.getRow(), null, labelPortletUpgradeTask.getGadgetUri(),
private void removeDashboardItemProperties(final PortletConfiguration portletConfiguration) { if (isLocalDashboardItemWithoutReplacementUri(portletConfiguration.getOpenSocialSpecUri(), portletConfiguration.getCompleteModuleKey())) { removeLocalDashboardItemPreferences(portletConfiguration.getId()); } else { removeOpenSocialGadgetPreferences(portletConfiguration.getId()); } }
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); }
log.info("Found activityfeed porlet, upgrading... (" + portlet.getKey() + ")"); String replace = "com.atlassian.streams.streams-jira-plugin:activityfeed"; final Long pageId = portlet.getDashboardPageId(); final Integer column = portlet.getColumn(); final Integer row = portlet.getRow(); final PropertySet propertySet = portlet.getProperties(); final PropertySet ps = portletConfiguration.getProperties(); 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()); } } }
public void visit(final UpdateLayoutChange updateLayoutChange) { final Long dashboardId = toLong(updateDashboardState.getId()); final PortalPage portalPage = portalPageStore.getPortalPage(dashboardId); if (!portalPage.getLayout().equals(updateLayoutChange.getLayout())) { portalPageStore.update(PortalPage.portalPage(portalPage).layout(updateLayoutChange.getLayout()).build()); } final GadgetLayout newLayout = updateLayoutChange.getGadgetLayout(); for (int column = 0; column < newLayout.getNumberOfColumns(); column++) { int row = 0; final Iterable<GadgetId> gadgets = newLayout.getGadgetsInColumn(column); for (GadgetId gadgetId : gadgets) { final Long gadgetIdLong = toLong(gadgetId); final PortletConfiguration portletConfiguration = portletConfigurationStore.getByPortletId(gadgetIdLong); if (portletConfiguration.getColumn() != column || portletConfiguration.getRow() != row) { portletConfigurationStore.updateGadgetPosition(gadgetIdLong, row, column, dashboardId); } row += 1; } } }
private GadgetId getGadgetId(final PortletConfiguration portletConfiguration) { return GadgetId.valueOf(portletConfiguration.getId().toString()); } };
public DashboardState findDashboardWithGadget(final GadgetId gadgetId) throws DashboardNotFoundException { notNull("gagdetId", gadgetId); try { final PortletConfiguration portletConfiguration = portletConfigurationStore.getByPortletId(toLong(gadgetId)); if (portletConfiguration == null) { throw new DashboardStateStoreException("Gadget with id '" + gadgetId + "' not found!"); } return retrieve(DashboardId.valueOf(Long.toString(portletConfiguration.getDashboardPageId()))); } catch (DataAccessException e) { throw new DashboardStateStoreException("Error looking up gadget with id '" + gadgetId + "'.", e); } }
@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); }
public int compareTo(final PortletConfiguration that) { return getRow().compareTo(that.getRow()); }
private DashboardItemState createOpenSocialGadget(final PortletConfiguration portletConfiguration, final URI gadgetUri) { return GadgetState .gadget(getGadgetId(portletConfiguration)) .specUri(gadgetUri) .color(portletConfiguration.getColor()) .userPrefs(portletConfiguration.getUserPrefs()) .build(); }
private List<PortletConfiguration> filter(List<PortletConfiguration> portletConfigs) { List<PortletConfiguration> result = new ArrayList<PortletConfiguration>(portletConfigs.size()); for (PortletConfiguration pc : portletConfigs) { final String key = pc.getKey(); if(key != null && key.contains("com.atlassian.studio.jira-streams")) { result.add(pc); } } return result; }
private GenericValue getGenericValue(final PortletConfiguration pc) { return delegator.findById(TABLE, pc.getId()); }
if (cacheObject != null && cacheObject.getValue() != null) existingDashboardId = cacheObject.getValue().getDashboardPageId(); existingDashboardId = pc.getDashboardPageId();
public void visit(final RemoveGadgetChange removeGadgetChange) { final PortletConfiguration gadgetToRemove = portletConfigurationStore.getByPortletId(toLong(removeGadgetChange.getGadgetId())); final Iterable<DashboardItemState> gadgets = updateDashboardState.getDashboardColumns().getItemsInColumn(DashboardState.ColumnIndex.from(gadgetToRemove.getColumn())); portletConfigurationStore.delete(gadgetToRemove); int row = 0; for (DashboardItemState gadget : gadgets) { portletConfigurationStore.updateGadgetPosition(toLong(gadget.getId()), row, gadgetToRemove.getColumn(), toLong(updateDashboardState.getId())); row++; } }
private DashboardItemState createLocalDashboardItem(final PortletConfiguration portletConfiguration) { return LocalDashboardItemState.builder() .gadgetId(getGadgetId(portletConfiguration)) .color(portletConfiguration.getColor()) .properties(portletConfiguration.getUserPrefs()) .dashboardItemModuleId(getLocalDashboardItemModuleId(portletConfiguration)).build(); }
@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); } }
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()); }
@Override @Nonnull public List<Long> load(@Nonnull final Long portletPageId) { List<PortletConfiguration> configs = delegateStore.getByPortalPage(portletPageId); if (configs != null) { List<Long> ownedSearchRequestIds = new ArrayList<Long>(configs.size()); for (final PortletConfiguration config : configs) { ownedSearchRequestIds.add(config.getId()); } return ImmutableList.copyOf(ownedSearchRequestIds); } else { return ImmutableList.of(); } } }