private void deletePortalPageImpl(final PortalPage portalPage) { Assertions.notNull("portalPage", portalPage); favouritesManager.removeFavouritesForEntityDelete(portalPage); portalPageManager.delete(portalPage.getId()); } }
public DefaultSharedEntityIndexManager( final SharedEntityIndexer indexer, final SearchRequestManager searchRequestManager, final PortalPageManager portalPageManager, final FileFactory fileFactory, final ApplicationProperties applicationProperties) { this.indexer = indexer; this.fileFactory = fileFactory; final Map<SharedEntity.TypeDescriptor<?>, Retriever<? extends SharedEntity>> retrievers = new LinkedHashMap<>(types.length); retrievers.put(SearchRequest.ENTITY_TYPE, () -> searchRequestManager.getAllIndexableSharedEntities()); retrievers.put(PortalPage.ENTITY_TYPE, () -> portalPageManager.getAllIndexableSharedEntities()); this.retrievers = Collections.unmodifiableMap(retrievers); this.multiThreadedIndexingConfiguration = new PropertiesAdapter(applicationProperties); }
public Collection<PortalPage> getOwnedPortalPages(final ApplicationUser user) { if (user == null) { return Collections.emptyList(); } final Collection<PortalPage> allOwnedPortalPages = portalPageManager.getAllOwnedPortalPages(user); return sortByName(allOwnedPortalPages); }
@Override public Collection<PortalPage> getFavouritePortalPages(final ApplicationUser user) { final Collection<Long> ids = getFavouriteIds(user); final List<PortalPage> results = new ArrayList<PortalPage>(ids.size()); for (final Long id : ids) { final PortalPage portalPage = portalPageManager.getPortalPage(user, id); if (portalPage != null) { results.add(portalPage); } } return results; }
private PortalPage getDashboard(long id) { return portalPageManager.getPortalPageById(id); }
public boolean validateForCreate(final JiraServiceContext serviceCtx, final PortalPage portalPage) { Assertions.notNull("serviceCtx", serviceCtx); Assertions.notNull("portalPage", portalPage); checkPermissionsForCreate(serviceCtx, portalPage); if (StringUtils.isBlank(portalPage.getName())) { serviceCtx.getErrorCollection().addError("portalPageName", serviceCtx.getI18nBean().getText("admin.errors.portalpages.must.specify.name")); } else if (serviceCtx.getLoggedInApplicationUser() != null) { final PortalPage byName = portalPageManager.getPortalPageByName(serviceCtx.getLoggedInApplicationUser(), portalPage.getName()); if (byName != null) { serviceCtx.getErrorCollection().addError("portalPageName", serviceCtx.getI18nBean().getText("admin.errors.portalpages.same.name")); } } if(StringUtils.isNotBlank(portalPage.getDescription()) && portalPage.getDescription().length() > 255) { serviceCtx.getErrorCollection().addError("portalPageDescription", serviceCtx.getI18nBean().getText("admin.errors.portalpages.description.too.long")); } return !serviceCtx.getErrorCollection().hasAnyErrors(); }
public List<List<PortletConfiguration>> getPortletConfigurations(JiraServiceContext serviceCtx, final Long portalPageId) { Assertions.notNull("serviceCtx", serviceCtx); Assertions.notNull("portalPageId", portalPageId); if(validateForGetPortalPage(serviceCtx, portalPageId)) { return portalPageManager.getPortletConfigurations(portalPageId); } return Collections.emptyList(); }
public PortalPage getSystemDefaultPortalPage() { return portalPageManager.getSystemDefaultPortalPage(); }
public PortalPage createPortalPage(final JiraServiceContext serviceCtx, final PortalPage portalPage, final boolean isFavourite) { Assertions.notNull("serviceCtx", serviceCtx); Assertions.notNull("portalPage", portalPage); PortalPage newPortalPage = null; if (checkPermissionsForCreate(serviceCtx, portalPage)) { newPortalPage = portalPageManager.create(portalPage); } if ((newPortalPage != null) && isFavourite) { try { favouritesManager.addFavourite(serviceCtx.getLoggedInApplicationUser(), newPortalPage); } catch (final PermissionException e) { serviceCtx.getErrorCollection().addErrorMessage(serviceCtx.getI18nBean().getText("common.favourites.not.added")); } } return newPortalPage; }
public PortalPage createPortalPageByClone(final JiraServiceContext serviceCtx, final PortalPage portalPage, final Long clonePortalPageId, final boolean isFavourite) { Assertions.notNull("serviceCtx", serviceCtx); Assertions.notNull("portalPage", portalPage); Assertions.notNull("clonePortalPageId", clonePortalPageId); final PortalPage clonePortalPage = checkForClone(serviceCtx, portalPage, clonePortalPageId); if (clonePortalPage == null) { return null; } final PortalPage newPortalPage = portalPageManager.createBasedOnClone(serviceCtx.getLoggedInApplicationUser(), portalPage, clonePortalPage); if ((newPortalPage != null) && isFavourite) { try { favouritesManager.addFavourite(serviceCtx.getLoggedInApplicationUser(), newPortalPage); } catch (final PermissionException e) { serviceCtx.getErrorCollection().addErrorMessage(serviceCtx.getI18nBean().getText("common.favourites.not.added")); } } return newPortalPage; }
public boolean validateForGetPortalPage(final JiraServiceContext context, final Long portalPageId) { Assertions.notNull("context", context); Assertions.notNull("portalPageId", portalPageId); final PortalPage portalPage = portalPageManager.getPortalPage(context.getLoggedInApplicationUser(), portalPageId); if (portalPage == null) { context.getErrorCollection().addErrorMessage(context.getI18nBean().getText("admin.errors.portalpages.no.access")); return false; } return true; }
/** * This will always return the Dashboard using the dashboard context - this means you will (should?) never get Permission * exceptions * @return the {@link com.atlassian.jira.issue.search.SearchRequest} that represents the current dashboardId */ protected PortalPage getDashboard() { if ((dashboard == null) && (getDashboardId() != null)) { dashboard = portalPageManager.getPortalPageById(getDashboardId()); } return dashboard; }
public boolean validateForUpdate(final JiraServiceContext serviceCtx, final PortalPage portalPage) { Assertions.notNull("serviceCtx", serviceCtx); Assertions.notNull("portalPage", portalPage); if (StringUtils.isBlank(portalPage.getName())) { serviceCtx.getErrorCollection().addError("portalPageName", serviceCtx.getI18nBean().getText("admin.errors.portalpages.must.specify.name")); } else if (portalPage.isSystemDefaultPortalPage()) { checkSystemDefaultPageForUpdate(serviceCtx, portalPage); } else { final boolean ok = checkOwnerShipAndExistenceAndSharePermissions(serviceCtx, portalPage); if (ok && (serviceCtx.getLoggedInApplicationUser() != null)) { final PortalPage portalPageByName = portalPageManager.getPortalPageByName(serviceCtx.getLoggedInApplicationUser(), portalPage.getName()); if ((portalPageByName != null) && !portalPage.getId().equals(portalPageByName.getId())) { serviceCtx.getErrorCollection().addError("portalPageName", serviceCtx.getI18nBean().getText("admin.errors.portalpages.same.name")); } } } if(StringUtils.isNotBlank(portalPage.getDescription()) && portalPage.getDescription().length() > 255) { serviceCtx.getErrorCollection().addError("portalPageDescription", serviceCtx.getI18nBean().getText("admin.errors.portalpages.description.too.long")); } return !serviceCtx.getErrorCollection().hasAnyErrors(); }
final List<List<PortletConfiguration>> pcColumns = portalPageManager.getPortletConfigurations(portalPageId);
public PortalPage getPortalPage(final JiraServiceContext context, final Long portalPageId) { Assertions.notNull("context", context); Assertions.notNull("portalPageId", portalPageId); final PortalPage portalPage = portalPageManager.getPortalPage(context.getLoggedInApplicationUser(), portalPageId); if (portalPage == null) { context.getErrorCollection().addErrorMessage(context.getI18nBean().getText("admin.errors.portalpages.no.access")); } return portalPage; }
public boolean validateForDelete(final JiraServiceContext serviceCtx, final Long portalPageId) { Assertions.notNull("serviceCtx", serviceCtx); Assertions.notNull("portalPageId", portalPageId); final ApplicationUser user = serviceCtx.getLoggedInApplicationUser(); final ErrorCollection errorCollection = serviceCtx.getErrorCollection(); if (user == null) { errorCollection.addErrorMessage(serviceCtx.getI18nBean().getText("admin.errors.portalpages.owned.anonymous.user")); } else { final PortalPage page = portalPageManager.getPortalPageById(portalPageId); if (page == null) { errorCollection.addErrorMessage(serviceCtx.getI18nBean().getText("admin.errors.portalpages.nonexistent")); } else if (page.isSystemDefaultPortalPage()) { errorCollection.addErrorMessage(serviceCtx.getI18nBean().getText("admin.errors.portalpages.not.delete.system.default")); } else if (!user.equals(page.getOwner())) { errorCollection.addErrorMessage(serviceCtx.getI18nBean().getText("admin.errors.portalpages.must.be.owner")); } } return !errorCollection.hasAnyErrors(); }
public void validateForChangeOwner(final JiraServiceContext serviceCtx, final PortalPage page) { Assertions.notNull("serviceCtx", serviceCtx); Assertions.notNull("page", page); if (serviceCtx.getLoggedInApplicationUser() != null) { final PortalPage portalPageByName = portalPageManager.getPortalPageByName(serviceCtx.getLoggedInApplicationUser(), page.getName()); if ((portalPageByName != null) && !page.getId().equals(portalPageByName.getId())) { serviceCtx.getErrorCollection().addErrorMessage( serviceCtx.getI18nBean().getText("admin.errors.portalpages.already.owns.same.name", serviceCtx.getLoggedInApplicationUser().getDisplayName())); } if (page.getPermissions().isPrivate()) { serviceCtx.getErrorCollection().addErrorMessage(serviceCtx.getI18nBean().getText("admin.errors.portalpages.private")); } } }
public void remove(final DashboardId dashboardId) throws DashboardStateStoreException { notNull("dashboardId", dashboardId); final Long portalPageId = toLong(dashboardId); // Removing the dashboard is done under a cluster lock (by dashboardId) // to ensure all threads trying to read this dashboard will block final Lock writeLock = clusterLockService.getLockForName(getWriteLockName(dashboardId)); writeLock.lock(); try { portalPageManager.delete(portalPageId); } catch (final DataAccessException e) { throw new DashboardStateStoreException("Error removing dashboard state with id'" + dashboardId + "'.", e); } finally { writeLock.unlock(); } }
public void deleteAllPortalPagesForUser(final ApplicationUser user) { Assertions.notNull("user", user); final Collection<PortalPage> ownedPortalPages = portalPageManager.getAllOwnedPortalPages(user); for (final PortalPage portalPage : ownedPortalPages) { deletePortalPageImpl(portalPage); } favouritesManager.removeFavouritesForUser(user, PortalPage.ENTITY_TYPE); }
private PortalPage checkForClone(final JiraServiceContext serviceCtx, final PortalPage portalPage, final Long clonePortalPageId) { final boolean ok = validateForCreate(serviceCtx, portalPage); PortalPage clonePortalPage = null; if (ok && (serviceCtx.getLoggedInApplicationUser() != null)) { final PortalPage tempClonePortalPage = portalPageManager.getPortalPage(serviceCtx.getLoggedInApplicationUser(), clonePortalPageId); if (tempClonePortalPage == null) { serviceCtx.getErrorCollection().addErrorMessage(serviceCtx.getI18nBean().getText("admin.errors.portalpages.clone.does.not.exist")); } else { clonePortalPage = tempClonePortalPage; } } return clonePortalPage; }