CCM NG: Refactored all (hopefully) Repositories to return an Optional instead of a result or null for the methods returning a single entity as result.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4549 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-02-03 07:24:38 +00:00
parent b262f77bdf
commit a4a6cfddc8
146 changed files with 1416 additions and 1389 deletions

View File

@ -141,7 +141,7 @@ public class ItemSelectionModel extends CcmObjectSelectionModel<ContentItem> {
if (typeId != null) { if (typeId != null) {
type = CdiUtil.createCdiUtil().findBean(ContentTypeRepository.class) type = CdiUtil.createCdiUtil().findBean(ContentTypeRepository.class)
.findById(typeId); .findById(typeId).get();
} }
return type; return type;

View File

@ -362,8 +362,7 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
* @param request The HTTP request * @param request The HTTP request
* @param response The HTTP response * @param response The HTTP response
* @param actx The request context * @param actx The request context
* * @throws javax.servlet.ServletException
* @exception AccessDeniedException if the user does not have access.
* *
*/ */
protected void checkUserAccess(HttpServletRequest request, protected void checkUserAccess(HttpServletRequest request,
@ -371,10 +370,11 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
RequestContext actx) RequestContext actx)
throws ServletException, AuthorizationException { throws ServletException, AuthorizationException {
final Shiro shiro = CdiUtil.createCdiUtil().findBean(Shiro.class); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
User user = shiro.getUser(); final Shiro shiro = cdiUtil.findBean(Shiro.class);
final PermissionChecker permissionChecker = CdiUtil.createCdiUtil() User user = shiro.getUser().get();
.findBean(PermissionChecker.class); final PermissionChecker permissionChecker = cdiUtil.findBean(
PermissionChecker.class);
ContentSection section = getContentSection(request); ContentSection section = getContentSection(request);
@ -492,6 +492,7 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
* @param context The use context * @param context The use context
* *
* @return The item associated with the URL, or null if no such item exists * @return The item associated with the URL, or null if no such item exists
*
* @throws javax.servlet.ServletException * @throws javax.servlet.ServletException
*/ */
protected ContentItem getContentItem(ContentSection section, String url, protected ContentItem getContentItem(ContentSection section, String url,
@ -499,8 +500,10 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
throws ServletException { throws ServletException {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentSectionManager sectionManager = cdiUtil.findBean(ContentSectionManager.class); final ContentSectionManager sectionManager = cdiUtil.findBean(
final ItemResolver itemResolver = sectionManager.getItemResolver(section); ContentSectionManager.class);
final ItemResolver itemResolver = sectionManager
.getItemResolver(section);
return itemResolver.getItem(section, url, context); return itemResolver.getItem(section, url, context);
} }
@ -537,9 +540,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
try { try {
pageResolver = (PageResolver) Class.forName(pageResolverClassName) pageResolver = (PageResolver) Class.forName(pageResolverClassName)
.newInstance(); .newInstance();
} catch (ClassNotFoundException | } catch (ClassNotFoundException
IllegalAccessException | | IllegalAccessException
InstantiationException ex) { | InstantiationException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
pageResolver.releasePage(url); pageResolver.releasePage(url);
@ -568,9 +571,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
pageResolver = (PageResolver) Class.forName( pageResolver = (PageResolver) Class.forName(
pageResolverClassName) pageResolverClassName)
.newInstance(); .newInstance();
} catch (ClassNotFoundException | } catch (ClassNotFoundException
IllegalAccessException | | IllegalAccessException
InstantiationException ex) { | InstantiationException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
s_pageResolverCache.put(name, pageResolver); s_pageResolverCache.put(name, pageResolver);
@ -614,9 +617,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
try { try {
xmlGenerator = (XMLGenerator) Class.forName( xmlGenerator = (XMLGenerator) Class.forName(
xmlGeneratorClassName).newInstance(); xmlGeneratorClassName).newInstance();
} catch (ClassNotFoundException | } catch (ClassNotFoundException
IllegalAccessException | | IllegalAccessException
InstantiationException ex) { | InstantiationException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
s_xmlGeneratorCache.put(name, xmlGenerator); s_xmlGeneratorCache.put(name, xmlGenerator);

View File

@ -44,13 +44,14 @@ import org.libreccm.security.PermissionChecker;
import org.libreccm.security.Shiro; import org.libreccm.security.Shiro;
import org.libreccm.security.User; import org.libreccm.security.User;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemRepository; import org.librecms.contentsection.ContentItemRepository;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionServlet; import org.librecms.contentsection.ContentSectionServlet;
import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.contentsection.privileges.ItemPrivileges;
import java.util.Optional;
/** /**
* <p>A <tt>CMSPage</tt> is a Bebop {@link com.arsdigita.bebop.Page} * <p>A <tt>CMSPage</tt> is a Bebop {@link com.arsdigita.bebop.Page}
@ -313,9 +314,9 @@ public class CMSPage extends Page implements ResourceHandler {
@Override @Override
protected Element generateXMLHelper(PageState ps, Document parent) { protected Element generateXMLHelper(PageState ps, Document parent) {
Element page = super.generateXMLHelper(ps,parent); Element page = super.generateXMLHelper(ps,parent);
final User user = CdiUtil.createCdiUtil().findBean(Shiro.class).getUser(); final Optional<User> user = CdiUtil.createCdiUtil().findBean(Shiro.class).getUser();
if ( user != null ) { if ( user.isPresent()) {
page.addAttribute("name",user.getName()); page.addAttribute("name",user.get().getName());
} }
return page; return page;

View File

@ -38,6 +38,7 @@ import org.libreccm.web.CcmApplication;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -217,10 +218,10 @@ public class CMSApplicationPage extends Page {
// document it in the classes. Probably remove one ore the other // document it in the classes. Probably remove one ore the other
// way from the API if possible. // way from the API if possible.
final Shiro shiro = CdiUtil.createCdiUtil().findBean(Shiro.class); final Shiro shiro = CdiUtil.createCdiUtil().findBean(Shiro.class);
final User user = shiro.getUser(); final Optional<User> user = shiro.getUser();
// User user = Web.getWebContext().getUser(); // User user = Web.getWebContext().getUser();
if ( user != null ) { if (user.isPresent()) {
pageElement.addAttribute("name",user.getName()); pageElement.addAttribute("name",user.get().getName());
} }
return pageElement; return pageElement;

View File

@ -53,6 +53,7 @@ import org.librecms.contenttypes.ContentTypesManager;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Optional;
/** /**
* An invisible component which contains all the possible creation components. * An invisible component which contains all the possible creation components.
@ -154,15 +155,15 @@ public class CreationSelector extends MetaForm {
final ContentTypesManager typesManager = cdiUtil.findBean( final ContentTypesManager typesManager = cdiUtil.findBean(
ContentTypesManager.class); ContentTypesManager.class);
final ContentType type = typeRepo.findById(typeId); final Optional<ContentType> type = typeRepo.findById(typeId);
if (type == null) { if (!type.isPresent()) {
throw new UncheckedWrapperException(String.format( throw new UncheckedWrapperException(String.format(
"Type with id %d not found.", typeId)); "Type with id %d not found.", typeId));
} }
final ContentTypeInfo typeInfo = typesManager.getContentTypeInfo( final ContentTypeInfo typeInfo = typesManager.getContentTypeInfo(
type); type.get());
final AuthoringKitInfo kit = typeInfo.getAuthoringKit(); final AuthoringKitInfo kit = typeInfo.getAuthoringKit();
component = instantiateKitComponent(kit, type); component = instantiateKitComponent(kit, type.get());
if (component != null) { if (component != null) {
returnForm.add(component); returnForm.add(component);
returnForm.setMethod(Form.POST); returnForm.setMethod(Form.POST);

View File

@ -129,7 +129,7 @@ public abstract class NewItemForm extends Form {
if (singleTypeID == null) { if (singleTypeID == null) {
parentType = null; parentType = null;
} else { } else {
parentType = typeRepo.findById(singleTypeID); parentType = typeRepo.findById(singleTypeID).get();
} }
typesCollection = section.getContentTypes().stream() typesCollection = section.getContentTypes().stream()

View File

@ -580,7 +580,7 @@ public class FolderManipulator extends SimpleContainer implements
final PermissionChecker permissionChecker = cdiUtil.findBean( final PermissionChecker permissionChecker = cdiUtil.findBean(
PermissionChecker.class); PermissionChecker.class);
final ContentItem item = itemRepo.findById(itemId); final ContentItem item = itemRepo.findById(itemId).get();
final String name = item.getDisplayName(); final String name = item.getDisplayName();
final long count = itemRepo.countByNameInFolder(target, name); final long count = itemRepo.countByNameInFolder(target, name);

View File

@ -115,7 +115,7 @@ public class Summary extends CMSContainer {
final ContentSection section = getContentSection(state); final ContentSection section = getContentSection(state);
final Shiro shiro = cdiUtil.findBean(Shiro.class); final Shiro shiro = cdiUtil.findBean(Shiro.class);
final User user = shiro.getUser(); final User user = shiro.getUser().get();
// Setup xml element for item's properties // Setup xml element for item's properties
final Element itemElement = new Element("cms:itemSummary", final Element itemElement = new Element("cms:itemSummary",

View File

@ -121,7 +121,7 @@ class DeletePhaseForm extends CMSForm
// Check if the object is already deleted for double click // Check if the object is already deleted for double click
// protection. // protection.
final PhaseDefinition phaseDef = phaseDefRepo.findById(key); final PhaseDefinition phaseDef = phaseDefRepo.findById(key).get();
if (phaseDef != null) { if (phaseDef != null) {
phaseDefRepo.delete(phaseDef); phaseDefRepo.delete(phaseDef);
} }

View File

@ -320,7 +320,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final ContentItem item = selectedItem.getContentItem(state); final ContentItem item = selectedItem.getContentItem(state);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final Shiro shiro = cdiUtil.findBean(Shiro.class); final Shiro shiro = cdiUtil.findBean(Shiro.class);
final User user = shiro.getUser(); final User user = shiro.getUser().get();
/* /*
* jensp 2011-12-14: Check is threaded publishing is active. * jensp 2011-12-14: Check is threaded publishing is active.
@ -360,10 +360,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
UserRepository.class); UserRepository.class);
final User receiver = userRepo.findByEmailAddress( final User receiver = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureReceiver()); .getPublishingFailureReceiver()).get();
final User sender = userRepo.findByEmailAddress( final User sender = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureSender()); .getPublishingFailureSender()).get();
if ((sender != null) && (receiver != null)) { if ((sender != null) && (receiver != null)) {
final Writer traceWriter = new StringWriter(); final Writer traceWriter = new StringWriter();
@ -467,7 +467,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final ContentItem item = selectedItem.getContentItem(state); final ContentItem item = selectedItem.getContentItem(state);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final Shiro shiro = cdiUtil.findBean(Shiro.class); final Shiro shiro = cdiUtil.findBean(Shiro.class);
final User user = shiro.getUser(); final User user = shiro.getUser().get();
/** /**
* jensp 2011-12-14: Execute is a thread if threaded publishing * jensp 2011-12-14: Execute is a thread if threaded publishing
@ -506,10 +506,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
UserRepository.class); UserRepository.class);
final User receiver = userRepo.findByEmailAddress( final User receiver = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureReceiver()); .getPublishingFailureReceiver()).get();
final User sender = userRepo.findByEmailAddress( final User sender = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureSender()); .getPublishingFailureSender()).get();
if ((sender != null) && (receiver != null)) { if ((sender != null) && (receiver != null)) {
final Writer traceWriter = new StringWriter(); final Writer traceWriter = new StringWriter();
@ -698,7 +698,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final FormData data = event.getFormData(); final FormData data = event.getFormData();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final Shiro shiro = cdiUtil.findBean(Shiro.class); final Shiro shiro = cdiUtil.findBean(Shiro.class);
final User user = shiro.getUser(); final User user = shiro.getUser().get();
String selected = (String) data.get(LIFECYCLE_ACTION); String selected = (String) data.get(LIFECYCLE_ACTION);
final ContentItem item = selectedItem.getContentItem(state); final ContentItem item = selectedItem.getContentItem(state);
@ -743,10 +743,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
UserRepository.class); UserRepository.class);
final User receiver = userRepo.findByEmailAddress( final User receiver = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureReceiver()); .getPublishingFailureReceiver()).get();
final User sender = userRepo.findByEmailAddress( final User sender = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureSender()); .getPublishingFailureSender()).get();
if ((sender != null) && (receiver != null)) { if ((sender != null) && (receiver != null)) {
final Writer traceWriter = new StringWriter(); final Writer traceWriter = new StringWriter();
@ -831,10 +831,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
UserRepository.class); UserRepository.class);
final User receiver = userRepo.findByEmailAddress( final User receiver = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureReceiver()); .getPublishingFailureReceiver()).get();
final User sender = userRepo.findByEmailAddress( final User sender = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureSender()); .getPublishingFailureSender()).get();
if ((sender != null) && (receiver != null)) { if ((sender != null) && (receiver != null)) {
final Writer traceWriter = new StringWriter(); final Writer traceWriter = new StringWriter();

View File

@ -433,10 +433,10 @@ class ItemLifecycleSelectForm extends BaseForm {
UserRepository.class); UserRepository.class);
final User receiver = userRepo.findByEmailAddress( final User receiver = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureReceiver()); .getPublishingFailureReceiver()).get();
final User sender = userRepo.findByEmailAddress( final User sender = userRepo.findByEmailAddress(
CMSConfig.getConfig() CMSConfig.getConfig()
.getPublishingFailureSender()); .getPublishingFailureSender()).get();
if ((sender != null) && (receiver != null)) { if ((sender != null) && (receiver != null)) {
final Writer traceWriter = new StringWriter(); final Writer traceWriter = new StringWriter();
@ -714,7 +714,7 @@ class ItemLifecycleSelectForm extends BaseForm {
workflowUuid = null; workflowUuid = null;
} }
user = CdiUtil.createCdiUtil().findBean(Shiro.class).getUser(); user = CdiUtil.createCdiUtil().findBean(Shiro.class).getUser().get();
} }
/** /**
@ -747,7 +747,7 @@ class ItemLifecycleSelectForm extends BaseForm {
final LifecycleDefinition cycleDef; final LifecycleDefinition cycleDef;
final Lifecycle lifecycle; final Lifecycle lifecycle;
// Apply the new lifecycle. // Apply the new lifecycle.
cycleDef = lifecycleDefRepo.findById(defID); cycleDef = lifecycleDefRepo.findById(defID).get();
pending = itemManager.publish(item, cycleDef); pending = itemManager.publish(item, cycleDef);
lifecycle = pending.getLifecycle(); lifecycle = pending.getLifecycle();

View File

@ -28,6 +28,8 @@ import org.libreccm.core.CcmObjectRepository;
import org.libreccm.security.Role; import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository; import org.libreccm.security.RoleRepository;
import java.util.Optional;
/** /**
* This class is mainly instantiated from a PageState It is very context * This class is mainly instantiated from a PageState It is very context
* specific for permissions. It tries to read the object_id and load the * specific for permissions. It tries to read the object_id and load the
@ -71,13 +73,13 @@ class CMSUserObjectStruct {
final CcmObjectRepository objectRepo = cdiUtil.findBean( final CcmObjectRepository objectRepo = cdiUtil.findBean(
CcmObjectRepository.class); CcmObjectRepository.class);
final CcmObject ccmObject = objectRepo.findById(objectId); final Optional<CcmObject> ccmObject = objectRepo.findById(objectId);
if (ccmObject == null) { if (!ccmObject.isPresent()) {
throw new UncheckedWrapperException(String.format( throw new UncheckedWrapperException(String.format(
"Failed to find object with ID %d.", objectId)); "Failed to find object with ID %d.", objectId));
} }
return ccmObject; return ccmObject.get();
} }
// use in package // use in package
@ -86,14 +88,14 @@ class CMSUserObjectStruct {
final RoleRepository roleRepo = cdiUtil final RoleRepository roleRepo = cdiUtil
.findBean(RoleRepository.class); .findBean(RoleRepository.class);
final Role role = roleRepo.findById(roleId); final Optional<Role> role = roleRepo.findById(roleId);
if (role == null) { if (!role.isPresent()) {
throw new UncheckedWrapperException(String.format( throw new UncheckedWrapperException(String.format(
"Failed to find party with ID %d.", roleId)); "Failed to find party with ID %d.", roleId));
} }
return role; return role.get();
} }
public static Role getRole(final PageState state) { public static Role getRole(final PageState state) {

View File

@ -59,6 +59,7 @@ import org.librecms.CmsConstants;
import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.contentsection.privileges.ItemPrivileges;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
/** /**
@ -263,14 +264,14 @@ public class ObjectAddAdmin extends SimpleContainer
// Add each checked user to the object // Add each checked user to the object
for (final String roleId : roleIds) { for (final String roleId : roleIds) {
final Role role = roleRepo.findById(Long.parseLong(roleId)); final Optional<Role> role = roleRepo.findById(Long.parseLong(roleId));
if (role == null) { if (!role.isPresent()) {
throw new FormProcessException(new GlobalizedMessage( throw new FormProcessException(new GlobalizedMessage(
"cms.ui.permissions.cannot_add_user", "cms.ui.permissions.cannot_add_user",
CmsConstants.CMS_BUNDLE)); CmsConstants.CMS_BUNDLE));
} }
permissionManager.grantPrivilege(ItemPrivileges.ADMINISTER, permissionManager.grantPrivilege(ItemPrivileges.ADMINISTER,
role, role.get(),
object); object);
} }

View File

@ -35,8 +35,6 @@ import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableModel; import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder; import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.dispatcher.AccessDeniedException;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.CcmObjectSelectionModel; import com.arsdigita.ui.CcmObjectSelectionModel;
import com.arsdigita.util.LockableImpl; import com.arsdigita.util.LockableImpl;
@ -44,7 +42,6 @@ import com.arsdigita.util.UncheckedWrapperException;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.security.Party;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.security.PermissionManager; import org.libreccm.security.PermissionManager;
import org.libreccm.security.Role; import org.libreccm.security.Role;
@ -52,9 +49,9 @@ import org.libreccm.security.RoleRepository;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.contentsection.privileges.ItemPrivileges;
import java.math.BigDecimal;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ObjectAdminListing extends SimpleContainer { public class ObjectAdminListing extends SimpleContainer {
@ -146,14 +143,14 @@ public class ObjectAdminListing extends SimpleContainer {
ItemPrivileges.ADMINISTER, object); ItemPrivileges.ADMINISTER, object);
final String roleId = (String) event.getRowKey(); final String roleId = (String) event.getRowKey();
final Role role = roleRepo.findById(Long.parseLong(roleId)); final Optional<Role> role = roleRepo.findById(Long.parseLong(roleId));
if (role == null) { if (!role.isPresent()) {
throw new UncheckedWrapperException(String.format( throw new UncheckedWrapperException(String.format(
"No role with id %s found.", roleId)); "No role with id %s found.", roleId));
} }
permissionManager.revokePrivilege(ItemPrivileges.ADMINISTER, permissionManager.revokePrivilege(ItemPrivileges.ADMINISTER,
role, role.get(),
object); object);
} }
} }

View File

@ -58,7 +58,7 @@ public class ContentSectionSummaryController {
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public List<RowData<Long>> createReportData(final ContentSection section) { public List<RowData<Long>> createReportData(final ContentSection section) {
final ContentSection contentSection = sectionRepo.findById( final ContentSection contentSection = sectionRepo.findById(
section.getObjectId()); section.getObjectId()).get();
final List<Folder> rootFolders = contentSection.getRootDocumentsFolder() final List<Folder> rootFolders = contentSection.getRootDocumentsFolder()
.getSubFolders(); .getSubFolders();

View File

@ -251,7 +251,7 @@ class BaseRoleItemPane extends BaseItemPane {
PartyRepository.class); PartyRepository.class);
final RoleManager roleManager = cdiUtil.findBean( final RoleManager roleManager = cdiUtil.findBean(
RoleManager.class); RoleManager.class);
final Party party = partyRepository.findById(itemId); final Party party = partyRepository.findById(itemId).get();
roleManager.removeRoleFromParty(role, party); roleManager.removeRoleFromParty(role, party);

View File

@ -197,7 +197,7 @@ public class RoleAdminPane extends BaseAdminPane<String> {
final RoleRepository roleRepository = cdiUtil.findBean( final RoleRepository roleRepository = cdiUtil.findBean(
RoleRepository.class); RoleRepository.class);
final Long id = Long.parseLong(selectionModel.getSelectedKey(state)); final Long id = Long.parseLong(selectionModel.getSelectedKey(state));
final Role role = roleRepository.findById(id); final Role role = roleRepository.findById(id).get();
roleRepository.delete(role); roleRepository.delete(role);

View File

@ -100,7 +100,7 @@ class RolePartyAddForm extends PartyAddForm {
final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.class); final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.class);
final RoleManager roleManager = cdiUtil.findBean(RoleManager.class); final RoleManager roleManager = cdiUtil.findBean(RoleManager.class);
final Role role = roleRepository.findById(roleId); final Role role = roleRepository.findById(roleId).get();
// Add each checked party to the role // Add each checked party to the role
Party party; Party party;
@ -108,7 +108,7 @@ class RolePartyAddForm extends PartyAddForm {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("parties[" + i + "] = " + parties[i]); s_log.debug("parties[" + i + "] = " + parties[i]);
} }
party = partyRepository.findByName(parties[i]); party = partyRepository.findByName(parties[i]).get();
roleManager.assignRoleToParty(role, party); roleManager.assignRoleToParty(role, party);
} }
} }

View File

@ -63,6 +63,7 @@ import org.librecms.lifecycle.LifecycleDefinitionRepository;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Optional;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
import javax.persistence.NoResultException; import javax.persistence.NoResultException;
@ -225,12 +226,20 @@ public class EditType extends CMSForm
final ContentTypeRepository typeRepo = cdiUtil.findBean( final ContentTypeRepository typeRepo = cdiUtil.findBean(
ContentTypeRepository.class); ContentTypeRepository.class);
final Optional<ContentType> result;
try { try {
return typeRepo.findById(Long.parseLong(key)); result = typeRepo.findById(Long.parseLong(key));
} catch (NumberFormatException } catch (NumberFormatException ex) {
| NoResultException ex) {
throw new UncheckedWrapperException(String.format( throw new UncheckedWrapperException(String.format(
"ContentType with ID %s not found.", key), ex); "The provided key \"%s\" is not a long.", key),
ex);
}
if (result.isPresent()) {
return result.get();
} else {
throw new UncheckedWrapperException(String.format(
"ContentType with ID %s not found.", key));
} }
} }
@ -266,13 +275,9 @@ public class EditType extends CMSForm
final ContentTypeManager typeManager = cdiUtil.findBean( final ContentTypeManager typeManager = cdiUtil.findBean(
ContentTypeManager.class); ContentTypeManager.class);
ContentType type = null; final Optional<ContentType> type = typeRepo.findById(key);
try { if (!type.isPresent()) {
type = typeRepo.findById(key);
} catch (NoResultException ex) {
LOGGER.error("Can't find ContentType with key {}", key); LOGGER.error("Can't find ContentType with key {}", key);
LOGGER.error(ex);
throw new FormProcessException(new GlobalizedMessage( throw new FormProcessException(new GlobalizedMessage(
"cms.ui.type.content_editing_failed", "cms.ui.type.content_editing_failed",
CmsConstants.CMS_BUNDLE, CmsConstants.CMS_BUNDLE,
@ -281,20 +286,20 @@ public class EditType extends CMSForm
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
type.getLabel().addValue(kernelConfig.getDefaultLocale(), label); type.get().getLabel().addValue(kernelConfig.getDefaultLocale(), label);
type.getDescription().addValue(kernelConfig.getDefaultLocale(), type.get().getDescription().addValue(kernelConfig.getDefaultLocale(),
description); description);
typeRepo.save(type); typeRepo.save(type.get());
// Handle default lifecycle and workflow. // Handle default lifecycle and workflow.
final LifecycleDefinition defaultLifecycle = lifecycleDefRepo.findById( final LifecycleDefinition defaultLifecycle = lifecycleDefRepo.findById(
lifecycleId); lifecycleId).get();
final WorkflowTemplate defaultWorkflow = workflowTemplateRepo.findById( final WorkflowTemplate defaultWorkflow = workflowTemplateRepo.findById(
workflowId); workflowId).get();
typeManager.setDefaultLifecycle(type, defaultLifecycle); typeManager.setDefaultLifecycle(type.get(), defaultLifecycle);
typeManager.setDefaultWorkflow(type, defaultWorkflow); typeManager.setDefaultWorkflow(type.get(), defaultWorkflow);
} }

View File

@ -107,7 +107,7 @@ public class TypePermissionsTable extends Table implements TableActionListener {
if (TABLE_COL_ACTION.equals(column.getHeaderKey().toString())) { if (TABLE_COL_ACTION.equals(column.getHeaderKey().toString())) {
final Role role = roleRepo.findById(Long.parseLong( final Role role = roleRepo.findById(Long.parseLong(
event.getRowKey().toString())); event.getRowKey().toString())).get();
ContentType contentType = getType().getContentType(state); ContentType contentType = getType().getContentType(state);
controller.toggleTypeUsePermission(contentType, role); controller.toggleTypeUsePermission(contentType, role);

View File

@ -63,7 +63,7 @@ public class TypePermissionsTableController {
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public List<RowData<Long>> retrieveTypePermissions( public List<RowData<Long>> retrieveTypePermissions(
final long typeId, final ContentSection section) { final long typeId, final ContentSection section) {
final ContentType type = typeRepo.findById(typeId); final ContentType type = typeRepo.findById(typeId).get();
final List<Role> roles = section.getRoles(); final List<Role> roles = section.getRoles();

View File

@ -70,7 +70,7 @@ public class AssignedTaskController {
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public List<RowData<Long>> getAssignedTasks(final Workflow workflow) { public List<RowData<Long>> getAssignedTasks(final Workflow workflow) {
final User user = shiro.getUser(); final User user = shiro.getUser().get();
final List<AssignableTask> tasks = userTaskRepo.getAssignedTasks(user, final List<AssignableTask> tasks = userTaskRepo.getAssignedTasks(user,
workflow); workflow);

View File

@ -174,8 +174,8 @@ public final class AssignedTaskSection extends Section {
final AssignableTaskRepository userTaskRepo = cdiUtil.findBean( final AssignableTaskRepository userTaskRepo = cdiUtil.findBean(
AssignableTaskRepository.class); AssignableTaskRepository.class);
final Shiro shiro = cdiUtil.findBean(Shiro.class); final Shiro shiro = cdiUtil.findBean(Shiro.class);
return userTaskRepo.findEnabledTasksForWorkflow(shiro.getUser(), return userTaskRepo.findEnabledTasksForWorkflow(
workflow); shiro.getUser().get(), workflow);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -75,8 +75,8 @@ public final class AssignedTaskTable extends Table {
if (column == 1) { if (column == 1) {
final AssignableTask task = userTaskRepo.findById((Long) event final AssignableTask task = userTaskRepo.findById((Long) event
.getRowKey()); .getRowKey()).get();
final User currentUser = shiro.getUser(); final User currentUser = shiro.getUser().get();
final User lockingUser = task.getLockingUser(); final User lockingUser = task.getLockingUser();
if (task.isLocked() if (task.isLocked()
&& lockingUser != null && lockingUser != null

View File

@ -182,7 +182,7 @@ class BaseTaskForm extends BaseForm {
selectedId = Long.parseLong(selectedDependency); selectedId = Long.parseLong(selectedDependency);
addedTask = toRemove.remove(selectedId); addedTask = toRemove.remove(selectedId);
if (addedTask == null) { if (addedTask == null) {
toAdd.put(selectedId, taskRepo.findById(selectedId)); toAdd.put(selectedId, taskRepo.findById(selectedId).get());
} }
} }
} }

View File

@ -146,7 +146,7 @@ abstract class BaseWorkflowItemPane extends BaseItemPane {
final User lockingUser = task.getLockingUser(); final User lockingUser = task.getLockingUser();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final Shiro shiro = cdiUtil.findBean(Shiro.class); final Shiro shiro = cdiUtil.findBean(Shiro.class);
final User currentUser = shiro.getUser(); final User currentUser = shiro.getUser().get();
return task.isLocked() && (lockingUser == null return task.isLocked() && (lockingUser == null
|| lockingUser.equals(currentUser)); || lockingUser.equals(currentUser));

View File

@ -24,8 +24,8 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import org.librecms.workflow.CmsTask; import org.librecms.workflow.CmsTask;
import com.arsdigita.web.Web;
import org.libreccm.workflow.Workflow; import org.libreccm.workflow.Workflow;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
@ -75,7 +75,7 @@ final class ItemWorkflowItemPane extends BaseWorkflowItemPane {
final TaskRepository taskRepo = cdiUtil.findBean( final TaskRepository taskRepo = cdiUtil.findBean(
TaskRepository.class); TaskRepository.class);
return (CmsTask) taskRepo.findById(Long.parseLong(taskId)); return (CmsTask) taskRepo.findById(Long.parseLong(taskId)).get();
} }
} }

View File

@ -102,9 +102,12 @@ class ItemWorkflowSelectForm extends CMSForm {
final WorkflowManager workflowManager = cdiUtil.findBean( final WorkflowManager workflowManager = cdiUtil.findBean(
WorkflowManager.class); WorkflowManager.class);
final WorkflowTemplate template = templateRepo.findById(flowId); final WorkflowTemplate template = templateRepo.findById(flowId)
.get();
workflowManager.createWorkflow(template, item); workflowManager.createWorkflow(template, item);
} }
} }
} }
} }

View File

@ -46,7 +46,7 @@ class ItemWorkflowSelectionModel extends ParameterSingleSelectionModel {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentItemRepository itemRepo = cdiUtil.findBean(ContentItemRepository.class); final ContentItemRepository itemRepo = cdiUtil.findBean(ContentItemRepository.class);
final ContentItem item = itemRepo.findById((Long) super.getSelectedKey( final ContentItem item = itemRepo.findById((Long) super.getSelectedKey(
state)); state)).get();
return item.getWorkflow().getWorkflowId(); return item.getWorkflow().getWorkflowId();
} }

View File

@ -139,7 +139,7 @@ class TaskAddRole extends CMSForm {
if (roleIds != null) { if (roleIds != null) {
for (final String roleId : roleIds) { for (final String roleId : roleIds) {
final Role role = roleRepository.findById(Long final Role role = roleRepository.findById(Long
.parseLong(roleId)); .parseLong(roleId)).get();
taskManager.assignTask(task, role); taskManager.assignTask(task, role);
} }
} }

View File

@ -24,7 +24,6 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.Submit;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ui.UserAddForm; import com.arsdigita.cms.ui.UserAddForm;
import com.arsdigita.cms.ui.UserSearchForm; import com.arsdigita.cms.ui.UserSearchForm;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
@ -40,7 +39,6 @@ import org.libreccm.security.UserRepository;
import org.libreccm.workflow.WorkflowManager; import org.libreccm.workflow.WorkflowManager;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
@ -150,7 +148,7 @@ class TaskAddUser extends SimpleContainer {
User user; User user;
for (int i = 0; i < users.length; i++) { for (int i = 0; i < users.length; i++) {
user = userRepo.findById(Long.parseLong(users[i])); user = userRepo.findById(Long.parseLong(users[i])).get();
//ToDo //ToDo

View File

@ -47,7 +47,7 @@ public class TaskFinishFormController {
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public List<AssignableTask> findEnabledTasks(final Workflow workflow) { public List<AssignableTask> findEnabledTasks(final Workflow workflow) {
final User user = shiro.getUser(); final User user = shiro.getUser().get();
final List<Role> roles = user.getRoleMemberships().stream() final List<Role> roles = user.getRoleMemberships().stream()
.map(membership -> membership.getRole()) .map(membership -> membership.getRole())
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -170,7 +170,7 @@ final class TaskItemPane extends BaseItemPane {
AssignableTaskManager.class); AssignableTaskManager.class);
final Shiro shiro = cdiUtil.findBean(Shiro.class); final Shiro shiro = cdiUtil.findBean(Shiro.class);
final User user = shiro.getUser(); final User user = shiro.getUser().get();
final List<AssignableTask> tasks = taskManager.lockedBy(user); final List<AssignableTask> tasks = taskManager.lockedBy(user);
@ -387,7 +387,7 @@ final class TaskItemPane extends BaseItemPane {
final RoleRepository roleRepo = cdiUtil.findBean( final RoleRepository roleRepo = cdiUtil.findBean(
RoleRepository.class); RoleRepository.class);
final Role role = roleRepo.findById(roleId); final Role role = roleRepo.findById(roleId).get();
taskManager.retractTask(task, role); taskManager.retractTask(task, role);
} }
} }

View File

@ -1023,7 +1023,7 @@ public class ContentItemManager {
// Ensure that we are using a fresh folder and that the folder was // Ensure that we are using a fresh folder and that the folder was
// retrieved in this transaction to avoid problems with lazy fetched // retrieved in this transaction to avoid problems with lazy fetched
// data. // data.
final Folder theFolder = folderRepo.findById(folder.getObjectId()); final Folder theFolder = folderRepo.findById(folder.getObjectId()).get();
theFolder.getObjects() theFolder.getObjects()
.stream() .stream()
@ -1120,7 +1120,7 @@ public class ContentItemManager {
// Ensure that we are using a fresh folder and that the folder was // Ensure that we are using a fresh folder and that the folder was
// retrieved in this transaction to avoid problems with lazy fetched // retrieved in this transaction to avoid problems with lazy fetched
// data. // data.
final Folder theFolder = folderRepo.findById(folder.getObjectId()); final Folder theFolder = folderRepo.findById(folder.getObjectId()).get();
theFolder.getObjects() theFolder.getObjects()
.stream() .stream()
@ -1384,10 +1384,8 @@ public class ContentItemManager {
*/ */
public Optional<Folder> getItemFolder(final ContentItem item) { public Optional<Folder> getItemFolder(final ContentItem item) {
final List<Categorization> result = item.getCategories().stream() final List<Categorization> result = item.getCategories().stream()
.filter(categorization -> { .filter(categorization -> CATEGORIZATION_TYPE_FOLDER.equals(
return CATEGORIZATION_TYPE_FOLDER. categorization.getType()))
equals(categorization.getType());
})
.collect(Collectors.toList()); .collect(Collectors.toList());
if (result.size() > 0) { if (result.size() > 0) {

View File

@ -103,9 +103,9 @@ public class ContentItemRepository
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends ContentItem> Optional<T> findById(final long itemId, public <T extends ContentItem> Optional<T> findById(final long itemId,
final Class<T> type) { final Class<T> type) {
final CcmObject result = ccmObjectRepo.findById(itemId); final Optional<CcmObject> result = ccmObjectRepo.findById(itemId);
if (result.getClass().isAssignableFrom(type)) { if (result.get().getClass().isAssignableFrom(type)) {
return Optional.of((T) result); return Optional.of((T) result.get());
} else { } else {
return Optional.empty(); return Optional.empty();
} }

View File

@ -351,10 +351,10 @@ public class MultilingualItemResolver implements ItemResolver {
// No template context here. // No template context here.
return generateDraftURL(section, itemId); return generateDraftURL(section, itemId);
} else if (CMSDispatcher.PREVIEW.equals(context)) { } else if (CMSDispatcher.PREVIEW.equals(context)) {
final ContentItem item = itemRepo.findById(itemId); final ContentItem item = itemRepo.findById(itemId).get();
return generatePreviewURL(section, item, templateContext); return generatePreviewURL(section, item, templateContext);
} else if (ContentItemVersion.LIVE.toString().equals(context)) { } else if (ContentItemVersion.LIVE.toString().equals(context)) {
final ContentItem item = itemRepo.findById(itemId); final ContentItem item = itemRepo.findById(itemId).get();
return generateLiveURL(section, item, templateContext); return generateLiveURL(section, item, templateContext);
} else { } else {

View File

@ -395,10 +395,10 @@ public class SimpleItemResolver implements ItemResolver {
if (ContentItemVersion.DRAFT.toString().equals(context)) { if (ContentItemVersion.DRAFT.toString().equals(context)) {
return generateDraftURL(itemId, section); return generateDraftURL(itemId, section);
} else if (ContentItemVersion.LIVE.toString().equals(context)) { } else if (ContentItemVersion.LIVE.toString().equals(context)) {
final ContentItem item = itemRepo.findById(itemId); final ContentItem item = itemRepo.findById(itemId).get();
return generateLiveURL(item, section, templateContext); return generateLiveURL(item, section, templateContext);
} else if (CMSDispatcher.PREVIEW.equals(context)) { } else if (CMSDispatcher.PREVIEW.equals(context)) {
final ContentItem item = itemRepo.findById(itemId); final ContentItem item = itemRepo.findById(itemId).get();
return generatePreviewURL(item, section, templateContext); return generatePreviewURL(item, section, templateContext);
} else { } else {
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(

View File

@ -212,7 +212,7 @@ public class AssetManagerTest {
"timestamp", "timestamp",
"uuid"}) "uuid"})
public void shareAsset() throws MimeTypeParseException { public void shareAsset() throws MimeTypeParseException {
final Folder folder = folderRepo.findById(-420L); final Folder folder = folderRepo.findById(-420L).get();
assertThat(folder, is(not(nullValue()))); assertThat(folder, is(not(nullValue())));
final File file = new File(); final File file = new File();
@ -224,7 +224,6 @@ public class AssetManagerTest {
assetManager.shareAsset(file, folder); assetManager.shareAsset(file, folder);
assertThat(file, is(not(nullValue())));
assertThat(file.getDisplayName(), is(equalTo("datasheet.pdf"))); assertThat(file.getDisplayName(), is(equalTo("datasheet.pdf")));
} }
@ -242,8 +241,7 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void shareAssetNull() { public void shareAssetNull() {
final Folder folder = folderRepo.findById(-420L); final Folder folder = folderRepo.findById(-420L).get();
assertThat(folder, is(not(nullValue())));
assetManager.shareAsset(null, folder); assetManager.shareAsset(null, folder);
} }
@ -286,11 +284,9 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void shareAlreadySharedAsset() { public void shareAlreadySharedAsset() {
final Folder folder = folderRepo.findById(-420L); final Folder folder = folderRepo.findById(-420L).get();
assertThat(folder, is(not(nullValue())));
final Asset asset = assetRepo.findById(-700L); final Asset asset = assetRepo.findById(-700L).get();
assertThat(asset, is(not(nullValue())));
assetManager.shareAsset(asset, folder); assetManager.shareAsset(asset, folder);
} }
@ -328,11 +324,9 @@ public class AssetManagerTest {
"object_order", "object_order",
"uuid"}) "uuid"})
public void moveAssetToOtherFolder() { public void moveAssetToOtherFolder() {
final Asset asset = assetRepo.findById(-900L); final Asset asset = assetRepo.findById(-900L).get();
assertThat(asset, is(not(nullValue())));
final Folder folder = folderRepo.findById(-410L); final Folder folder = folderRepo.findById(-410L).get();
assertThat(folder, is(not(nullValue())));
assetManager.move(asset, folder); assetManager.move(asset, folder);
} }
@ -354,11 +348,9 @@ public class AssetManagerTest {
"object_order", "object_order",
"uuid"}) "uuid"})
public void moveAssetToFolderInOtherContentSection() { public void moveAssetToFolderInOtherContentSection() {
final Asset asset = assetRepo.findById(-900L); final Asset asset = assetRepo.findById(-900L).get();
assertThat(asset, is(not(nullValue())));
final Folder folder = folderRepo.findById(-1600L); final Folder folder = folderRepo.findById(-1600L).get();
assertThat(folder, is(not(nullValue())));
assetManager.move(asset, folder); assetManager.move(asset, folder);
} }
@ -379,8 +371,7 @@ public class AssetManagerTest {
public void moveAssetNull() { public void moveAssetNull() {
final Asset asset = null; final Asset asset = null;
final Folder folder = folderRepo.findById(-410L); final Folder folder = folderRepo.findById(-410L).get();
assertThat(folder, is(not(nullValue())));
assetManager.move(asset, folder); assetManager.move(asset, folder);
} }
@ -399,8 +390,7 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveAssetTargetFolderIsNull() { public void moveAssetTargetFolderIsNull() {
final Asset asset = assetRepo.findById(-900L); final Asset asset = assetRepo.findById(-900L).get();
assertThat(asset, is(not(nullValue())));
final Folder targetFolder = null; final Folder targetFolder = null;
@ -421,11 +411,9 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveAssetTargetFolderIsNotAssetFolder() { public void moveAssetTargetFolderIsNotAssetFolder() {
final Asset asset = assetRepo.findById(-900L); final Asset asset = assetRepo.findById(-900L).get();
assertThat(asset, is(not(nullValue())));
final Folder folder = folderRepo.findById(-200L); final Folder folder = folderRepo.findById(-200L).get();
assertThat(folder, is(not(nullValue())));
assetManager.move(asset, folder); assetManager.move(asset, folder);
} }
@ -450,11 +438,9 @@ public class AssetManagerTest {
"categorization_id", "categorization_id",
"object_order"}) "object_order"})
public void copyAssetToOtherFolder() { public void copyAssetToOtherFolder() {
final Asset asset = assetRepo.findById(-1100L); final Asset asset = assetRepo.findById(-1100L).get();
assertThat(asset, is(not(nullValue())));
final Folder targetFolder = folderRepo.findById(-400L); final Folder targetFolder = folderRepo.findById(-400L).get();
assertThat(targetFolder, is(not(nullValue())));
assetManager.copy(asset, targetFolder); assetManager.copy(asset, targetFolder);
} }
@ -479,11 +465,9 @@ public class AssetManagerTest {
"categorization_id", "categorization_id",
"object_order"}) "object_order"})
public void copyAssetToSameFolder() { public void copyAssetToSameFolder() {
final Asset asset = assetRepo.findById(-1100L); final Asset asset = assetRepo.findById(-1100L).get();
assertThat(asset, is(not(nullValue())));
final Folder targetFolder = folderRepo.findById(-420L); final Folder targetFolder = folderRepo.findById(-420L).get();
assertThat(targetFolder, is(not(nullValue())));
assetManager.copy(asset, targetFolder); assetManager.copy(asset, targetFolder);
assetManager.copy(asset, targetFolder); assetManager.copy(asset, targetFolder);
@ -510,11 +494,9 @@ public class AssetManagerTest {
"categorization_id", "categorization_id",
"object_order"}) "object_order"})
public void copyAssetToOtherContentSection() { public void copyAssetToOtherContentSection() {
final Asset asset = assetRepo.findById(-1100L); final Asset asset = assetRepo.findById(-1100L).get();
assertThat(asset, is(not(nullValue())));
final Folder targetFolder = folderRepo.findById(-1600L); final Folder targetFolder = folderRepo.findById(-1600L).get();
assertThat(targetFolder, is(not(nullValue())));
assetManager.copy(asset, targetFolder); assetManager.copy(asset, targetFolder);
} }
@ -535,8 +517,7 @@ public class AssetManagerTest {
public void copyAssetNull() { public void copyAssetNull() {
final Asset asset = null; final Asset asset = null;
final Folder targetFolder = folderRepo.findById(-420L); final Folder targetFolder = folderRepo.findById(-420L).get();
assertThat(targetFolder, is(not(nullValue())));
assetManager.copy(asset, targetFolder); assetManager.copy(asset, targetFolder);
} }
@ -555,8 +536,7 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyAssetTargetFolderIsNull() { public void copyAssetTargetFolderIsNull() {
final Asset asset = assetRepo.findById(-1100L); final Asset asset = assetRepo.findById(-1100L).get();
assertThat(asset, is(not(nullValue())));
final Folder targetFolder = null; final Folder targetFolder = null;
@ -577,11 +557,9 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyAssetTargetFolderIsNotAssetFolder() { public void copyAssetTargetFolderIsNotAssetFolder() {
final Asset asset = assetRepo.findById(-1100L); final Asset asset = assetRepo.findById(-1100L).get();
assertThat(asset, is(not(nullValue())));
final Folder targetFolder = folderRepo.findById(-200L); final Folder targetFolder = folderRepo.findById(-200L).get();
assertThat(targetFolder, is(not(nullValue())));
assetManager.copy(asset, targetFolder); assetManager.copy(asset, targetFolder);
} }
@ -598,17 +576,11 @@ public class AssetManagerTest {
@ShouldMatchDataSet( @ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyIsAssetInUse() { public void verifyIsAssetInUse() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L); final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L); final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L); final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(header, is(not(nullValue())));
assertThat(phb, is(not(nullValue())));
assertThat(servicesHeader, is(not(nullValue())));
assertThat(product1Datasheet, is(not(nullValue())));
assertThat(catalog, is(not(nullValue())));
assertThat(assetManager.isAssetInUse(header), is(true)); assertThat(assetManager.isAssetInUse(header), is(true));
assertThat(assetManager.isAssetInUse(phb), is(false)); assertThat(assetManager.isAssetInUse(phb), is(false));
@ -629,17 +601,11 @@ public class AssetManagerTest {
@ShouldMatchDataSet( @ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetPathWithoutContentSection() { public void verifyGetAssetPathWithoutContentSection() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L); final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L); final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L); final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(header, is(not(nullValue())));
assertThat(phb, is(not(nullValue())));
assertThat(servicesHeader, is(not(nullValue())));
assertThat(product1Datasheet, is(not(nullValue())));
assertThat(catalog, is(not(nullValue())));
assertThat(assetManager.getAssetPath(header), assertThat(assetManager.getAssetPath(header),
is(equalTo("/media/images/header.png"))); is(equalTo("/media/images/header.png")));
@ -665,17 +631,11 @@ public class AssetManagerTest {
@ShouldMatchDataSet( @ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetPathWithContentSection() { public void verifyGetAssetPathWithContentSection() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L); final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L); final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L); final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(header, is(not(nullValue())));
assertThat(phb, is(not(nullValue())));
assertThat(servicesHeader, is(not(nullValue())));
assertThat(product1Datasheet, is(not(nullValue())));
assertThat(catalog, is(not(nullValue())));
assertThat(assetManager.getAssetPath(header, true), assertThat(assetManager.getAssetPath(header, true),
is(equalTo("info:/media/images/header.png"))); is(equalTo("info:/media/images/header.png")));
@ -701,25 +661,15 @@ public class AssetManagerTest {
@ShouldMatchDataSet( @ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetFolder() { public void verifyGetAssetFolder() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L); final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L); final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L); final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(header, is(not(nullValue()))); final Folder media = folderRepo.findById(-400L).get();
assertThat(phb, is(not(nullValue()))); final Folder images = folderRepo.findById(-410L).get();
assertThat(servicesHeader, is(not(nullValue()))); final Folder downloads = folderRepo.findById(-420L).get();
assertThat(product1Datasheet, is(not(nullValue())));
assertThat(catalog, is(not(nullValue())));
final Folder media = folderRepo.findById(-400L);
final Folder images = folderRepo.findById(-410L);
final Folder downloads = folderRepo.findById(-420L);
assertThat(media, is(not(nullValue())));
assertThat(images, is(not(nullValue())));
assertThat(downloads, is(not(nullValue())));
final Optional<Folder> headerFolder = assetManager final Optional<Folder> headerFolder = assetManager
.getAssetFolder(header); .getAssetFolder(header);
@ -756,27 +706,16 @@ public class AssetManagerTest {
@ShouldMatchDataSet( @ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml") "datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetFolders() { public void verifyGetAssetFolders() {
final Asset header = assetRepo.findById(-700L); final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L); final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L); final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L); final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L); final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(header, is(not(nullValue()))); final Folder infoAssets = folderRepo.findById(-300L).get();
assertThat(phb, is(not(nullValue()))); final Folder media = folderRepo.findById(-400L).get();
assertThat(servicesHeader, is(not(nullValue()))); final Folder images = folderRepo.findById(-410L).get();
assertThat(product1Datasheet, is(not(nullValue()))); final Folder downloads = folderRepo.findById(-420L).get();
assertThat(catalog, is(not(nullValue())));
final Folder infoAssets = folderRepo.findById(-300L);
final Folder media = folderRepo.findById(-400L);
final Folder images = folderRepo.findById(-410L);
final Folder downloads = folderRepo.findById(-420L);
assertThat(infoAssets, is(not(nullValue())));
assertThat(media, is(not(nullValue())));
assertThat(images, is(not(nullValue())));
assertThat(downloads, is(not(nullValue())));
final List<Folder> headerFolders = assetManager.getAssetFolders(header); final List<Folder> headerFolders = assetManager.getAssetFolders(header);
final List<Folder> phbFolders = assetManager.getAssetFolders(phb); final List<Folder> phbFolders = assetManager.getAssetFolders(phb);

View File

@ -199,9 +199,7 @@ public class AssetRepositoryTest {
excludeColumns = {"timestamp", "object_order"} excludeColumns = {"timestamp", "object_order"}
) )
public void deleteUnusedAsset() { public void deleteUnusedAsset() {
final Asset asset = assetRepo.findById(-800L); final Asset asset = assetRepo.findById(-800L).get();
assertThat(asset, is(not(nullValue())));
assetRepo.delete(asset); assetRepo.delete(asset);
} }
@ -220,9 +218,7 @@ public class AssetRepositoryTest {
+ "data.xml") + "data.xml")
@ShouldThrowException(AssetInUseException.class) @ShouldThrowException(AssetInUseException.class)
public void deleteUsedAsset() { public void deleteUsedAsset() {
final Asset asset = assetRepo.findById(-700L); final Asset asset = assetRepo.findById(-700L).get();
assertThat(asset, is(not(nullValue())));
assetRepo.delete(asset); assetRepo.delete(asset);
} }
@ -324,8 +320,8 @@ public class AssetRepositoryTest {
@UsingDataSet( @UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml") "datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void findAssetsByFolder() { public void findAssetsByFolder() {
final Folder media = folderRepo.findById(-400L); final Folder media = folderRepo.findById(-400L).get();
final Folder data = folderRepo.findById(-500L); final Folder data = folderRepo.findById(-500L).get();
final List<Asset> mediaAssets = assetRepo.findByFolder(media); final List<Asset> mediaAssets = assetRepo.findByFolder(media);
final List<Asset> dataAssets = assetRepo.findByFolder(data); final List<Asset> dataAssets = assetRepo.findByFolder(data);
@ -344,8 +340,8 @@ public class AssetRepositoryTest {
@UsingDataSet( @UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml") "datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void countAssetsInFolder() { public void countAssetsInFolder() {
final Folder media = folderRepo.findById(-400L); final Folder media = folderRepo.findById(-400L).get();
final Folder data = folderRepo.findById(-500L); final Folder data = folderRepo.findById(-500L).get();
assertThat(assetRepo.countAssetsInFolder(media), is(5L)); assertThat(assetRepo.countAssetsInFolder(media), is(5L));
assertThat(assetRepo.countAssetsInFolder(data), is(0L)); assertThat(assetRepo.countAssetsInFolder(data), is(0L));
@ -360,7 +356,7 @@ public class AssetRepositoryTest {
@UsingDataSet( @UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml") "datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void filterAssetByFolderAndName() { public void filterAssetByFolderAndName() {
final Folder media = folderRepo.findById(-400L); final Folder media = folderRepo.findById(-400L).get();
final List<Asset> result1 = assetRepo.filterByFolderAndName(media, final List<Asset> result1 = assetRepo.filterByFolderAndName(media,
"hea"); "hea");
@ -383,7 +379,7 @@ public class AssetRepositoryTest {
@UsingDataSet( @UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml") "datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void countFilterAssetByFolderAndName() { public void countFilterAssetByFolderAndName() {
final Folder media = folderRepo.findById(-400L); final Folder media = folderRepo.findById(-400L).get();
assertThat(assetRepo.countFilterByFolderAndName(media, "hea"), assertThat(assetRepo.countFilterByFolderAndName(media, "hea"),
is(1L)); is(1L));
@ -401,7 +397,7 @@ public class AssetRepositoryTest {
@UsingDataSet( @UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml") "datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void filterAssetsByFolderAndType() { public void filterAssetsByFolderAndType() {
final Folder media = folderRepo.findById(-400L); final Folder media = folderRepo.findById(-400L).get();
final List<Asset> images = assetRepo.filterByFolderAndType(media, final List<Asset> images = assetRepo.filterByFolderAndType(media,
Image.class); Image.class);
@ -434,7 +430,7 @@ public class AssetRepositoryTest {
@UsingDataSet( @UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml") "datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void countFilterAssetsByFolderAndType() { public void countFilterAssetsByFolderAndType() {
final Folder media = folderRepo.findById(-400L); final Folder media = folderRepo.findById(-400L).get();
assertThat(assetRepo.countFilterByFolderAndType(media, Image.class), assertThat(assetRepo.countFilterByFolderAndType(media, Image.class),
is(3L)); is(3L));
@ -454,7 +450,7 @@ public class AssetRepositoryTest {
@UsingDataSet( @UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml") "datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void filterAssetsByFolderAndTypeAndName() { public void filterAssetsByFolderAndTypeAndName() {
final Folder media = folderRepo.findById(-400L); final Folder media = folderRepo.findById(-400L).get();
final List<Asset> result1 = assetRepo.filterByFolderAndTypeAndName( final List<Asset> result1 = assetRepo.filterByFolderAndTypeAndName(
media, Image.class, "hea"); media, Image.class, "hea");
@ -476,7 +472,7 @@ public class AssetRepositoryTest {
@UsingDataSet( @UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml") "datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void countFilterAssetsByFolderAndTypeAndName() { public void countFilterAssetsByFolderAndTypeAndName() {
final Folder media = folderRepo.findById(-400L); final Folder media = folderRepo.findById(-400L).get();
assertThat(assetRepo.countFilterByFolderAndTypeAndName( assertThat(assetRepo.countFilterByFolderAndTypeAndName(
media, Image.class, "hea"), media, Image.class, "hea"),

View File

@ -372,7 +372,7 @@ public class ContentItemManagerTest {
final Folder folder = section.getRootDocumentsFolder(); final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L); .findById(-110L).get();
final Article article = itemManager.createContentItem( final Article article = itemManager.createContentItem(
"new-article", "new-article",
@ -417,7 +417,7 @@ public class ContentItemManagerTest {
final Folder folder = section.getRootDocumentsFolder(); final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L); .findById(-110L).get();
itemManager.createContentItem("Test", itemManager.createContentItem("Test",
section, section,
@ -446,7 +446,7 @@ public class ContentItemManagerTest {
final Folder folder = section.getRootDocumentsFolder(); final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L); .findById(-110L).get();
itemManager.createContentItem(null, itemManager.createContentItem(null,
section, section,
@ -500,7 +500,7 @@ public class ContentItemManagerTest {
final ContentSection section = sectionRepo.findByLabel("info"); final ContentSection section = sectionRepo.findByLabel("info");
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L); .findById(-110L).get();
itemManager.createContentItem("Test", itemManager.createContentItem("Test",
section, section,
@ -534,7 +534,7 @@ public class ContentItemManagerTest {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final Folder targetFolder = folderRepo.findById(-2120L); final Folder targetFolder = folderRepo.findById(-2120L).get();
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.move(item.get(), targetFolder); itemManager.move(item.get(), targetFolder);
@ -562,7 +562,7 @@ public class ContentItemManagerTest {
}) })
public void moveItemToOtherContentSection() { public void moveItemToOtherContentSection() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
final Folder targetFolder = folderRepo.findById(-2300L); final Folder targetFolder = folderRepo.findById(-2300L).get();
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
@ -585,7 +585,7 @@ public class ContentItemManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveToOtherContentSectionTypeNotPresent() { public void moveToOtherContentSectionTypeNotPresent() {
final Optional<ContentItem> item = itemRepo.findById(-10400L); final Optional<ContentItem> item = itemRepo.findById(-10400L);
final Folder targetFolder = folderRepo.findById(-2300L); final Folder targetFolder = folderRepo.findById(-2300L).get();
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
@ -607,7 +607,7 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveItemNull() { public void moveItemNull() {
final Folder targetFolder = folderRepo.findById(-2120L); final Folder targetFolder = folderRepo.findById(-2120L).get();
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.move(null, targetFolder); itemManager.move(null, targetFolder);
@ -665,7 +665,7 @@ public class ContentItemManagerTest {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final Folder targetFolder = folderRepo.findById(-2120L); final Folder targetFolder = folderRepo.findById(-2120L).get();
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.copy(item.get(), targetFolder); itemManager.copy(item.get(), targetFolder);
@ -701,7 +701,7 @@ public class ContentItemManagerTest {
}) })
public void copyToFolderInOtherSection() { public void copyToFolderInOtherSection() {
final Optional<ContentItem> source = itemRepo.findById(-10100L); final Optional<ContentItem> source = itemRepo.findById(-10100L);
final Folder targetFolder = folderRepo.findById(-2300L); final Folder targetFolder = folderRepo.findById(-2300L).get();
assertThat(source.isPresent(), is(true)); assertThat(source.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
@ -728,7 +728,7 @@ public class ContentItemManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyToFolderInOtherSectionTypeNotPresent() { public void copyToFolderInOtherSectionTypeNotPresent() {
final Optional<ContentItem> source = itemRepo.findById(-10400L); final Optional<ContentItem> source = itemRepo.findById(-10400L);
final Folder targetFolder = folderRepo.findById(-2300L); final Folder targetFolder = folderRepo.findById(-2300L).get();
assertThat(source.isPresent(), is(true)); assertThat(source.isPresent(), is(true));
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
@ -770,7 +770,7 @@ public class ContentItemManagerTest {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final Folder targetFolder = folderRepo.findById(-2110L); final Folder targetFolder = folderRepo.findById(-2110L).get();
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.copy(item.get(), targetFolder); itemManager.copy(item.get(), targetFolder);
@ -791,7 +791,7 @@ public class ContentItemManagerTest {
+ "ContentItemManagerTest/data.xml") + "ContentItemManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void copyItemNull() { public void copyItemNull() {
final Folder targetFolder = folderRepo.findById(-2120L); final Folder targetFolder = folderRepo.findById(-2120L).get();
assertThat(targetFolder, is(not(nullValue()))); assertThat(targetFolder, is(not(nullValue())));
itemManager.copy(null, targetFolder); itemManager.copy(null, targetFolder);
@ -892,7 +892,7 @@ public class ContentItemManagerTest {
public void publishItemWithLifecycle() { public void publishItemWithLifecycle() {
final Optional<ContentItem> item = itemRepo.findById(-10100L); final Optional<ContentItem> item = itemRepo.findById(-10100L);
final LifecycleDefinition lifecycleDef = lifecycleDefinitionRepo final LifecycleDefinition lifecycleDef = lifecycleDefinitionRepo
.findById(-200L); .findById(-200L).get();
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
assertThat(lifecycleDef, is(not(nullValue()))); assertThat(lifecycleDef, is(not(nullValue())));

View File

@ -50,7 +50,11 @@ import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import org.jboss.arquillian.persistence.CleanupUsingScript; import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.libreccm.security.User;
import java.util.Optional;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -102,8 +106,8 @@ public class ContentItemPermissionTest {
public static WebArchive createDeployment() { public static WebArchive createDeployment() {
return ShrinkWrap return ShrinkWrap
.create(WebArchive.class, .create(WebArchive.class,
"LibreCCM-org.librecms.contentsection.ContentItemPermissionTest.war"). "LibreCCM-org.librecms.contentsection.ContentItemPermissionTest.war")
addPackage(org.libreccm.auditing.CcmRevision.class.getPackage()) .addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
.addPackage(org.libreccm.categorization.Categorization.class .addPackage(org.libreccm.categorization.Categorization.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage()) .addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
@ -130,12 +134,12 @@ public class ContentItemPermissionTest {
com.arsdigita.cms.dispatcher.ContentItemDispatcher.class). com.arsdigita.cms.dispatcher.ContentItemDispatcher.class).
addClass(com.arsdigita.dispatcher.Dispatcher.class) addClass(com.arsdigita.dispatcher.Dispatcher.class)
.addClass( .addClass(
com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class). com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class)
addClass( .addClass(
com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class). com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class)
addClass( .addClass(
com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class). com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class)
addClass( .addClass(
com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class) com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class)
.addClass(org.librecms.dispatcher.ItemResolver.class) .addClass(org.librecms.dispatcher.ItemResolver.class)
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
@ -183,12 +187,13 @@ public class ContentItemPermissionTest {
+ "ContentItemPermissionTest/data.xml") + "ContentItemPermissionTest/data.xml")
public void accessByNoUser() { public void accessByNoUser() {
final List<Role> roles; final List<Role> roles;
if (shiro.getUser() == null) { final Optional<User> user = shiro.getUser();
roles = new ArrayList<>(); if (user.isPresent()) {
} else { roles = user.get().getRoleMemberships().stream()
roles = shiro.getUser().getRoleMemberships().stream()
.map(membership -> membership.getRole()) .map(membership -> membership.getRole())
.collect(Collectors.toList()); .collect(Collectors.toList());
} else {
roles = new ArrayList<>();
} }
final TypedQuery<ContentItem> query = entityManager.createQuery( final TypedQuery<ContentItem> query = entityManager.createQuery(
@ -209,7 +214,8 @@ public class ContentItemPermissionTest {
token.setRememberMe(true); token.setRememberMe(true);
subject.login(token); subject.login(token);
final List<Role> roles = shiro.getUser().getRoleMemberships().stream() final List<Role> roles = shiro.getUser().get().getRoleMemberships()
.stream()
.map(membership -> membership.getRole()) .map(membership -> membership.getRole())
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -233,7 +239,8 @@ public class ContentItemPermissionTest {
token.setRememberMe(true); token.setRememberMe(true);
subject.login(token); subject.login(token);
final List<Role> roles = shiro.getUser().getRoleMemberships().stream() final List<Role> roles = shiro.getUser().get().getRoleMemberships()
.stream()
.map(membership -> membership.getRole()) .map(membership -> membership.getRole())
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -256,7 +263,8 @@ public class ContentItemPermissionTest {
token.setRememberMe(true); token.setRememberMe(true);
subject.login(token); subject.login(token);
final List<Role> roles = shiro.getUser().getRoleMemberships().stream() final List<Role> roles = shiro.getUser().get().getRoleMemberships()
.stream()
.map(membership -> membership.getRole()) .map(membership -> membership.getRole())
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -238,7 +238,7 @@ public class ContentItemRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemRepositoryTest/data.xml") + "ContentItemRepositoryTest/data.xml")
public void findByFolder() { public void findByFolder() {
final Category folder = categoryRepo.findById(-2100L); final Category folder = categoryRepo.findById(-2100L).get();
assertThat(folder.getObjects().size(), is(4)); assertThat(folder.getObjects().size(), is(4));
@ -253,7 +253,7 @@ public class ContentItemRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemRepositoryTest/data.xml") + "ContentItemRepositoryTest/data.xml")
public void countItemsInFolder() { public void countItemsInFolder() {
final Category folder = categoryRepo.findById(-2100L); final Category folder = categoryRepo.findById(-2100L).get();
assertThat(itemRepo.countItemsInFolder(folder), is(4L)); assertThat(itemRepo.countItemsInFolder(folder), is(4L));
} }
@ -263,7 +263,7 @@ public class ContentItemRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemRepositoryTest/data.xml") + "ContentItemRepositoryTest/data.xml")
public void countByNameInFolder() { public void countByNameInFolder() {
final Category folder = categoryRepo.findById(-2100L); final Category folder = categoryRepo.findById(-2100L).get();
assertThat(itemRepo.countByNameInFolder(folder, "article1"), is(1L)); assertThat(itemRepo.countByNameInFolder(folder, "article1"), is(1L));
assertThat(itemRepo.countByNameInFolder(folder, "article2"), is(1L)); assertThat(itemRepo.countByNameInFolder(folder, "article2"), is(1L));
@ -278,7 +278,7 @@ public class ContentItemRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemRepositoryTest/data.xml") + "ContentItemRepositoryTest/data.xml")
public void filterByFolderAndName() { public void filterByFolderAndName() {
final Category folder = categoryRepo.findById(-2100L); final Category folder = categoryRepo.findById(-2100L).get();
final List<ContentItem> articles = itemRepo.filterByFolderAndName( final List<ContentItem> articles = itemRepo.filterByFolderAndName(
folder, "article"); folder, "article");
@ -300,7 +300,7 @@ public class ContentItemRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentItemRepositoryTest/data.xml") + "ContentItemRepositoryTest/data.xml")
public void countFilterByFolderAndName() { public void countFilterByFolderAndName() {
final Category folder = categoryRepo.findById(-2100L); final Category folder = categoryRepo.findById(-2100L).get();
assertThat(itemRepo.countFilterByFolderAndName(folder, "article"), assertThat(itemRepo.countFilterByFolderAndName(folder, "article"),
is(3L)); is(3L));

View File

@ -374,7 +374,7 @@ public class ContentSectionManagerTest {
@InSequence(350) @InSequence(350)
public void removeRole() { public void removeRole() {
final ContentSection section = repository.findByLabel("info"); final ContentSection section = repository.findByLabel("info");
final Role role = roleRepository.findByName("info_publisher"); final Role role = roleRepository.findByName("info_publisher").get();
manager.removeRoleFromContentSection(section, role); manager.removeRoleFromContentSection(section, role);
} }
@ -412,7 +412,7 @@ public class ContentSectionManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(352) @InSequence(352)
public void removeRoleSectionIsNull() { public void removeRoleSectionIsNull() {
final Role role = roleRepository.findByName("info_publisher"); final Role role = roleRepository.findByName("info_publisher").get();
manager.removeRoleFromContentSection(null, role); manager.removeRoleFromContentSection(null, role);
} }
@ -433,15 +433,11 @@ public class ContentSectionManagerTest {
"creation_date"}) "creation_date"})
@InSequence(400) @InSequence(400)
public void addContentTypeToSection() { public void addContentTypeToSection() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L); .findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14001L); .findById(-14001L).get();
assertThat(section, is(not(nullValue())));
assertThat(lifecycleDef, is(not(nullValue())));
assertThat(workflowTemplate, is(not(nullValue())));
manager.addContentTypeToSection(Event.class, manager.addContentTypeToSection(Event.class,
section, section,
@ -462,15 +458,11 @@ public class ContentSectionManagerTest {
+ "ContentSectionManagerTest/data.xml") + "ContentSectionManagerTest/data.xml")
@InSequence(500) @InSequence(500)
public void addAlreadyAddedContentTypeToSection() { public void addAlreadyAddedContentTypeToSection() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L); .findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14002L); .findById(-14002L).get();
assertThat(section, is(not(nullValue())));
assertThat(lifecycleDef, is(not(nullValue())));
assertThat(workflowTemplate, is(not(nullValue())));
manager.addContentTypeToSection(News.class, manager.addContentTypeToSection(News.class,
section, section,
@ -492,15 +484,11 @@ public class ContentSectionManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(600) @InSequence(600)
public void addContentTypeToSectionTypeIsNull() { public void addContentTypeToSectionTypeIsNull() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L); .findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14002L); .findById(-14002L).get();
assertThat(section, is(not(nullValue())));
assertThat(lifecycleDef, is(not(nullValue())));
assertThat(workflowTemplate, is(not(nullValue())));
manager.addContentTypeToSection(null, manager.addContentTypeToSection(null,
section, section,
@ -524,12 +512,9 @@ public class ContentSectionManagerTest {
@InSequence(700) @InSequence(700)
public void addContentTypeToSectionSectionIsNull() { public void addContentTypeToSectionSectionIsNull() {
final LifecycleDefinition lifecycleDef = lifecycleDefRepo final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L); .findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14002L); .findById(-14002L).get();
assertThat(lifecycleDef, is(not(nullValue())));
assertThat(workflowTemplate, is(not(nullValue())));
manager.addContentTypeToSection(Event.class, manager.addContentTypeToSection(Event.class,
null, null,
@ -551,12 +536,9 @@ public class ContentSectionManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(800) @InSequence(800)
public void addContentTypeToSectionLifecycleIsNull() { public void addContentTypeToSectionLifecycleIsNull() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14001L); .findById(-14001L).get();
assertThat(section, is(not(nullValue())));
assertThat(workflowTemplate, is(not(nullValue())));
manager.addContentTypeToSection(Event.class, manager.addContentTypeToSection(Event.class,
section, section,
@ -578,12 +560,9 @@ public class ContentSectionManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(900) @InSequence(900)
public void addContentTypeToSectionWorkflowIsNull() { public void addContentTypeToSectionWorkflowIsNull() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L); .findById(-13002L).get();
assertThat(section, is(not(nullValue())));
assertThat(lifecycleDef, is(not(nullValue())));
manager.addContentTypeToSection(Event.class, manager.addContentTypeToSection(Event.class,
section, section,
@ -606,15 +585,11 @@ public class ContentSectionManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(1000) @InSequence(1000)
public void addContentTypeToSectionLifecycleNotInSection() { public void addContentTypeToSectionLifecycleNotInSection() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13003L); .findById(-13003L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14001L); .findById(-14001L).get();
assertThat(section, is(not(nullValue())));
assertThat(lifecycleDef, is(not(nullValue())));
assertThat(workflowTemplate, is(not(nullValue())));
manager.addContentTypeToSection(Event.class, manager.addContentTypeToSection(Event.class,
section, section,
@ -636,15 +611,11 @@ public class ContentSectionManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(1100) @InSequence(1100)
public void addContentTypeToSectionWorkflowNoInSection() { public void addContentTypeToSectionWorkflowNoInSection() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L); .findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14003L); .findById(-14003L).get();
assertThat(section, is(not(nullValue())));
assertThat(lifecycleDef, is(not(nullValue())));
assertThat(workflowTemplate, is(not(nullValue())));
manager.addContentTypeToSection(Event.class, manager.addContentTypeToSection(Event.class,
section, section,
@ -661,7 +632,7 @@ public class ContentSectionManagerTest {
+ "ContentSectionManagerTest/data.xml") + "ContentSectionManagerTest/data.xml")
@InSequence(1200) @InSequence(1200)
public void verifyHasContentType() { public void verifyHasContentType() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
assertThat(manager.hasContentType(Article.class, section), is(true)); assertThat(manager.hasContentType(Article.class, section), is(true));
assertThat(manager.hasContentType(News.class, section), is(true)); assertThat(manager.hasContentType(News.class, section), is(true));
@ -679,7 +650,7 @@ public class ContentSectionManagerTest {
+ "ContentSectionManagerTest/after-remove-contenttype.xml") + "ContentSectionManagerTest/after-remove-contenttype.xml")
@InSequence(1300) @InSequence(1300)
public void removeContentTypeFromSection() { public void removeContentTypeFromSection() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
manager.removeContentTypeFromSection(News.class, section); manager.removeContentTypeFromSection(News.class, section);
} }
@ -698,7 +669,7 @@ public class ContentSectionManagerTest {
+ "ContentSectionManagerTest/data.xml") + "ContentSectionManagerTest/data.xml")
@InSequence(1301) @InSequence(1301)
public void removeNotExistingContentTypeFromSection() { public void removeNotExistingContentTypeFromSection() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
manager.removeContentTypeFromSection(Event.class, section); manager.removeContentTypeFromSection(Event.class, section);
} }
@ -718,7 +689,7 @@ public class ContentSectionManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(1400) @InSequence(1400)
public void removeContentTypeFromSectionTypeInUse() { public void removeContentTypeFromSectionTypeInUse() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
manager.removeContentTypeFromSection(Article.class, section); manager.removeContentTypeFromSection(Article.class, section);
} }
@ -738,7 +709,7 @@ public class ContentSectionManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(1400) @InSequence(1400)
public void removeContentTypeFromSectionTypeIsNull() { public void removeContentTypeFromSectionTypeIsNull() {
final ContentSection section = repository.findById(-1100L); final ContentSection section = repository.findById(-1100L).get();
manager.removeContentTypeFromSection(null, section); manager.removeContentTypeFromSection(null, section);
} }

View File

@ -177,7 +177,7 @@ public class ContentTypeRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentTypeRepositoryTest/data.xml") + "ContentTypeRepositoryTest/data.xml")
public void findByContentSection() { public void findByContentSection() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final List<ContentType> types = contentTypeRepo.findByContentSection( final List<ContentType> types = contentTypeRepo.findByContentSection(
section); section);
@ -220,7 +220,7 @@ public class ContentTypeRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentTypeRepositoryTest/data.xml") + "ContentTypeRepositoryTest/data.xml")
public void findByContentSectionAndClass() { public void findByContentSectionAndClass() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final Optional<ContentType> articleType = contentTypeRepo final Optional<ContentType> articleType = contentTypeRepo
.findByContentSectionAndClass(section, Article.class); .findByContentSectionAndClass(section, Article.class);
final Optional<ContentType> newsType = contentTypeRepo final Optional<ContentType> newsType = contentTypeRepo
@ -271,7 +271,7 @@ public class ContentTypeRepositoryTest {
+ "ContentTypeRepositoryTest/data.xml") + "ContentTypeRepositoryTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void findByContentSectionAndClassNull() { public void findByContentSectionAndClassNull() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final Class<? extends ContentItem> type = null; final Class<? extends ContentItem> type = null;
contentTypeRepo.findByContentSectionAndClass(section, type); contentTypeRepo.findByContentSectionAndClass(section, type);
} }
@ -286,7 +286,7 @@ public class ContentTypeRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentTypeRepositoryTest/data.xml") + "ContentTypeRepositoryTest/data.xml")
public void findByContentSectionAndClassName() { public void findByContentSectionAndClassName() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final Optional<ContentType> articleType = contentTypeRepo final Optional<ContentType> articleType = contentTypeRepo
.findByContentSectionAndClass(section, Article.class.getName()); .findByContentSectionAndClass(section, Article.class.getName());
final Optional<ContentType> newsType = contentTypeRepo final Optional<ContentType> newsType = contentTypeRepo
@ -339,7 +339,7 @@ public class ContentTypeRepositoryTest {
+ "ContentTypeRepositoryTest/data.xml") + "ContentTypeRepositoryTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void findByContentSectionAndClassNameNull() { public void findByContentSectionAndClassNameNull() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final String type = null; final String type = null;
contentTypeRepo.findByContentSectionAndClass(section, type); contentTypeRepo.findByContentSectionAndClass(section, type);
} }
@ -353,7 +353,7 @@ public class ContentTypeRepositoryTest {
@UsingDataSet("datasets/org/librecms/contentsection/" @UsingDataSet("datasets/org/librecms/contentsection/"
+ "ContentTypeRepositoryTest/data.xml") + "ContentTypeRepositoryTest/data.xml")
public void verifyIsContentTypeInUse() { public void verifyIsContentTypeInUse() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final Optional<ContentType> articleType = contentTypeRepo final Optional<ContentType> articleType = contentTypeRepo
.findByContentSectionAndClass(section, Article.class); .findByContentSectionAndClass(section, Article.class);
final Optional<ContentType> newsType = contentTypeRepo final Optional<ContentType> newsType = contentTypeRepo
@ -378,7 +378,7 @@ public class ContentTypeRepositoryTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ContentTypeRepositoryTest/after-delete.xml") + "ContentTypeRepositoryTest/after-delete.xml")
public void deleteUnusedContentType() { public void deleteUnusedContentType() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final Optional<ContentType> newsType = contentTypeRepo final Optional<ContentType> newsType = contentTypeRepo
.findByContentSectionAndClass(section, News.class); .findByContentSectionAndClass(section, News.class);
assertThat(newsType.isPresent(), is(true)); assertThat(newsType.isPresent(), is(true));
@ -398,7 +398,7 @@ public class ContentTypeRepositoryTest {
+ "ContentTypeRepositoryTest/data.xml") + "ContentTypeRepositoryTest/data.xml")
@ShouldThrowException(UnauthorizedException.class) @ShouldThrowException(UnauthorizedException.class)
public void deleteUnusedContentTypeUnauthorized() { public void deleteUnusedContentTypeUnauthorized() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final Optional<ContentType> newsType = contentTypeRepo final Optional<ContentType> newsType = contentTypeRepo
.findByContentSectionAndClass(section, News.class); .findByContentSectionAndClass(section, News.class);
assertThat(newsType.isPresent(), is(true)); assertThat(newsType.isPresent(), is(true));
@ -418,7 +418,7 @@ public class ContentTypeRepositoryTest {
+ "ContentTypeRepositoryTest/data.xml") + "ContentTypeRepositoryTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void deleteContentTypeInUse() { public void deleteContentTypeInUse() {
final ContentSection section = contentSectionRepo.findById(-1001L); final ContentSection section = contentSectionRepo.findById(-1001L).get();
final Optional<ContentType> articleType = contentTypeRepo final Optional<ContentType> articleType = contentTypeRepo
.findByContentSectionAndClass(section, Article.class); .findByContentSectionAndClass(section, Article.class);
assertThat(articleType.isPresent(), is(true)); assertThat(articleType.isPresent(), is(true));

View File

@ -43,8 +43,11 @@ import org.junit.runner.RunWith;
import org.libreccm.tests.categories.IntegrationTest; import org.libreccm.tests.categories.IntegrationTest;
import javax.inject.Inject; import javax.inject.Inject;
import org.jboss.arquillian.persistence.CleanupUsingScript; import org.jboss.arquillian.persistence.CleanupUsingScript;
import java.util.Optional;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -165,10 +168,10 @@ public class FolderManagerTest {
"content_section_id"}) "content_section_id"})
@InSequence(1000) @InSequence(1000)
public void createDocumentsFolder() { public void createDocumentsFolder() {
final Folder parent = folderRepo.findById(-2005L); final Optional<Folder> parent = folderRepo.findById(-2005L);
assertThat(parent, is(not(nullValue()))); assertThat(parent.isPresent(), is(true));
final Folder test = folderManager.createFolder("test", parent); final Folder test = folderManager.createFolder("test", parent.get());
assertThat(test, is(not(nullValue()))); assertThat(test, is(not(nullValue())));
assertThat(test.getName(), is(equalTo("test"))); assertThat(test.getName(), is(equalTo("test")));
@ -189,10 +192,10 @@ public class FolderManagerTest {
"content_section_id"}) "content_section_id"})
@InSequence(1100) @InSequence(1100)
public void createAssetsFolder() { public void createAssetsFolder() {
final Folder parent = folderRepo.findById(-2013L); final Optional<Folder> parent = folderRepo.findById(-2013L);
assertThat(parent, is(not(nullValue()))); assertThat(parent.isPresent(), is(true));
final Folder test = folderManager.createFolder("test", parent); final Folder test = folderManager.createFolder("test", parent.get());
assertThat(test, is(not(nullValue()))); assertThat(test, is(not(nullValue())));
assertThat(test.getName(), is(equalTo("test"))); assertThat(test.getName(), is(equalTo("test")));
@ -220,10 +223,10 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(1500) @InSequence(1500)
public void createFolderNullName() { public void createFolderNullName() {
final Folder parent = folderRepo.findById(-2005L); final Optional<Folder> parent = folderRepo.findById(-2005L);
assertThat(parent, is(not(nullValue()))); assertThat(parent.isPresent(), is(true));
final Folder test = folderManager.createFolder(null, parent); final Folder test = folderManager.createFolder(null, parent.get());
} }
@ -236,10 +239,10 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(1500) @InSequence(1500)
public void createFolderEmptyName() { public void createFolderEmptyName() {
final Folder parent = folderRepo.findById(-2005L); final Optional<Folder> parent = folderRepo.findById(-2005L);
assertThat(parent, is(not(nullValue()))); assertThat(parent.isPresent(), is(false));
final Folder test = folderManager.createFolder(" ", parent); final Folder test = folderManager.createFolder(" ", parent.get());
} }
@ -253,7 +256,7 @@ public class FolderManagerTest {
@InSequence(2000) @InSequence(2000)
public void deleteFolder() { public void deleteFolder() {
//docs-1-1-1 //docs-1-1-1
final Folder folder = folderRepo.findById(-2007L); final Folder folder = folderRepo.findById(-2007L).get();
folderManager.deleteFolder(folder); folderManager.deleteFolder(folder);
} }
@ -266,7 +269,7 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(2100) @InSequence(2100)
public void deleteNonEmptyFolder() { public void deleteNonEmptyFolder() {
final Folder folder = folderRepo.findById(-2008L); final Folder folder = folderRepo.findById(-2008L).get();
folderManager.deleteFolder(folder); folderManager.deleteFolder(folder);
} }
@ -279,7 +282,7 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(2100) @InSequence(2100)
public void deleteNonEmptySubFolder() { public void deleteNonEmptySubFolder() {
final Folder folder = folderRepo.findById(-2006L); final Folder folder = folderRepo.findById(-2006L).get();
folderManager.deleteFolder(folder); folderManager.deleteFolder(folder);
} }
@ -292,7 +295,7 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(2210) @InSequence(2210)
public void deleteRootFolder() { public void deleteRootFolder() {
final Folder folder = folderRepo.findById(-2003L); final Folder folder = folderRepo.findById(-2003L).get();
folderManager.deleteFolder(folder); folderManager.deleteFolder(folder);
} }
@ -318,8 +321,8 @@ public class FolderManagerTest {
@InSequence(3000) @InSequence(3000)
public void moveFolder() { public void moveFolder() {
//docs-1-1-2 to docs-2 //docs-1-1-2 to docs-2
final Folder folder = folderRepo.findById(-2008L); final Folder folder = folderRepo.findById(-2008L).get();
final Folder target = folderRepo.findById(-2010L); final Folder target = folderRepo.findById(-2010L).get();
folderManager.moveFolder(folder, target); folderManager.moveFolder(folder, target);
} }
@ -335,8 +338,8 @@ public class FolderManagerTest {
public void moveFolderTargetFolderSameName() { public void moveFolderTargetFolderSameName() {
//docs-1/downloads to /docs-2/ //docs-1/downloads to /docs-2/
final Folder folder = folderRepo.findById(-2009L); final Folder folder = folderRepo.findById(-2009L).get();
final Folder target = folderRepo.findById(-2010L); final Folder target = folderRepo.findById(-2010L).get();
folderManager.moveFolder(folder, target); folderManager.moveFolder(folder, target);
} }
@ -350,8 +353,8 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(3100) @InSequence(3100)
public void moveDocumentsFolderToAssetsFolder() { public void moveDocumentsFolderToAssetsFolder() {
final Folder folder = folderRepo.findById(-2009L); final Folder folder = folderRepo.findById(-2009L).get();
final Folder target = folderRepo.findById(-2014L); final Folder target = folderRepo.findById(-2014L).get();
folderManager.moveFolder(folder, target); folderManager.moveFolder(folder, target);
} }
@ -365,8 +368,8 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(3110) @InSequence(3110)
public void moveAssetsFolderToDocumentsFolder() { public void moveAssetsFolderToDocumentsFolder() {
final Folder folder = folderRepo.findById(-2014L); final Folder folder = folderRepo.findById(-2014L).get();
final Folder target = folderRepo.findById(-2010L); final Folder target = folderRepo.findById(-2010L).get();
folderManager.moveFolder(folder, target); folderManager.moveFolder(folder, target);
} }
@ -380,7 +383,7 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(3110) @InSequence(3110)
public void moveFolderToItself() { public void moveFolderToItself() {
final Folder folder = folderRepo.findById(-2008L); final Folder folder = folderRepo.findById(-2008L).get();
folderManager.moveFolder(folder, folder); folderManager.moveFolder(folder, folder);
} }
@ -394,7 +397,7 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(3200) @InSequence(3200)
public void moveFolderNull() { public void moveFolderNull() {
final Folder target = folderRepo.findById(-2010L); final Folder target = folderRepo.findById(-2010L).get();
folderManager.moveFolder(null, target); folderManager.moveFolder(null, target);
} }
@ -407,7 +410,7 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(3210) @InSequence(3210)
public void moveFolderTargetNull() { public void moveFolderTargetNull() {
final Folder folder = folderRepo.findById(-2008L); final Folder folder = folderRepo.findById(-2008L).get();
folderManager.moveFolder(folder, null); folderManager.moveFolder(folder, null);
} }
@ -421,8 +424,8 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(3300) @InSequence(3300)
public void moveFolderWithLiveItems() { public void moveFolderWithLiveItems() {
final Folder folder = folderRepo.findById(-2011L); final Folder folder = folderRepo.findById(-2011L).get();
final Folder target = folderRepo.findById(-2010L); final Folder target = folderRepo.findById(-2010L).get();
folderManager.moveFolder(folder, target); folderManager.moveFolder(folder, target);
} }
@ -436,8 +439,8 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(3310) @InSequence(3310)
public void moveFolderWithLiveItemsInSubFolder() { public void moveFolderWithLiveItemsInSubFolder() {
final Folder folder = folderRepo.findById(-2010L); final Folder folder = folderRepo.findById(-2010L).get();
final Folder target = folderRepo.findById(-2005L); final Folder target = folderRepo.findById(-2005L).get();
folderManager.moveFolder(folder, target); folderManager.moveFolder(folder, target);
} }
@ -451,8 +454,8 @@ public class FolderManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
@InSequence(3320) @InSequence(3320)
public void moveFolderToOtherSection() { public void moveFolderToOtherSection() {
final Folder folder = folderRepo.findById(-2008L); final Folder folder = folderRepo.findById(-2008L).get();
final Folder target = folderRepo.findById(-2003L); final Folder target = folderRepo.findById(-2003L).get();
folderManager.moveFolder(folder, target); folderManager.moveFolder(folder, target);
} }
@ -462,21 +465,21 @@ public class FolderManagerTest {
+ "FolderManagerTest/data.xml") + "FolderManagerTest/data.xml")
@InSequence(3400) @InSequence(3400)
public void getFolderPath() { public void getFolderPath() {
final Folder infoRoot = folderRepo.findById(-2001L); final Folder infoRoot = folderRepo.findById(-2001L).get();
final Folder infoAssets = folderRepo.findById(-2002L); final Folder infoAssets = folderRepo.findById(-2002L).get();
final Folder projectsRoot = folderRepo.findById(-2003L); final Folder projectsRoot = folderRepo.findById(-2003L).get();
final Folder projectsAssets = folderRepo.findById(-2004L); final Folder projectsAssets = folderRepo.findById(-2004L).get();
final Folder docs1 = folderRepo.findById(-2005L); final Folder docs1 = folderRepo.findById(-2005L).get();
final Folder docs11 = folderRepo.findById(-2006L); final Folder docs11 = folderRepo.findById(-2006L).get();
final Folder docs111 = folderRepo.findById(-2007L); final Folder docs111 = folderRepo.findById(-2007L).get();
final Folder docs112 = folderRepo.findById(-2008L); final Folder docs112 = folderRepo.findById(-2008L).get();
final Folder downloads1 = folderRepo.findById(-2009L); final Folder downloads1 = folderRepo.findById(-2009L).get();
final Folder docs2 = folderRepo.findById(-2010L); final Folder docs2 = folderRepo.findById(-2010L).get();
final Folder docs21 = folderRepo.findById(-2011L); final Folder docs21 = folderRepo.findById(-2011L).get();
final Folder downloads2 = folderRepo.findById(-2012L); final Folder downloads2 = folderRepo.findById(-2012L).get();
final Folder assets1 = folderRepo.findById(-2013L); final Folder assets1 = folderRepo.findById(-2013L).get();
final Folder assets11 = folderRepo.findById(-2014L); final Folder assets11 = folderRepo.findById(-2014L).get();
final Folder assets12 = folderRepo.findById(-2015L); final Folder assets12 = folderRepo.findById(-2015L).get();
assertThat(folderManager.getFolderPath(infoRoot), assertThat(folderManager.getFolderPath(infoRoot),
is(equalTo("/info_root/"))); is(equalTo("/info_root/")));
@ -515,21 +518,21 @@ public class FolderManagerTest {
+ "FolderManagerTest/data.xml") + "FolderManagerTest/data.xml")
@InSequence(3410) @InSequence(3410)
public void getFolderPathWithContentSection() { public void getFolderPathWithContentSection() {
final Folder infoRoot = folderRepo.findById(-2001L); final Folder infoRoot = folderRepo.findById(-2001L).get();
final Folder infoAssets = folderRepo.findById(-2002L); final Folder infoAssets = folderRepo.findById(-2002L).get();
final Folder projectsRoot = folderRepo.findById(-2003L); final Folder projectsRoot = folderRepo.findById(-2003L).get();
final Folder projectsAssets = folderRepo.findById(-2004L); final Folder projectsAssets = folderRepo.findById(-2004L).get();
final Folder docs1 = folderRepo.findById(-2005L); final Folder docs1 = folderRepo.findById(-2005L).get();
final Folder docs11 = folderRepo.findById(-2006L); final Folder docs11 = folderRepo.findById(-2006L).get();
final Folder docs111 = folderRepo.findById(-2007L); final Folder docs111 = folderRepo.findById(-2007L).get();
final Folder docs112 = folderRepo.findById(-2008L); final Folder docs112 = folderRepo.findById(-2008L).get();
final Folder downloads1 = folderRepo.findById(-2009L); final Folder downloads1 = folderRepo.findById(-2009L).get();
final Folder docs2 = folderRepo.findById(-2010L); final Folder docs2 = folderRepo.findById(-2010L).get();
final Folder docs21 = folderRepo.findById(-2011L); final Folder docs21 = folderRepo.findById(-2011L).get();
final Folder downloads2 = folderRepo.findById(-2012L); final Folder downloads2 = folderRepo.findById(-2012L).get();
final Folder assets1 = folderRepo.findById(-2013L); final Folder assets1 = folderRepo.findById(-2013L).get();
final Folder assets11 = folderRepo.findById(-2014L); final Folder assets11 = folderRepo.findById(-2014L).get();
final Folder assets12 = folderRepo.findById(-2015L); final Folder assets12 = folderRepo.findById(-2015L).get();
assertThat(folderManager.getFolderPath(infoRoot, true), assertThat(folderManager.getFolderPath(infoRoot, true),
is(equalTo("info:/info_root/"))); is(equalTo("info:/info_root/")));

View File

@ -207,11 +207,7 @@ public class ItemAttachmentManagerTest {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
// final File file = new File(); final Asset file = assetRepo.findById(-720L).get();
// file.setDisplayName("assets510-2a");
// file.setFileName("asset-510-2a.pdf");
// file.setMimeType(new MimeType("application/pdf"));
final Asset file = assetRepo.findById(-720L);
attachmentManager.attachAsset(file, item.get().getAttachments().get(1)); attachmentManager.attachAsset(file, item.get().getAttachments().get(1));
} }
@ -236,7 +232,7 @@ public class ItemAttachmentManagerTest {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final Asset shared = assetRepo.findById(-610L); final Asset shared = assetRepo.findById(-610L).get();
attachmentManager.attachAsset(shared, attachmentManager.attachAsset(shared,
item.get().getAttachments().get(1)); item.get().getAttachments().get(1));
@ -258,7 +254,7 @@ public class ItemAttachmentManagerTest {
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(item.isPresent(), is(true)); assertThat(item.isPresent(), is(true));
final Asset shared = assetRepo.findById(-620L); final Asset shared = assetRepo.findById(-620L).get();
attachmentManager.attachAsset(shared, attachmentManager.attachAsset(shared,
item.get().getAttachments().get(1)); item.get().getAttachments().get(1));
@ -302,7 +298,7 @@ public class ItemAttachmentManagerTest {
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void attachAssetToListNull() { public void attachAssetToListNull() {
final AttachmentList list = null; final AttachmentList list = null;
final Asset shared = assetRepo.findById(-610L); final Asset shared = assetRepo.findById(-610L).get();
attachmentManager.attachAsset(shared, list); attachmentManager.attachAsset(shared, list);
} }
@ -321,7 +317,7 @@ public class ItemAttachmentManagerTest {
+ "after-unattach-shared.xml", + "after-unattach-shared.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void unattachSharedAsset() { public void unattachSharedAsset() {
final Asset asset = assetRepo.findById(-610L); final Asset asset = assetRepo.findById(-610L).get();
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
@ -348,7 +344,7 @@ public class ItemAttachmentManagerTest {
+ "after-unattach-nonshared.xml", + "after-unattach-nonshared.xml",
excludeColumns = {"timestamp"}) excludeColumns = {"timestamp"})
public void unattachNonSharedAsset() { public void unattachNonSharedAsset() {
final Asset asset = assetRepo.findById(-720L); final Asset asset = assetRepo.findById(-720L).get();
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
@ -372,7 +368,7 @@ public class ItemAttachmentManagerTest {
@ShouldMatchDataSet("datasets/org/librecms/contentsection/" @ShouldMatchDataSet("datasets/org/librecms/contentsection/"
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
public void unattachAssetNotAttached() { public void unattachAssetNotAttached() {
final Asset asset = assetRepo.findById(-720L); final Asset asset = assetRepo.findById(-720L).get();
final Optional<ContentItem> item = itemRepo.findById(-510L); final Optional<ContentItem> item = itemRepo.findById(-510L);
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
@ -421,7 +417,7 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void unattachAssetFromListNull() { public void unattachAssetFromListNull() {
final Asset asset = assetRepo.findById(-720L); final Asset asset = assetRepo.findById(-720L).get();
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
final AttachmentList list = null; final AttachmentList list = null;
@ -509,7 +505,7 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveUpInListNull() { public void moveUpInListNull() {
final Asset asset = assetRepo.findById(-720L); final Asset asset = assetRepo.findById(-720L).get();
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
final AttachmentList list = null; final AttachmentList list = null;
@ -597,7 +593,7 @@ public class ItemAttachmentManagerTest {
+ "ItemAttachmentManagerTest/data.xml") + "ItemAttachmentManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class) @ShouldThrowException(IllegalArgumentException.class)
public void moveDownInListNull() { public void moveDownInListNull() {
final Asset asset = assetRepo.findById(-720L); final Asset asset = assetRepo.findById(-720L).get();
assertThat(asset, is(not(nullValue()))); assertThat(asset, is(not(nullValue())));
final AttachmentList list = null; final AttachmentList list = null;

View File

@ -39,8 +39,8 @@ import java.util.stream.Collectors;
@Configuration @Configuration
public final class KernelConfig { public final class KernelConfig {
private static final String EMAIL = "email"; public static final String USER_IDENTIFIER_EMAIL = "email";
private static final String SCREEN_NAME = "screen_name"; public static final String USER_IDENTIFIER_SCREEN_NAME = "screen_name";
@Setting @Setting
private boolean debugEnabled = false; private boolean debugEnabled = false;
@ -52,7 +52,7 @@ public final class KernelConfig {
private boolean dataPermissionCheckEnabled = true; private boolean dataPermissionCheckEnabled = true;
@Setting @Setting
private String primaryUserIdentifier = EMAIL; private String primaryUserIdentifier = USER_IDENTIFIER_EMAIL;
@Setting @Setting
private boolean ssoEnabled = false; private boolean ssoEnabled = false;
@ -113,8 +113,8 @@ public final class KernelConfig {
} }
public void setPrimaryUserIdentifier(final String primaryUserIdentifier) { public void setPrimaryUserIdentifier(final String primaryUserIdentifier) {
if (SCREEN_NAME.equals(primaryUserIdentifier) if (USER_IDENTIFIER_SCREEN_NAME.equals(primaryUserIdentifier)
|| EMAIL.equals(primaryUserIdentifier)) { || USER_IDENTIFIER_EMAIL.equals(primaryUserIdentifier)) {
this.primaryUserIdentifier = primaryUserIdentifier; this.primaryUserIdentifier = primaryUserIdentifier;
} else { } else {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -124,11 +124,11 @@ public final class KernelConfig {
} }
public boolean emailIsPrimaryIdentifier() { public boolean emailIsPrimaryIdentifier() {
return EMAIL.equals(primaryUserIdentifier); return USER_IDENTIFIER_EMAIL.equals(primaryUserIdentifier);
} }
public boolean screenNameIsPrimaryIdentifier() { public boolean screenNameIsPrimaryIdentifier() {
return SCREEN_NAME.equals(primaryUserIdentifier); return USER_IDENTIFIER_SCREEN_NAME.equals(primaryUserIdentifier);
} }
public boolean isSsoEnabled() { public boolean isSsoEnabled() {

View File

@ -302,7 +302,7 @@ public class ACSObjectSelectionModel implements SingleSelectionModel {
final CcmObjectRepository repository = cdiUtil.findBean( final CcmObjectRepository repository = cdiUtil.findBean(
CcmObjectRepository.class); CcmObjectRepository.class);
return repository.findById(objectId); return repository.findById(objectId).get();
} }

View File

@ -83,7 +83,7 @@ public abstract class SecurityContainer extends SimpleContainer {
public boolean isVisible(final PageState state) { public boolean isVisible(final PageState state) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final Shiro shiro = cdiUtil.findBean(Shiro.class); final Shiro shiro = cdiUtil.findBean(Shiro.class);
final Party party = shiro.getUser(); final Party party = shiro.getUser().get();
return ( super.isVisible(state) && canAccess(party, state) ); return ( super.isVisible(state) && canAccess(party, state) );
} }

View File

@ -120,7 +120,7 @@ public class CcmObjectSelectionModel<T extends CcmObject>
final CcmObjectRepository repository = CdiUtil.createCdiUtil().findBean( final CcmObjectRepository repository = CdiUtil.createCdiUtil().findBean(
CcmObjectRepository.class); CcmObjectRepository.class);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final T object = (T) repository.findById(key); final T object = (T) repository.findById(key).get();
return object; return object;
} }

View File

@ -32,6 +32,8 @@ import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.User; import org.libreccm.security.User;
import org.libreccm.security.UserRepository; import org.libreccm.security.UserRepository;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import static com.arsdigita.ui.UI.*; import static com.arsdigita.ui.UI.*;
@ -61,7 +63,7 @@ public class UserBanner extends SimpleComponent {
final UserRepository userRepository = cdiUtil.findBean( final UserRepository userRepository = cdiUtil.findBean(
UserRepository.class); UserRepository.class);
final User user; final Optional<User> user;
if ("email".equals(config.getPrimaryUserIdentifier())) { if ("email".equals(config.getPrimaryUserIdentifier())) {
user = userRepository.findByEmailAddress( user = userRepository.findByEmailAddress(
(String) subject.getPrincipal()); (String) subject.getPrincipal());
@ -70,15 +72,18 @@ public class UserBanner extends SimpleComponent {
.findByName((String) subject.getPrincipal()); .findByName((String) subject.getPrincipal());
} }
if (user != null) { if (user.isPresent()) {
contentElem.addAttribute("givenName", user.getGivenName()); contentElem.addAttribute("givenName",
contentElem.addAttribute("familyName", user.getFamilyName()); user.get().getGivenName());
contentElem.addAttribute("screenName", user.getName()); contentElem.addAttribute("familyName",
user.get().getFamilyName());
contentElem.addAttribute("screenName",
user.get().getName());
contentElem.addAttribute("primaryEmail", contentElem.addAttribute("primaryEmail",
user.getPrimaryEmailAddress() user.get().getPrimaryEmailAddress()
.getAddress()); .getAddress());
contentElem.addAttribute("userID", contentElem.addAttribute("userID",
Long.toString(user.getPartyId())); Long.toString(user.get().getPartyId()));
} }
} }

View File

@ -19,7 +19,6 @@
package com.arsdigita.ui.admin.applications; package com.arsdigita.ui.admin.applications;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.ParameterSingleSelectionModel;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
@ -77,9 +76,8 @@ public abstract class AbstractAppInstanceForm extends Form {
final ApplicationRepository appRepo = CdiUtil.createCdiUtil() final ApplicationRepository appRepo = CdiUtil.createCdiUtil()
.findBean(ApplicationRepository.class); .findBean(ApplicationRepository.class);
final CcmApplication result = appRepo.findById(Long.parseLong( return appRepo.findById(Long.parseLong(
selectedAppInstance.getSelectedKey(state))); selectedAppInstance.getSelectedKey(state)));
return Optional.of(result);
} }
} }

View File

@ -70,9 +70,8 @@ public abstract class AbstractAppSettingsPane extends SimpleContainer {
final ApplicationRepository appRepo = CdiUtil.createCdiUtil() final ApplicationRepository appRepo = CdiUtil.createCdiUtil()
.findBean(ApplicationRepository.class); .findBean(ApplicationRepository.class);
final CcmApplication result = appRepo.findById(Long.parseLong( return appRepo.findById(Long.parseLong(
selectedAppInstance.getSelectedKey(state))); selectedAppInstance.getSelectedKey(state)));
return Optional.of(result);
} }
} }

View File

@ -41,6 +41,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import static com.arsdigita.ui.admin.AdminUiConstants.*; import static com.arsdigita.ui.admin.AdminUiConstants.*;
@ -98,11 +99,11 @@ public class ApplicationsTab extends LayoutPanel {
final ApplicationRepository appRepo = CdiUtil.createCdiUtil() final ApplicationRepository appRepo = CdiUtil.createCdiUtil()
.findBean(ApplicationRepository.class); .findBean(ApplicationRepository.class);
final CcmApplication application = appRepo.findById( final Optional<CcmApplication> application = appRepo.findById(
Long.parseLong(instanceId)); Long.parseLong(instanceId));
if (application != null) { if (application.isPresent()) {
selectedAppType.setSelectedKey( selectedAppType.setSelectedKey(
state, application.getApplicationType()); state, application.get().getApplicationType());
} }
showAppSettings(state); showAppSettings(state);

View File

@ -47,7 +47,7 @@ public class CategoriesTreeModel implements TreeModel {
final CategoryRepository categoryRepository = CdiUtil.createCdiUtil() final CategoryRepository categoryRepository = CdiUtil.createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category category = categoryRepository.findById(domain.getRoot() final Category category = categoryRepository.findById(domain.getRoot()
.getObjectId()); .getObjectId()).get();
return new CategoryTreeNode(category); return new CategoryTreeNode(category);
} }
@ -57,7 +57,7 @@ public class CategoriesTreeModel implements TreeModel {
final CategoryRepository categoryRepo = CdiUtil.createCdiUtil() final CategoryRepository categoryRepo = CdiUtil.createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category category = categoryRepo.findById( final Category category = categoryRepo.findById(
((CategoryTreeNode) node).getCategory().getObjectId()); ((CategoryTreeNode) node).getCategory().getObjectId()).get();
return (category.getSubCategories() != null return (category.getSubCategories() != null
&& !category.getSubCategories().isEmpty()); && !category.getSubCategories().isEmpty());
@ -69,7 +69,7 @@ public class CategoriesTreeModel implements TreeModel {
final CategoryRepository categoryRepo = CdiUtil.createCdiUtil() final CategoryRepository categoryRepo = CdiUtil.createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category category = categoryRepo.findById( final Category category = categoryRepo.findById(
((CategoryTreeNode) node).getCategory().getObjectId()); ((CategoryTreeNode) node).getCategory().getObjectId()).get();
return new SubCategoryNodesIterator(category.getSubCategories()); return new SubCategoryNodesIterator(category.getSubCategories());
} }

View File

@ -51,7 +51,7 @@ class CategoriesTreeModelBuilder
final DomainRepository domainRepository = CdiUtil.createCdiUtil(). final DomainRepository domainRepository = CdiUtil.createCdiUtil().
findBean(DomainRepository.class); findBean(DomainRepository.class);
final Domain domain = domainRepository.findById(Long.parseLong( final Domain domain = domainRepository.findById(Long.parseLong(
selectedDomainId.getSelectedKey(state))); selectedDomainId.getSelectedKey(state))).get();
return new CategoriesTreeModel(domain); return new CategoriesTreeModel(domain);
} }

View File

@ -63,7 +63,7 @@ public class CategoryCreateForm extends Form {
final CategoryRepository categoryRepository = CdiUtil final CategoryRepository categoryRepository = CdiUtil
.createCdiUtil().findBean(CategoryRepository.class); .createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepository.findById(Long final Category category = categoryRepository.findById(Long
.parseLong(selectedCategoryId.getSelectedKey(state))); .parseLong(selectedCategoryId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.categories.category.create_new_subcategory", "ui.admin.categories.category.create_new_subcategory",
ADMIN_BUNDLE, ADMIN_BUNDLE,
@ -108,7 +108,8 @@ public class CategoryCreateForm extends Form {
CategoryManager.class); CategoryManager.class);
final Category selectedCategory = categoryRepository.findById( final Category selectedCategory = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey(state))); Long.parseLong(selectedCategoryId.getSelectedKey(state)))
.get();
final FormData data = e.getFormData(); final FormData data = e.getFormData();
final String categoryNameData = data.getString(CATEGORY_NAME); final String categoryNameData = data.getString(CATEGORY_NAME);

View File

@ -75,7 +75,7 @@ public class CategoryDescriptionForm extends Form {
createCdiUtil() createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category selectedCategory = categoryRepository.findById( final Category selectedCategory = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey(state))); Long.parseLong(selectedCategoryId.getSelectedKey(state))).get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));
@ -115,7 +115,7 @@ public class CategoryDescriptionForm extends Form {
final CategoryRepository categoryRepository = CdiUtil. final CategoryRepository categoryRepository = CdiUtil.
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
final Category selectedCategory = categoryRepository.findById( final Category selectedCategory = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey(state))); Long.parseLong(selectedCategoryId.getSelectedKey(state))).get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));
@ -152,7 +152,8 @@ public class CategoryDescriptionForm extends Form {
.createCdiUtil() .createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category selectedCategory = categoryRepository.findById( final Category selectedCategory = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey(state))); Long.parseLong(selectedCategoryId.getSelectedKey(state)))
.get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));

View File

@ -156,7 +156,7 @@ public class CategoryDescriptionTable extends Table {
CategoryRepository.class); CategoryRepository.class);
final Category category = categoryRepository.findById( final Category category = categoryRepository.findById(
Long.parseLong(selectedCategoryId. Long.parseLong(selectedCategoryId.
getSelectedKey(state))); getSelectedKey(state))).get();
category.getDescription().removeValue(locale); category.getDescription().removeValue(locale);
categoryRepository.save(category); categoryRepository.save(category);
@ -199,7 +199,7 @@ public class CategoryDescriptionTable extends Table {
final CategoryRepository categoryRepository = CdiUtil. final CategoryRepository categoryRepository = CdiUtil.
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
selectedCategory = categoryRepository.findById(Long.parseLong( selectedCategory = categoryRepository.findById(Long.parseLong(
selectedCategoryId.getSelectedKey(state))); selectedCategoryId.getSelectedKey(state))).get();
locales = new ArrayList<>(); locales = new ArrayList<>();
if (selectedCategory.getDescription() != null) { if (selectedCategory.getDescription() != null) {

View File

@ -83,7 +83,7 @@ class CategoryDetails extends SegmentedPanel {
final CategoryRepository categoryRepo = CdiUtil.createCdiUtil() final CategoryRepository categoryRepo = CdiUtil.createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category category = categoryRepo.findById(Long.parseLong( final Category category = categoryRepo.findById(Long.parseLong(
selectedCategoryId.getSelectedKey(state))); selectedCategoryId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.categories.category_details.heading", "ui.admin.categories.category_details.heading",
@ -115,7 +115,8 @@ class CategoryDetails extends SegmentedPanel {
final CategoryRepository categoryRepo = CdiUtil final CategoryRepository categoryRepo = CdiUtil
.createCdiUtil().findBean(CategoryRepository.class); .createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepo.findById(Long final Category category = categoryRepo.findById(Long
.parseLong(selectedCategoryId.getSelectedKey(state))); .parseLong(selectedCategoryId.getSelectedKey(state)))
.get();
//If the category has no parent category it is the root //If the category has no parent category it is the root
//category of a domain and can't be moved //category of a domain and can't be moved
@ -202,7 +203,7 @@ class CategoryDetails extends SegmentedPanel {
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepository.findById( final Category category = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey( Long.parseLong(selectedCategoryId.getSelectedKey(
state))); state))).get();
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
final Set<String> supportedLanguages = kernelConfig. final Set<String> supportedLanguages = kernelConfig.
getSupportedLanguages(); getSupportedLanguages();
@ -248,7 +249,7 @@ class CategoryDetails extends SegmentedPanel {
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepository.findById( final Category category = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey( Long.parseLong(selectedCategoryId.getSelectedKey(
state))); state))).get();
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
final Set<String> supportedLanguages = kernelConfig. final Set<String> supportedLanguages = kernelConfig.
getSupportedLanguages(); getSupportedLanguages();
@ -287,7 +288,7 @@ class CategoryDetails extends SegmentedPanel {
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepository.findById( final Category category = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey( Long.parseLong(selectedCategoryId.getSelectedKey(
state))); state))).get();
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
final Set<String> supportedLanguages = kernelConfig. final Set<String> supportedLanguages = kernelConfig.
getSupportedLanguages(); getSupportedLanguages();
@ -335,7 +336,7 @@ class CategoryDetails extends SegmentedPanel {
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepository.findById( final Category category = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey( Long.parseLong(selectedCategoryId.getSelectedKey(
state))); state))).get();
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
final Set<String> supportedLanguages = kernelConfig. final Set<String> supportedLanguages = kernelConfig.
getSupportedLanguages(); getSupportedLanguages();

View File

@ -75,7 +75,7 @@ public class CategoryEditForm extends Form {
final CategoryRepository categoryRepository = CdiUtil final CategoryRepository categoryRepository = CdiUtil
.createCdiUtil().findBean(CategoryRepository.class); .createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepository.findById(Long final Category category = categoryRepository.findById(Long
.parseLong(selectedCategoryId.getSelectedKey(state))); .parseLong(selectedCategoryId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.categories.category.edit_category", "ui.admin.categories.category.edit_category",
ADMIN_BUNDLE, ADMIN_BUNDLE,
@ -117,7 +117,7 @@ public class CategoryEditForm extends Form {
final CategoryRepository categoryRepository = cdiUtil.findBean( final CategoryRepository categoryRepository = cdiUtil.findBean(
CategoryRepository.class); CategoryRepository.class);
final Category category = categoryRepository.findById(Long final Category category = categoryRepository.findById(Long
.parseLong(selectedCategoryId.getSelectedKey(state))); .parseLong(selectedCategoryId.getSelectedKey(state))).get();
categoryName.setValue(state, category.getName()); categoryName.setValue(state, category.getName());
final List<String> props = new ArrayList<>(); final List<String> props = new ArrayList<>();
@ -161,14 +161,16 @@ public class CategoryEditForm extends Form {
CategoryManager.class); CategoryManager.class);
final Category category = categoryRepository.findById( final Category category = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey(state))); Long.parseLong(selectedCategoryId.getSelectedKey(state)))
.get();
final FormData data = e.getFormData(); final FormData data = e.getFormData();
final String categoryNameData = data.getString(CATEGORY_NAME); final String categoryNameData = data.getString(CATEGORY_NAME);
category.setName(categoryNameData); category.setName(categoryNameData);
final List<String> propertiesData = Arrays.asList((String[]) data.get( final List<String> propertiesData = Arrays.asList(
(String[]) data.get(
CATEGORY_PROPERTIES)); CATEGORY_PROPERTIES));
category.setEnabled(propertiesData.contains(ENABLED)); category.setEnabled(propertiesData.contains(ENABLED));
category.setVisible(propertiesData.contains(VISIBLE)); category.setVisible(propertiesData.contains(VISIBLE));

View File

@ -65,7 +65,7 @@ public class CategoryMover extends Form {
final CategoryRepository categoryRepo = CdiUtil final CategoryRepository categoryRepo = CdiUtil
.createCdiUtil().findBean(CategoryRepository.class); .createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepo.findById(Long.parseLong( final Category category = categoryRepo.findById(Long.parseLong(
selectedCategoryId.getSelectedKey(state))); selectedCategoryId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.categories.category.move.heading", "ui.admin.categories.category.move.heading",
@ -94,10 +94,10 @@ public class CategoryMover extends Form {
CategoryManager.class); CategoryManager.class);
final Category category = categoryRepo.findById(Long.parseLong( final Category category = categoryRepo.findById(Long.parseLong(
selectedCategoryId.getSelectedKey(state))); selectedCategoryId.getSelectedKey(state))).get();
final Category parent = category.getParentCategory(); final Category parent = category.getParentCategory();
final Category target = categoryRepo.findById(Long.parseLong( final Category target = categoryRepo.findById(Long.parseLong(
(String) categoryTree.getSelectedKey(state))); (String) categoryTree.getSelectedKey(state))).get();
categoryManager.removeSubCategoryFromCategory(category, parent); categoryManager.removeSubCategoryFromCategory(category, parent);
categoryManager.addSubCategoryToCategory(category, target); categoryManager.addSubCategoryToCategory(category, target);

View File

@ -51,7 +51,7 @@ public class CategoryMoverModel implements TreeModel {
final CategoryRepository categoryRepository = CdiUtil.createCdiUtil() final CategoryRepository categoryRepository = CdiUtil.createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category category = categoryRepository.findById(domain.getRoot() final Category category = categoryRepository.findById(domain.getRoot()
.getObjectId()); .getObjectId()).get();
return new CategoryMoverNode(category); return new CategoryMoverNode(category);
} }
@ -71,7 +71,7 @@ public class CategoryMoverModel implements TreeModel {
final CategoryRepository categoryRepo = CdiUtil.createCdiUtil() final CategoryRepository categoryRepo = CdiUtil.createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category category = categoryRepo.findById( final Category category = categoryRepo.findById(
((CategoryMoverNode) node).getCategory().getObjectId()); ((CategoryMoverNode) node).getCategory().getObjectId()).get();
final List<Category> subCategories = new ArrayList<>(); final List<Category> subCategories = new ArrayList<>();
category.getSubCategories().forEach(c -> { category.getSubCategories().forEach(c -> {

View File

@ -58,12 +58,12 @@ public class CategoryMoverModelBuilder
final DomainRepository domainRepository = cdiUtil.findBean( final DomainRepository domainRepository = cdiUtil.findBean(
DomainRepository.class); DomainRepository.class);
final Domain domain = domainRepository.findById(Long.parseLong( final Domain domain = domainRepository.findById(Long.parseLong(
selectedDomainId.getSelectedKey(state))); selectedDomainId.getSelectedKey(state))).get();
final CategoryRepository categoryRepository = cdiUtil.findBean( final CategoryRepository categoryRepository = cdiUtil.findBean(
CategoryRepository.class); CategoryRepository.class);
final Category category = categoryRepository.findById(Long.parseLong( final Category category = categoryRepository.findById(Long.parseLong(
selectedCategoryId.getSelectedKey(state))); selectedCategoryId.getSelectedKey(state))).get();
return new CategoryMoverModel(domain, category); return new CategoryMoverModel(domain, category);
} }

View File

@ -57,7 +57,7 @@ public class CategoryPropertySheetModelBuilder
final CategoryRepository categoryRepository = CdiUtil. final CategoryRepository categoryRepository = CdiUtil.
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
selectedCategory = categoryRepository.findById(Long.parseLong( selectedCategory = categoryRepository.findById(Long.parseLong(
categoryIdStr)); categoryIdStr)).get();
} }
return new CategoryPropertySheetModel(selectedCategory); return new CategoryPropertySheetModel(selectedCategory);

View File

@ -73,7 +73,7 @@ public class CategoryTitleForm extends Form {
createCdiUtil() createCdiUtil()
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category selectedCategory = categoryRepository.findById( final Category selectedCategory = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey(state))); Long.parseLong(selectedCategoryId.getSelectedKey(state))).get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));
@ -111,7 +111,7 @@ public class CategoryTitleForm extends Form {
final CategoryRepository categoryRepository = CdiUtil. final CategoryRepository categoryRepository = CdiUtil.
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
final Category selectedCategory = categoryRepository.findById( final Category selectedCategory = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey(state))); Long.parseLong(selectedCategoryId.getSelectedKey(state))).get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));
@ -146,7 +146,8 @@ public class CategoryTitleForm extends Form {
final CategoryRepository categoryRepository = CdiUtil. final CategoryRepository categoryRepository = CdiUtil.
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
final Category selectedCategory = categoryRepository.findById( final Category selectedCategory = categoryRepository.findById(
Long.parseLong(selectedCategoryId.getSelectedKey(state))); Long.parseLong(selectedCategoryId.getSelectedKey(state)))
.get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));

View File

@ -154,7 +154,7 @@ public class CategoryTitleTable extends Table {
CategoryRepository.class); CategoryRepository.class);
final Category category = categoryRepository.findById( final Category category = categoryRepository.findById(
Long.parseLong(selectedCategoryId. Long.parseLong(selectedCategoryId.
getSelectedKey(state))); getSelectedKey(state))).get();
category.getTitle().removeValue(locale); category.getTitle().removeValue(locale);
categoryRepository.save(category); categoryRepository.save(category);
@ -197,7 +197,7 @@ public class CategoryTitleTable extends Table {
final CategoryRepository categoryRepository = CdiUtil. final CategoryRepository categoryRepository = CdiUtil.
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
selectedCategory = categoryRepository.findById(Long.parseLong( selectedCategory = categoryRepository.findById(Long.parseLong(
selectedCategoryId.getSelectedKey(state))); selectedCategoryId.getSelectedKey(state))).get();
locales = new ArrayList<>(); locales = new ArrayList<>();
if (selectedCategory.getTitle() != null) { if (selectedCategory.getTitle() != null) {

View File

@ -73,7 +73,7 @@ class DomainDescriptionForm extends Form {
final DomainRepository domainRepository = CdiUtil.createCdiUtil() final DomainRepository domainRepository = CdiUtil.createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
final Domain selectedDomain = domainRepository.findById( final Domain selectedDomain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state))); Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));
@ -113,7 +113,7 @@ class DomainDescriptionForm extends Form {
final DomainRepository domainRepository = CdiUtil.createCdiUtil() final DomainRepository domainRepository = CdiUtil.createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
final Domain selectedDomain = domainRepository.findById( final Domain selectedDomain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state))); Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));
@ -150,7 +150,8 @@ class DomainDescriptionForm extends Form {
.createCdiUtil() .createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
final Domain selectedDomain = domainRepository.findById( final Domain selectedDomain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state))); Long.parseLong(selectedDomainId.getSelectedKey(state)))
.get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));

View File

@ -158,7 +158,7 @@ class DomainDescriptionTable extends Table {
findBean(DomainRepository.class); findBean(DomainRepository.class);
final Domain domain = domainRepository.findById( final Domain domain = domainRepository.findById(
Long.parseLong(selectedDomainId Long.parseLong(selectedDomainId
.getSelectedKey(state))); .getSelectedKey(state))).get();
domain.getDescription().removeValue(locale); domain.getDescription().removeValue(locale);
domainRepository.save(domain); domainRepository.save(domain);
@ -202,7 +202,7 @@ class DomainDescriptionTable extends Table {
final DomainRepository domainRepository = CdiUtil.createCdiUtil() final DomainRepository domainRepository = CdiUtil.createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
selectedDomain = domainRepository.findById( selectedDomain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state))); Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
locales = new ArrayList<>(); locales = new ArrayList<>();
locales.addAll(selectedDomain.getDescription() locales.addAll(selectedDomain.getDescription()

View File

@ -81,7 +81,7 @@ class DomainDetails extends SegmentedPanel {
final DomainRepository domainRepository = CdiUtil.createCdiUtil() final DomainRepository domainRepository = CdiUtil.createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
final Domain domain = domainRepository.findById(Long.parseLong( final Domain domain = domainRepository.findById(Long.parseLong(
selectedDomainId.getSelectedKey(state))); selectedDomainId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.categories.domain.details.heading", "ui.admin.categories.domain.details.heading",
@ -163,7 +163,8 @@ class DomainDetails extends SegmentedPanel {
final DomainRepository domainRepository = CdiUtil final DomainRepository domainRepository = CdiUtil
.createCdiUtil().findBean(DomainRepository.class); .createCdiUtil().findBean(DomainRepository.class);
final Domain domain = domainRepository.findById(Long final Domain domain = domainRepository.findById(Long
.parseLong(selectedDomainId.getSelectedKey(state))); .parseLong(selectedDomainId.getSelectedKey(state)))
.get();
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
final Set<String> supportedLanguages = kernelConfig final Set<String> supportedLanguages = kernelConfig
.getSupportedLanguages(); .getSupportedLanguages();
@ -208,8 +209,7 @@ class DomainDetails extends SegmentedPanel {
final DomainRepository domainRepository = CdiUtil final DomainRepository domainRepository = CdiUtil
.createCdiUtil().findBean(DomainRepository.class); .createCdiUtil().findBean(DomainRepository.class);
final Domain domain = domainRepository.findById(Long final Domain domain = domainRepository.findById(Long
.parseLong( .parseLong(selectedDomainId.getSelectedKey(state))).get();
selectedDomainId.getSelectedKey(state)));
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
final Set<String> supportedLanguages = kernelConfig final Set<String> supportedLanguages = kernelConfig
.getSupportedLanguages(); .getSupportedLanguages();
@ -247,8 +247,8 @@ class DomainDetails extends SegmentedPanel {
final DomainRepository domainRepository = CdiUtil final DomainRepository domainRepository = CdiUtil
.createCdiUtil().findBean(DomainRepository.class); .createCdiUtil().findBean(DomainRepository.class);
final Domain domain = domainRepository.findById(Long final Domain domain = domainRepository.findById(Long
.parseLong( .parseLong(selectedDomainId.getSelectedKey(state)))
selectedDomainId.getSelectedKey(state))); .get();
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
final Set<String> supportedLanguages = kernelConfig final Set<String> supportedLanguages = kernelConfig
.getSupportedLanguages(); .getSupportedLanguages();
@ -294,8 +294,7 @@ class DomainDetails extends SegmentedPanel {
final DomainRepository domainRepository = CdiUtil final DomainRepository domainRepository = CdiUtil
.createCdiUtil().findBean(DomainRepository.class); .createCdiUtil().findBean(DomainRepository.class);
final Domain domain = domainRepository.findById(Long final Domain domain = domainRepository.findById(Long
.parseLong( .parseLong(selectedDomainId.getSelectedKey(state))).get();
selectedDomainId.getSelectedKey(state)));
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
final Set<String> supportedLanguages = kernelConfig final Set<String> supportedLanguages = kernelConfig
.getSupportedLanguages(); .getSupportedLanguages();

View File

@ -77,7 +77,7 @@ class DomainForm extends Form {
final DomainRepository domainRepository = CdiUtil. final DomainRepository domainRepository = CdiUtil.
createCdiUtil().findBean(DomainRepository.class); createCdiUtil().findBean(DomainRepository.class);
final Domain domain = domainRepository.findById(Long.parseLong( final Domain domain = domainRepository.findById(Long.parseLong(
selectedDomainId.getSelectedKey(state))); selectedDomainId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.categories.domain_form.heading.edit", "ui.admin.categories.domain_form.heading.edit",
ADMIN_BUNDLE, ADMIN_BUNDLE,
@ -130,7 +130,7 @@ class DomainForm extends Form {
final DomainRepository domainRepository = cdiUtil.findBean( final DomainRepository domainRepository = cdiUtil.findBean(
DomainRepository.class); DomainRepository.class);
final Domain domain = domainRepository.findById(Long.parseLong( final Domain domain = domainRepository.findById(Long.parseLong(
selectedDomainId.getSelectedKey(state))); selectedDomainId.getSelectedKey(state))).get();
domainKey.setValue(state, domain.getDomainKey()); domainKey.setValue(state, domain.getDomainKey());
domainUri.setValue(state, domain.getUri()); domainUri.setValue(state, domain.getUri());
@ -202,7 +202,7 @@ class DomainForm extends Form {
} }
} else { } else {
domain = domainRepository.findById(Long.parseLong( domain = domainRepository.findById(Long.parseLong(
selectedDomainId.getSelectedKey(state))); selectedDomainId.getSelectedKey(state))).get();
} }
domain.setDomainKey(domainKeyData); domain.setDomainKey(domainKeyData);
domain.setUri(domainUriData); domain.setUri(domainUriData);

View File

@ -75,7 +75,7 @@ class DomainMappingAddForm extends Form {
final Domain domain = domainRepository.findById( final Domain domain = domainRepository.findById(
Long.parseLong( Long.parseLong(
selectedDomainId.getSelectedKey(e.getPageState())), selectedDomainId.getSelectedKey(e.getPageState())),
"Domain.withOwners"); "Domain.withOwners").get();
final List<CcmApplication> applications = appRepository final List<CcmApplication> applications = appRepository
.findAll(); .findAll();
@ -130,10 +130,10 @@ class DomainMappingAddForm extends Form {
final Domain domain = domainRepository.findById( final Domain domain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state)), Long.parseLong(selectedDomainId.getSelectedKey(state)),
"Domain.withOwners"); "Domain.withOwners").get();
final CcmApplication application = appRepository.findById( final CcmApplication application = appRepository.findById(
Long.parseLong(data.getString(DOMAIN_MAPPING_OWNER)), Long.parseLong(data.getString(DOMAIN_MAPPING_OWNER)),
"CcmApplication.withDomains"); "CcmApplication.withDomains").get();
domainManager.addDomainOwner(application, domain); domainManager.addDomainOwner(application, domain);
}); });

View File

@ -130,10 +130,10 @@ class DomainMappingsTable extends Table {
final Domain domain = domainRepository.findById( final Domain domain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(event Long.parseLong(selectedDomainId.getSelectedKey(event
.getPageState()))); .getPageState()))).get();
final CcmApplication owner = appRepository.findById( final CcmApplication owner = appRepository.findById(
Long.parseLong((String)event.getRowKey())); Long.parseLong((String)event.getRowKey())).get();
domainManager.removeDomainOwner(owner, domain); domainManager.removeDomainOwner(owner, domain);
@ -175,7 +175,7 @@ class DomainMappingsTable extends Table {
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
final Domain domain = domainRepository.findById( final Domain domain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state)), Long.parseLong(selectedDomainId.getSelectedKey(state)),
"Domain.withOwners"); "Domain.withOwners").get();
domainOwnerships = new ArrayList<>(domain.getOwners()); domainOwnerships = new ArrayList<>(domain.getOwners());

View File

@ -58,7 +58,7 @@ class DomainPropertySheetModelBuilder
final DomainRepository domainRepository = CdiUtil.createCdiUtil() final DomainRepository domainRepository = CdiUtil.createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
selectedDomain = domainRepository.findById(Long.parseLong( selectedDomain = domainRepository.findById(Long.parseLong(
domainIdStr)); domainIdStr)).get();
} }
return new DomainPropertySheetModel(selectedDomain); return new DomainPropertySheetModel(selectedDomain);

View File

@ -73,7 +73,7 @@ class DomainTitleForm extends Form {
final DomainRepository domainRepository = CdiUtil.createCdiUtil() final DomainRepository domainRepository = CdiUtil.createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
final Domain selectedDomain = domainRepository.findById( final Domain selectedDomain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state))); Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));
@ -111,7 +111,7 @@ class DomainTitleForm extends Form {
final DomainRepository domainRepository = CdiUtil.createCdiUtil() final DomainRepository domainRepository = CdiUtil.createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
final Domain selectedDomain = domainRepository.findById( final Domain selectedDomain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state))); Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));
@ -148,7 +148,8 @@ class DomainTitleForm extends Form {
.createCdiUtil() .createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
final Domain selectedDomain = domainRepository.findById( final Domain selectedDomain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state))); Long.parseLong(selectedDomainId.getSelectedKey(state)))
.get();
final Locale selectedLocale = new Locale(selectedLanguage final Locale selectedLocale = new Locale(selectedLanguage
.getSelectedKey(state)); .getSelectedKey(state));

View File

@ -156,7 +156,7 @@ class DomainTitleTable extends Table {
findBean(DomainRepository.class); findBean(DomainRepository.class);
final Domain domain = domainRepository.findById( final Domain domain = domainRepository.findById(
Long.parseLong(selectedDomainId Long.parseLong(selectedDomainId
.getSelectedKey(state))); .getSelectedKey(state))).get();
domain.getTitle().removeValue(locale); domain.getTitle().removeValue(locale);
domainRepository.save(domain); domainRepository.save(domain);
@ -198,7 +198,7 @@ class DomainTitleTable extends Table {
final DomainRepository domainRepository = CdiUtil.createCdiUtil() final DomainRepository domainRepository = CdiUtil.createCdiUtil()
.findBean(DomainRepository.class); .findBean(DomainRepository.class);
selectedDomain = domainRepository.findById( selectedDomain = domainRepository.findById(
Long.parseLong(selectedDomainId.getSelectedKey(state))); Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
locales = new ArrayList<>(); locales = new ArrayList<>();
locales.addAll(selectedDomain.getTitle().getAvailableLocales()); locales.addAll(selectedDomain.getTitle().getAvailableLocales());

View File

@ -199,9 +199,9 @@ public class SubCategoriesTable extends Table {
.findBean(CategoryManager.class); .findBean(CategoryManager.class);
final Category parentCategory = categoryRepo.findById( final Category parentCategory = categoryRepo.findById(
Long.parseLong(selectedCategoryId.getSelectedKey( Long.parseLong(selectedCategoryId.getSelectedKey(
state))); state))).get();
final Category subCategory = categoryRepo.findById(Long final Category subCategory = categoryRepo.findById(Long
.parseLong((String) event.getRowKey())); .parseLong((String) event.getRowKey())).get();
categoryManager.decreaseCategoryOrder(subCategory, categoryManager.decreaseCategoryOrder(subCategory,
parentCategory); parentCategory);
break; break;
@ -214,9 +214,9 @@ public class SubCategoriesTable extends Table {
.findBean(CategoryManager.class); .findBean(CategoryManager.class);
final Category parentCategory = categoryRepo.findById( final Category parentCategory = categoryRepo.findById(
Long.parseLong(selectedCategoryId.getSelectedKey( Long.parseLong(selectedCategoryId.getSelectedKey(
state))); state))).get();
final Category subCategory = categoryRepo.findById(Long final Category subCategory = categoryRepo.findById(Long
.parseLong((String) event.getRowKey())); .parseLong((String) event.getRowKey())).get();
categoryManager.increaseCategoryOrder(subCategory, categoryManager.increaseCategoryOrder(subCategory,
parentCategory); parentCategory);
break; break;
@ -232,7 +232,7 @@ public class SubCategoriesTable extends Table {
final CategoryRepository categoryRepo = cdiUtil final CategoryRepository categoryRepo = cdiUtil
.findBean(CategoryRepository.class); .findBean(CategoryRepository.class);
final Category category = categoryRepo.findById(Long final Category category = categoryRepo.findById(Long
.parseLong((String) event.getRowKey())); .parseLong((String) event.getRowKey())).get();
categoryRepo.delete(category); categoryRepo.delete(category);
break; break;
} }
@ -271,7 +271,7 @@ public class SubCategoriesTable extends Table {
final CategoryRepository categoryRepo = CdiUtil. final CategoryRepository categoryRepo = CdiUtil.
createCdiUtil().findBean(CategoryRepository.class); createCdiUtil().findBean(CategoryRepository.class);
final Category category = categoryRepo.findById(Long.parseLong( final Category category = categoryRepo.findById(Long.parseLong(
selectedCategoryId.getSelectedKey(state))); selectedCategoryId.getSelectedKey(state))).get();
subCategories = new ArrayList<>(category.getSubCategories()); subCategories = new ArrayList<>(category.getSubCategories());
subCategories.sort((c1, c2) -> { subCategories.sort((c1, c2) -> {

View File

@ -95,7 +95,7 @@ class GroupAddMemberForm extends Form {
final GroupRepository groupRepository = CdiUtil.createCdiUtil() final GroupRepository groupRepository = CdiUtil.createCdiUtil()
.findBean(GroupRepository.class); .findBean(GroupRepository.class);
final Group group = groupRepository.findById(Long.parseLong( final Group group = groupRepository.findById(Long.parseLong(
selectedGroupId.getSelectedKey(state))); selectedGroupId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.group_details.add_member.header", "ui.admin.group_details.add_member.header",
@ -191,10 +191,11 @@ class GroupAddMemberForm extends Form {
final GroupManager groupManager = cdiUtil.findBean( final GroupManager groupManager = cdiUtil.findBean(
GroupManager.class); GroupManager.class);
final User user = userRepository.findById(Long final User user = userRepository.findById(Long
.parseLong(key)); .parseLong(key)).get();
final Group group = groupRepository.findById( final Group group = groupRepository.findById(
Long.parseLong( Long.parseLong(
selectedGroupId.getSelectedKey(state))); selectedGroupId.getSelectedKey(state)))
.get();
groupManager.addMemberToGroup(user, group); groupManager.addMemberToGroup(user, group);
groupAdmin.hideGroupMemberAddForm(state); groupAdmin.hideGroupMemberAddForm(state);
break; break;

View File

@ -62,7 +62,7 @@ class GroupDetails extends BoxPanel {
final GroupRepository groupRepository = CdiUtil.createCdiUtil() final GroupRepository groupRepository = CdiUtil.createCdiUtil()
.findBean(GroupRepository.class); .findBean(GroupRepository.class);
final Group group = groupRepository.findById(Long.parseLong( final Group group = groupRepository.findById(Long.parseLong(
selectedGroupId.getSelectedKey(state))); selectedGroupId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.group_details.header", "ui.admin.group_details.header",
ADMIN_BUNDLE, ADMIN_BUNDLE,

View File

@ -31,6 +31,8 @@ import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.Group; import org.libreccm.security.Group;
import org.libreccm.security.GroupRepository; import org.libreccm.security.GroupRepository;
import java.util.Optional;
import static com.arsdigita.ui.admin.AdminUiConstants.*; import static com.arsdigita.ui.admin.AdminUiConstants.*;
/** /**
@ -112,7 +114,8 @@ class GroupForm extends Form {
final GroupRepository groupRepository = cdiUtil.findBean( final GroupRepository groupRepository = cdiUtil.findBean(
GroupRepository.class); GroupRepository.class);
if (groupRepository.findByName(groupNameData) != null) { final Optional<Group> group = groupRepository.findByName(groupNameData);
if (group.isPresent()) {
data.addError(GROUP_NAME, new GlobalizedMessage( data.addError(GROUP_NAME, new GlobalizedMessage(
"ui.admin.group.error.name_already_in_use", "ui.admin.group.error.name_already_in_use",
ADMIN_BUNDLE)); ADMIN_BUNDLE));
@ -132,7 +135,7 @@ class GroupForm extends Form {
GroupRepository.class); GroupRepository.class);
final Group group = groupRepository.findById(Long.parseLong( final Group group = groupRepository.findById(Long.parseLong(
selectedGroupIdStr)); selectedGroupIdStr)).get();
groupName.setValue(state, group.getName()); groupName.setValue(state, group.getName());
} }
}); });
@ -158,7 +161,7 @@ class GroupForm extends Form {
groupRepository.save(group); groupRepository.save(group);
} else { } else {
final Group group = groupRepository.findById(Long.parseLong( final Group group = groupRepository.findById(Long.parseLong(
selectedGroupIdStr)); selectedGroupIdStr)).get();
group.setName(groupNameData); group.setName(groupNameData);
groupRepository.save(group); groupRepository.save(group);

View File

@ -132,10 +132,10 @@ class GroupMembersTable extends Table {
final GroupManager groupManager = cdiUtil.findBean( final GroupManager groupManager = cdiUtil.findBean(
GroupManager.class); GroupManager.class);
final User user = userRepository.findById(Long final User user = userRepository.findById(Long
.parseLong(key)); .parseLong(key)).get();
final Group group = groupRepository.findById( final Group group = groupRepository.findById(
Long.parseLong( Long.parseLong(
selectedGroupId.getSelectedKey(state))); selectedGroupId.getSelectedKey(state))).get();
groupManager.removeMemberFromGroup(user, group); groupManager.removeMemberFromGroup(user, group);
break; break;
default: default:
@ -186,7 +186,7 @@ class GroupMembersTable extends Table {
final GroupRepository groupRepository = CdiUtil.createCdiUtil() final GroupRepository groupRepository = CdiUtil.createCdiUtil()
.findBean(GroupRepository.class); .findBean(GroupRepository.class);
final Group group = groupRepository.findById(Long.parseLong( final Group group = groupRepository.findById(Long.parseLong(
selectedGroupId.getSelectedKey(state))); selectedGroupId.getSelectedKey(state))).get();
members = new ArrayList<>(); members = new ArrayList<>();

View File

@ -55,7 +55,7 @@ class GroupPropertySheetModelBuilder
} else { } else {
final GroupRepository groupRepository = CdiUtil.createCdiUtil() final GroupRepository groupRepository = CdiUtil.createCdiUtil()
.findBean(GroupRepository.class); .findBean(GroupRepository.class);
selectedGroup = groupRepository.findById(Long.parseLong(groupIdStr)); selectedGroup = groupRepository.findById(Long.parseLong(groupIdStr)).get();
} }
return new GroupPropertySheetModel(selectedGroup); return new GroupPropertySheetModel(selectedGroup);

View File

@ -134,7 +134,7 @@ class GroupsTable extends Table {
final GroupRepository groupRepository = CdiUtil final GroupRepository groupRepository = CdiUtil
.createCdiUtil().findBean(GroupRepository.class); .createCdiUtil().findBean(GroupRepository.class);
final Group group = groupRepository.findById( final Group group = groupRepository.findById(
Long.parseLong(key)); Long.parseLong(key)).get();
groupRepository.delete(group); groupRepository.delete(group);
break; break;
default: default:

View File

@ -89,7 +89,7 @@ class RoleAddMemberForm extends Form {
final RoleRepository roleRepository = CdiUtil.createCdiUtil() final RoleRepository roleRepository = CdiUtil.createCdiUtil()
.findBean(RoleRepository.class); .findBean(RoleRepository.class);
final Role role = roleRepository.findById(Long.parseLong( final Role role = roleRepository.findById(Long.parseLong(
selectedRoleId.getSelectedKey(state))); selectedRoleId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.role_members.add.heading", "ui.admin.role_members.add.heading",
@ -169,10 +169,10 @@ class RoleAddMemberForm extends Form {
final RoleManager roleManager = cdiUtil.findBean( final RoleManager roleManager = cdiUtil.findBean(
RoleManager.class); RoleManager.class);
final Party party = partyRepository.findById( final Party party = partyRepository.findById(
Long.parseLong(key)); Long.parseLong(key)).get();
final Role role = roleRepository.findById( final Role role = roleRepository.findById(
Long.parseLong( Long.parseLong(
selectedRoleId.getSelectedKey(state))); selectedRoleId.getSelectedKey(state))).get();
roleManager.assignRoleToParty(role, party); roleManager.assignRoleToParty(role, party);
roleAdmin.hideRoleMemberAddForm(state); roleAdmin.hideRoleMemberAddForm(state);
break; break;

View File

@ -61,7 +61,7 @@ class RoleDetails extends BoxPanel {
final RoleRepository roleRepository = CdiUtil.createCdiUtil() final RoleRepository roleRepository = CdiUtil.createCdiUtil()
.findBean(RoleRepository.class); .findBean(RoleRepository.class);
final Role role = roleRepository.findById(Long.parseLong( final Role role = roleRepository.findById(Long.parseLong(
selectedRoleId.getSelectedKey(state))); selectedRoleId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.role_details.heading", "ui.admin.role_details.heading",
ADMIN_BUNDLE, ADMIN_BUNDLE,

View File

@ -31,6 +31,8 @@ import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.Role; import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository; import org.libreccm.security.RoleRepository;
import java.util.Optional;
import static com.arsdigita.ui.admin.AdminUiConstants.*; import static com.arsdigita.ui.admin.AdminUiConstants.*;
/** /**
@ -106,7 +108,8 @@ class RoleForm extends Form {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final RoleRepository roleRepository = cdiUtil.findBean( final RoleRepository roleRepository = cdiUtil.findBean(
RoleRepository.class); RoleRepository.class);
if (roleRepository.findByName(roleNameData) != null) { final Optional<Role> role = roleRepository.findByName(roleNameData);
if (role.isPresent()) {
data.addError(ROLE_NAME, new GlobalizedMessage( data.addError(ROLE_NAME, new GlobalizedMessage(
"ui.admin.role.error.name_already_in_use", "ui.admin.role.error.name_already_in_use",
ADMIN_BUNDLE)); ADMIN_BUNDLE));
@ -126,7 +129,7 @@ class RoleForm extends Form {
RoleRepository.class); RoleRepository.class);
final Role role = roleRepository.findById(Long.parseLong( final Role role = roleRepository.findById(Long.parseLong(
selectedRoleIdStr)); selectedRoleIdStr)).get();
roleName.setValue(state, role.getName()); roleName.setValue(state, role.getName());
} }
}); });
@ -151,7 +154,7 @@ class RoleForm extends Form {
roleRepository.save(role); roleRepository.save(role);
} else { } else {
final Role role = roleRepository.findById(Long.parseLong( final Role role = roleRepository.findById(Long.parseLong(
selectedRoleIdStr)); selectedRoleIdStr)).get();
role.setName(roleNameData); role.setName(roleNameData);
roleRepository.save(role); roleRepository.save(role);

View File

@ -119,9 +119,9 @@ class RoleMembersTable extends Table {
final RoleManager roleManager = cdiUtil.findBean( final RoleManager roleManager = cdiUtil.findBean(
RoleManager.class); RoleManager.class);
final Party party = partyRepository.findById(Long final Party party = partyRepository.findById(Long
.parseLong(key)); .parseLong(key)).get();
final Role role = roleRepository.findById( final Role role = roleRepository.findById(
Long.parseLong(selectedRoleId.getSelectedKey(state))); Long.parseLong(selectedRoleId.getSelectedKey(state))).get();
roleManager.removeRoleFromParty(role, party); roleManager.removeRoleFromParty(role, party);
break; break;
default: default:
@ -173,7 +173,7 @@ class RoleMembersTable extends Table {
final RoleRepository roleRepository = CdiUtil.createCdiUtil() final RoleRepository roleRepository = CdiUtil.createCdiUtil()
.findBean(RoleRepository.class); .findBean(RoleRepository.class);
final Role role = roleRepository.findById(Long.parseLong( final Role role = roleRepository.findById(Long.parseLong(
selectedRoleId.getSelectedKey(state))); selectedRoleId.getSelectedKey(state))).get();
members = new ArrayList<>(); members = new ArrayList<>();

View File

@ -78,7 +78,7 @@ class RolePermissionsForm extends Form {
final RoleRepository roleRepository = CdiUtil.createCdiUtil() final RoleRepository roleRepository = CdiUtil.createCdiUtil()
.findBean(RoleRepository.class); .findBean(RoleRepository.class);
final Role role = roleRepository.findById(Long.parseLong( final Role role = roleRepository.findById(Long.parseLong(
selectedRoleId.getSelectedKey(state))); selectedRoleId.getSelectedKey(state))).get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.role_details.add_permission.heading", "ui.admin.role_details.add_permission.heading",
@ -170,7 +170,7 @@ class RolePermissionsForm extends Form {
RoleRepository.class); RoleRepository.class);
final Role role = roleRepository.findById(Long.parseLong( final Role role = roleRepository.findById(Long.parseLong(
selectedRoleId.getSelectedKey(state))); selectedRoleId.getSelectedKey(state))).get();
final PermissionManager permissionManager = cdiUtil.findBean( final PermissionManager permissionManager = cdiUtil.findBean(
PermissionManager.class); PermissionManager.class);
if (objectIdData == null || objectIdData.isEmpty()) { if (objectIdData == null || objectIdData.isEmpty()) {

View File

@ -113,7 +113,7 @@ class RolePermissionsTable extends Table {
final PermissionManager permissionManager = cdiUtil final PermissionManager permissionManager = cdiUtil
.findBean(PermissionManager.class); .findBean(PermissionManager.class);
final Role role = roleRepository.findById( final Role role = roleRepository.findById(
Long.parseLong(selectedRoleId.getSelectedKey(state))); Long.parseLong(selectedRoleId.getSelectedKey(state))).get();
final Permission permission = permissionManager final Permission permission = permissionManager
.findById(Long.parseLong(key)); .findById(Long.parseLong(key));
if (permission.getObject() == null) { if (permission.getObject() == null) {
@ -176,7 +176,7 @@ class RolePermissionsTable extends Table {
.findBean(RoleRepository.class); .findBean(RoleRepository.class);
final Role role = roleRepository.findById( final Role role = roleRepository.findById(
Long.parseLong(selectedRoleId.getSelectedKey(state)), Long.parseLong(selectedRoleId.getSelectedKey(state)),
Role.ENTITY_GRPAH_WITH_PERMISSIONS); Role.ENTITY_GRPAH_WITH_PERMISSIONS).get();
permissions = new ArrayList<>(role.getPermissions()); permissions = new ArrayList<>(role.getPermissions());

View File

@ -54,7 +54,8 @@ class RolePropertySheetModelBuilder extends LockableImpl
} else { } else {
final RoleRepository roleRepository = CdiUtil.createCdiUtil() final RoleRepository roleRepository = CdiUtil.createCdiUtil()
.findBean(RoleRepository.class); .findBean(RoleRepository.class);
selectedRole = roleRepository.findById(Long.parseLong(roleIdStr)); selectedRole = roleRepository.findById(Long.parseLong(roleIdStr))
.get();
} }
return new RolePropertySheetModel(selectedRole); return new RolePropertySheetModel(selectedRole);

View File

@ -131,7 +131,7 @@ class RolesTable extends Table {
final RoleRepository roleRepository = CdiUtil final RoleRepository roleRepository = CdiUtil
.createCdiUtil().findBean(RoleRepository.class); .createCdiUtil().findBean(RoleRepository.class);
final Role role = roleRepository.findById(Long final Role role = roleRepository.findById(Long
.parseLong(key)); .parseLong(key)).get();
roleRepository.delete(role); roleRepository.delete(role);
break; break;
default: default:

View File

@ -80,7 +80,7 @@ class ActionLinks extends BoxPanel {
final UserRepository userRepository = cdiUtil.findBean( final UserRepository userRepository = cdiUtil.findBean(
UserRepository.class); UserRepository.class);
final User user = userRepository.findById(Long.parseLong( final User user = userRepository.findById(Long.parseLong(
selectedUserId.getSelectedKey(e.getPageState()))); selectedUserId.getSelectedKey(e.getPageState()))).get();
final ChallengeManager challengeManager = cdiUtil.findBean( final ChallengeManager challengeManager = cdiUtil.findBean(
ChallengeManager.class); ChallengeManager.class);
try { try {

View File

@ -93,7 +93,7 @@ class EmailForm extends Form {
final UserRepository userRepository = CdiUtil.createCdiUtil() final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class); .findBean(UserRepository.class);
final User user = userRepository.findById(Long.parseLong( final User user = userRepository.findById(Long.parseLong(
userIdStr)); userIdStr)).get();
EmailAddress email = null; EmailAddress email = null;
if (user.getPrimaryEmailAddress().getAddress().equals(selected)) { if (user.getPrimaryEmailAddress().getAddress().equals(selected)) {
email = user.getPrimaryEmailAddress(); email = user.getPrimaryEmailAddress();
@ -147,7 +147,7 @@ class EmailForm extends Form {
final UserRepository userRepository = CdiUtil.createCdiUtil() final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class); .findBean(UserRepository.class);
final User user = userRepository.findById(Long.parseLong( final User user = userRepository.findById(Long.parseLong(
userIdStr)); userIdStr)).get();
EmailAddress email = null; EmailAddress email = null;
if (selected == null) { if (selected == null) {
email = new EmailAddress(); email = new EmailAddress();

View File

@ -135,7 +135,7 @@ class EmailTable extends Table {
final UserRepository userRepository = CdiUtil final UserRepository userRepository = CdiUtil
.createCdiUtil().findBean(UserRepository.class); .createCdiUtil().findBean(UserRepository.class);
final User user = userRepository.findById(Long final User user = userRepository.findById(Long
.parseLong(userIdStr)); .parseLong(userIdStr)).get();
EmailAddress email = null; EmailAddress email = null;
for (EmailAddress current : user.getEmailAddresses()) { for (EmailAddress current : user.getEmailAddresses()) {
if (current.getAddress().equals(key)) { if (current.getAddress().equals(key)) {

View File

@ -54,7 +54,7 @@ class EmailTableModelBuilder extends LockableImpl
final UserRepository userRepository = CdiUtil.createCdiUtil() final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class); .findBean(UserRepository.class);
final long userId = Long.parseLong(userIdStr); final long userId = Long.parseLong(userIdStr);
selectedUser = userRepository.findById(userId); selectedUser = userRepository.findById(userId).get();
} }
return new EmailTableModel(selectedUser); return new EmailTableModel(selectedUser);

View File

@ -76,7 +76,8 @@ class GroupMembershipsForm extends Form {
final String userIdStr = selectedUserId.getSelectedKey(state); final String userIdStr = selectedUserId.getSelectedKey(state);
final UserRepository userRepository = CdiUtil.createCdiUtil() final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class); .findBean(UserRepository.class);
final User user = userRepository.findById(Long.parseLong(userIdStr)); final User user = userRepository.findById(Long.parseLong(userIdStr))
.get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.user.edit_group_memberships", "ui.admin.user.edit_group_memberships",
@ -136,7 +137,7 @@ class GroupMembershipsForm extends Form {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final User user = userRepository.findById(Long.parseLong( final User user = userRepository.findById(Long.parseLong(
selectedUserId.getSelectedKey(state))); selectedUserId.getSelectedKey(state))).get();
final List<Group> assignedGroups = new ArrayList<>(); final List<Group> assignedGroups = new ArrayList<>();
user.getGroupMemberships().forEach(m -> { user.getGroupMemberships().forEach(m -> {
assignedGroups.add(m.getGroup()); assignedGroups.add(m.getGroup());
@ -168,12 +169,12 @@ class GroupMembershipsForm extends Form {
GROUPS_SELECTOR); GROUPS_SELECTOR);
final User user = userRepository.findById(Long.parseLong( final User user = userRepository.findById(Long.parseLong(
selectedUserId.getSelectedKey(state))); selectedUserId.getSelectedKey(state))).get();
final List<Group> selectedGroups = new ArrayList<>(); final List<Group> selectedGroups = new ArrayList<>();
if (selectedGroupIds != null) { if (selectedGroupIds != null) {
Arrays.stream(selectedGroupIds).forEach(id -> { Arrays.stream(selectedGroupIds).forEach(id -> {
final Group group = groupRepository.findById( final Group group = groupRepository.findById(
Long.parseLong(id)); Long.parseLong(id)).get();
selectedGroups.add(group); selectedGroups.add(group);
}); });
} }
@ -195,7 +196,7 @@ class GroupMembershipsForm extends Form {
//The group is maybe detached or not fully loaded, //The group is maybe detached or not fully loaded,
//therefore we load the group from the database. //therefore we load the group from the database.
final Group group = groupRepository.findById( final Group group = groupRepository.findById(
g.getPartyId()); g.getPartyId()).get();
groupManager.removeMemberFromGroup(user, group); groupManager.removeMemberFromGroup(user, group);
} }
}); });

View File

@ -54,7 +54,7 @@ class GroupsRolesTableModelBuilder extends LockableImpl
final UserRepository userRepository = CdiUtil.createCdiUtil() final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class); .findBean(UserRepository.class);
final long userId = Long.parseLong(userIdStr); final long userId = Long.parseLong(userIdStr);
selectedUser = userRepository.findById(userId); selectedUser = userRepository.findById(userId).get();
} }
return new GroupsRolesTableModel(selectedUser); return new GroupsRolesTableModel(selectedUser);

View File

@ -114,7 +114,7 @@ class PasswordSetForm extends Form {
final UserRepository userRepository = CdiUtil.createCdiUtil() final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class); .findBean(UserRepository.class);
final User user = userRepository.findById(Long.parseLong( final User user = userRepository.findById(Long.parseLong(
userIdStr)); userIdStr)).get();
final UserManager userManager = CdiUtil.createCdiUtil() final UserManager userManager = CdiUtil.createCdiUtil()
.findBean( .findBean(

View File

@ -54,7 +54,7 @@ class PrimaryEmailTableModelBuilder extends LockableImpl
final UserRepository userRepository = CdiUtil.createCdiUtil() final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class); .findBean(UserRepository.class);
final long userId = Long.parseLong(userIdStr); final long userId = Long.parseLong(userIdStr);
selectedUser = userRepository.findById(userId); selectedUser = userRepository.findById(userId).get();
} }
return new PrimaryEmailTableModel(selectedUser); return new PrimaryEmailTableModel(selectedUser);

View File

@ -75,7 +75,8 @@ class RoleMembershipsForm extends Form {
final String userIdStr = selectedUserId.getSelectedKey(state); final String userIdStr = selectedUserId.getSelectedKey(state);
final UserRepository userRepository = CdiUtil.createCdiUtil() final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class); .findBean(UserRepository.class);
final User user = userRepository.findById(Long.parseLong(userIdStr)); final User user = userRepository.findById(Long.parseLong(userIdStr))
.get();
target.setLabel(new GlobalizedMessage( target.setLabel(new GlobalizedMessage(
"ui.admin.user_edit_role_memberships", "ui.admin.user_edit_role_memberships",
@ -136,7 +137,7 @@ class RoleMembershipsForm extends Form {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final User user = userRepository.findById(Long.parseLong( final User user = userRepository.findById(Long.parseLong(
selectedUserId.getSelectedKey(state))); selectedUserId.getSelectedKey(state))).get();
final List<Role> assignedRoles = new ArrayList<>(); final List<Role> assignedRoles = new ArrayList<>();
user.getRoleMemberships().forEach(m -> { user.getRoleMemberships().forEach(m -> {
assignedRoles.add(m.getRole()); assignedRoles.add(m.getRole());
@ -170,12 +171,12 @@ class RoleMembershipsForm extends Form {
ROLES_SELECTOR); ROLES_SELECTOR);
final User user = userRepository.findById(Long.parseLong( final User user = userRepository.findById(Long.parseLong(
selectedUserId.getSelectedKey(state))); selectedUserId.getSelectedKey(state))).get();
final List<Role> selectedRoles = new ArrayList<>(); final List<Role> selectedRoles = new ArrayList<>();
if (selectedRolesIds != null) { if (selectedRolesIds != null) {
Arrays.stream(selectedRolesIds).forEach(id -> { Arrays.stream(selectedRolesIds).forEach(id -> {
final Role role = roleRepository.findById( final Role role = roleRepository.findById(
Long.parseLong(id)); Long.parseLong(id)).get();
selectedRoles.add(role); selectedRoles.add(role);
}); });
} }
@ -196,7 +197,8 @@ class RoleMembershipsForm extends Form {
if (!selectedRoles.contains(r)) { if (!selectedRoles.contains(r)) {
//Role is maybe detached or not fully loaded, //Role is maybe detached or not fully loaded,
//therefore we load the role from the database. //therefore we load the role from the database.
final Role role = roleRepository.findById(r.getRoleId()); final Role role = roleRepository.findById(r.getRoleId())
.get();
roleManager.removeRoleFromParty(role, user); roleManager.removeRoleFromParty(role, user);
} }
}); });

Some files were not shown because too many files have changed in this diff Show More