@VisibleForTesting Map<String, String> getUserPreferences(final Long id, final Option<URI> openSocialSpecUri, final Option<ModuleCompleteKey> completeModuleKey) { // according to migration plan in comment // https://ecosystem.atlassian.net/browse/ACJIRA-235?focusedCommentId=146468&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-146468 // At first stage only connect dashboard items i.e. locally rendered dashboard items without replacement URI, // have user preferences in dashboard items' properties. if (isLocalDashboardItemWithoutReplacementUri(openSocialSpecUri, completeModuleKey)) { return getDashboardItemProperties(id); } else { return getOpenSocialGadgetUserPreferences(id); } }
public void updateUserPrefs(final Long gadgetId, final Map<String, String> userPrefs) { notNull("gadgetId", gadgetId); notNull("userPrefs", userPrefs); if (isLocalDashboardItemWithoutReplacementUri(gadgetId)) { updateLocalDashboardItemProperties(gadgetId, userPrefs); } else { updateOpenSocialGadgetUserPreferences(gadgetId, userPrefs); } }
private void updateUserPrefs(final Long gadgetId, final Map<String, String> userPrefs, final Option<URI> openSocialSpecUri, final Option<ModuleCompleteKey> moduleKey) { notNull("gadgetId", gadgetId); notNull("userPrefs", userPrefs); if (isLocalDashboardItemWithoutReplacementUri(openSocialSpecUri, moduleKey)) { updateLocalDashboardItemProperties(gadgetId, userPrefs); } else { updateOpenSocialGadgetUserPreferences(gadgetId, userPrefs); } }
private boolean isLocalDashboardItemWithoutReplacementUri(long id) { notNull("portletId", id); final List<GenericValue> portletConfigsListGVs = delegator.findByAnd(TABLE, MapBuilder.singletonMap(Columns.ID, id)); if (portletConfigsListGVs.isEmpty()) { throw new IllegalArgumentException("You are trying to update preferences of gadget witch does not exist"); } final GenericValue portletConfigGV = portletConfigsListGVs.get(0); final Option<URI> openSocialSpecUri = Option.option(getGadgetXmlURI(portletConfigGV.getString(Columns.GADGET_XML), id)); final Option<ModuleCompleteKey> completeModuleKey = Option.option(portletConfigGV.getString(Columns.MODULE_KEY)).map(new Function<String, ModuleCompleteKey>() { @Override public ModuleCompleteKey apply(final String input) { return new ModuleCompleteKey(input); } }); return isLocalDashboardItemWithoutReplacementUri(openSocialSpecUri, completeModuleKey); }
private void removeDashboardItemProperties(final PortletConfiguration portletConfiguration) { if (isLocalDashboardItemWithoutReplacementUri(portletConfiguration.getOpenSocialSpecUri(), portletConfiguration.getCompleteModuleKey())) { removeLocalDashboardItemPreferences(portletConfiguration.getId()); } else { removeOpenSocialGadgetPreferences(portletConfiguration.getId()); } }