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 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(); }
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")); } } }