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-94f89814c4dfpull/2/head
parent
809475465a
commit
d00f438bdd
|
|
@ -141,7 +141,7 @@ public class ItemSelectionModel extends CcmObjectSelectionModel<ContentItem> {
|
|||
|
||||
if (typeId != null) {
|
||||
type = CdiUtil.createCdiUtil().findBean(ContentTypeRepository.class)
|
||||
.findById(typeId);
|
||||
.findById(typeId).get();
|
||||
}
|
||||
|
||||
return type;
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
} else if (remainingUrl.endsWith(ItemDispatcher.FILE_SUFFIX)) {
|
||||
remainingUrl = remainingUrl.substring(0, remainingUrl.length()
|
||||
- ItemDispatcher.FILE_SUFFIX
|
||||
.length());
|
||||
.length());
|
||||
} else if (remainingUrl.equals("")) {
|
||||
remainingUrl = "index";
|
||||
}
|
||||
|
|
@ -362,8 +362,7 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
* @param request The HTTP request
|
||||
* @param response The HTTP response
|
||||
* @param actx The request context
|
||||
*
|
||||
* @exception AccessDeniedException if the user does not have access.
|
||||
* @throws javax.servlet.ServletException
|
||||
*
|
||||
*/
|
||||
protected void checkUserAccess(HttpServletRequest request,
|
||||
|
|
@ -371,10 +370,11 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
RequestContext actx)
|
||||
throws ServletException, AuthorizationException {
|
||||
|
||||
final Shiro shiro = CdiUtil.createCdiUtil().findBean(Shiro.class);
|
||||
User user = shiro.getUser();
|
||||
final PermissionChecker permissionChecker = CdiUtil.createCdiUtil()
|
||||
.findBean(PermissionChecker.class);
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final Shiro shiro = cdiUtil.findBean(Shiro.class);
|
||||
User user = shiro.getUser().get();
|
||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||
PermissionChecker.class);
|
||||
|
||||
ContentSection section = getContentSection(request);
|
||||
|
||||
|
|
@ -492,6 +492,7 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
* @param context The use context
|
||||
*
|
||||
* @return The item associated with the URL, or null if no such item exists
|
||||
*
|
||||
* @throws javax.servlet.ServletException
|
||||
*/
|
||||
protected ContentItem getContentItem(ContentSection section, String url,
|
||||
|
|
@ -499,8 +500,10 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
throws ServletException {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ContentSectionManager sectionManager = cdiUtil.findBean(ContentSectionManager.class);
|
||||
final ItemResolver itemResolver = sectionManager.getItemResolver(section);
|
||||
final ContentSectionManager sectionManager = cdiUtil.findBean(
|
||||
ContentSectionManager.class);
|
||||
final ItemResolver itemResolver = sectionManager
|
||||
.getItemResolver(section);
|
||||
|
||||
return itemResolver.getItem(section, url, context);
|
||||
}
|
||||
|
|
@ -537,9 +540,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
try {
|
||||
pageResolver = (PageResolver) Class.forName(pageResolverClassName)
|
||||
.newInstance();
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
InstantiationException ex) {
|
||||
} catch (ClassNotFoundException
|
||||
| IllegalAccessException
|
||||
| InstantiationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
pageResolver.releasePage(url);
|
||||
|
|
@ -568,9 +571,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
pageResolver = (PageResolver) Class.forName(
|
||||
pageResolverClassName)
|
||||
.newInstance();
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
InstantiationException ex) {
|
||||
} catch (ClassNotFoundException
|
||||
| IllegalAccessException
|
||||
| InstantiationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
s_pageResolverCache.put(name, pageResolver);
|
||||
|
|
@ -590,8 +593,8 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
|
||||
final Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(section.getItemResolverClass());
|
||||
} catch(ClassNotFoundException ex) {
|
||||
clazz = Class.forName(section.getItemResolverClass());
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
|
||||
|
|
@ -614,9 +617,9 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher {
|
|||
try {
|
||||
xmlGenerator = (XMLGenerator) Class.forName(
|
||||
xmlGeneratorClassName).newInstance();
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
InstantiationException ex) {
|
||||
} catch (ClassNotFoundException
|
||||
| IllegalAccessException
|
||||
| InstantiationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
s_xmlGeneratorCache.put(name, xmlGenerator);
|
||||
|
|
|
|||
|
|
@ -44,13 +44,14 @@ import org.libreccm.security.PermissionChecker;
|
|||
import org.libreccm.security.Shiro;
|
||||
import org.libreccm.security.User;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.ContentItemRepository;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ContentSectionServlet;
|
||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
* <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
|
||||
protected Element generateXMLHelper(PageState ps, Document parent) {
|
||||
Element page = super.generateXMLHelper(ps,parent);
|
||||
final User user = CdiUtil.createCdiUtil().findBean(Shiro.class).getUser();
|
||||
if ( user != null ) {
|
||||
page.addAttribute("name",user.getName());
|
||||
final Optional<User> user = CdiUtil.createCdiUtil().findBean(Shiro.class).getUser();
|
||||
if ( user.isPresent()) {
|
||||
page.addAttribute("name",user.get().getName());
|
||||
}
|
||||
|
||||
return page;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.libreccm.web.CcmApplication;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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
|
||||
// way from the API if possible.
|
||||
final Shiro shiro = CdiUtil.createCdiUtil().findBean(Shiro.class);
|
||||
final User user = shiro.getUser();
|
||||
final Optional<User> user = shiro.getUser();
|
||||
// User user = Web.getWebContext().getUser();
|
||||
if ( user != null ) {
|
||||
pageElement.addAttribute("name",user.getName());
|
||||
if (user.isPresent()) {
|
||||
pageElement.addAttribute("name",user.get().getName());
|
||||
}
|
||||
|
||||
return pageElement;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import org.librecms.contenttypes.ContentTypesManager;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* An invisible component which contains all the possible creation components.
|
||||
|
|
@ -154,15 +155,15 @@ public class CreationSelector extends MetaForm {
|
|||
final ContentTypesManager typesManager = cdiUtil.findBean(
|
||||
ContentTypesManager.class);
|
||||
|
||||
final ContentType type = typeRepo.findById(typeId);
|
||||
if (type == null) {
|
||||
final Optional<ContentType> type = typeRepo.findById(typeId);
|
||||
if (!type.isPresent()) {
|
||||
throw new UncheckedWrapperException(String.format(
|
||||
"Type with id %d not found.", typeId));
|
||||
}
|
||||
final ContentTypeInfo typeInfo = typesManager.getContentTypeInfo(
|
||||
type);
|
||||
type.get());
|
||||
final AuthoringKitInfo kit = typeInfo.getAuthoringKit();
|
||||
component = instantiateKitComponent(kit, type);
|
||||
component = instantiateKitComponent(kit, type.get());
|
||||
if (component != null) {
|
||||
returnForm.add(component);
|
||||
returnForm.setMethod(Form.POST);
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public abstract class NewItemForm extends Form {
|
|||
if (singleTypeID == null) {
|
||||
parentType = null;
|
||||
} else {
|
||||
parentType = typeRepo.findById(singleTypeID);
|
||||
parentType = typeRepo.findById(singleTypeID).get();
|
||||
}
|
||||
|
||||
typesCollection = section.getContentTypes().stream()
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@ public class FolderManipulator extends SimpleContainer implements
|
|||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||
PermissionChecker.class);
|
||||
|
||||
final ContentItem item = itemRepo.findById(itemId);
|
||||
final ContentItem item = itemRepo.findById(itemId).get();
|
||||
final String name = item.getDisplayName();
|
||||
|
||||
final long count = itemRepo.countByNameInFolder(target, name);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class Summary extends CMSContainer {
|
|||
final ContentSection section = getContentSection(state);
|
||||
|
||||
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
|
||||
final Element itemElement = new Element("cms:itemSummary",
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class DeletePhaseForm extends CMSForm
|
|||
|
||||
// Check if the object is already deleted for double click
|
||||
// protection.
|
||||
final PhaseDefinition phaseDef = phaseDefRepo.findById(key);
|
||||
final PhaseDefinition phaseDef = phaseDefRepo.findById(key).get();
|
||||
if (phaseDef != null) {
|
||||
phaseDefRepo.delete(phaseDef);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
|
|||
final ContentItem item = selectedItem.getContentItem(state);
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
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.
|
||||
|
|
@ -360,10 +360,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
|
|||
UserRepository.class);
|
||||
final User receiver = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureReceiver());
|
||||
.getPublishingFailureReceiver()).get();
|
||||
final User sender = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureSender());
|
||||
.getPublishingFailureSender()).get();
|
||||
|
||||
if ((sender != null) && (receiver != null)) {
|
||||
final Writer traceWriter = new StringWriter();
|
||||
|
|
@ -467,7 +467,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
|
|||
final ContentItem item = selectedItem.getContentItem(state);
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
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
|
||||
|
|
@ -506,10 +506,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
|
|||
UserRepository.class);
|
||||
final User receiver = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureReceiver());
|
||||
.getPublishingFailureReceiver()).get();
|
||||
final User sender = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureSender());
|
||||
.getPublishingFailureSender()).get();
|
||||
|
||||
if ((sender != null) && (receiver != null)) {
|
||||
final Writer traceWriter = new StringWriter();
|
||||
|
|
@ -698,7 +698,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
|
|||
final FormData data = event.getFormData();
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
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);
|
||||
final ContentItem item = selectedItem.getContentItem(state);
|
||||
|
|
@ -743,10 +743,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
|
|||
UserRepository.class);
|
||||
final User receiver = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureReceiver());
|
||||
.getPublishingFailureReceiver()).get();
|
||||
final User sender = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureSender());
|
||||
.getPublishingFailureSender()).get();
|
||||
|
||||
if ((sender != null) && (receiver != null)) {
|
||||
final Writer traceWriter = new StringWriter();
|
||||
|
|
@ -831,10 +831,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
|
|||
UserRepository.class);
|
||||
final User receiver = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureReceiver());
|
||||
.getPublishingFailureReceiver()).get();
|
||||
final User sender = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureSender());
|
||||
.getPublishingFailureSender()).get();
|
||||
|
||||
if ((sender != null) && (receiver != null)) {
|
||||
final Writer traceWriter = new StringWriter();
|
||||
|
|
|
|||
|
|
@ -433,10 +433,10 @@ class ItemLifecycleSelectForm extends BaseForm {
|
|||
UserRepository.class);
|
||||
final User receiver = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureReceiver());
|
||||
.getPublishingFailureReceiver()).get();
|
||||
final User sender = userRepo.findByEmailAddress(
|
||||
CMSConfig.getConfig()
|
||||
.getPublishingFailureSender());
|
||||
.getPublishingFailureSender()).get();
|
||||
|
||||
if ((sender != null) && (receiver != null)) {
|
||||
final Writer traceWriter = new StringWriter();
|
||||
|
|
@ -714,7 +714,7 @@ class ItemLifecycleSelectForm extends BaseForm {
|
|||
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 Lifecycle lifecycle;
|
||||
// Apply the new lifecycle.
|
||||
cycleDef = lifecycleDefRepo.findById(defID);
|
||||
cycleDef = lifecycleDefRepo.findById(defID).get();
|
||||
pending = itemManager.publish(item, cycleDef);
|
||||
lifecycle = pending.getLifecycle();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import org.libreccm.core.CcmObjectRepository;
|
|||
import org.libreccm.security.Role;
|
||||
import org.libreccm.security.RoleRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
@ -71,13 +73,13 @@ class CMSUserObjectStruct {
|
|||
final CcmObjectRepository objectRepo = cdiUtil.findBean(
|
||||
CcmObjectRepository.class);
|
||||
|
||||
final CcmObject ccmObject = objectRepo.findById(objectId);
|
||||
if (ccmObject == null) {
|
||||
final Optional<CcmObject> ccmObject = objectRepo.findById(objectId);
|
||||
if (!ccmObject.isPresent()) {
|
||||
throw new UncheckedWrapperException(String.format(
|
||||
"Failed to find object with ID %d.", objectId));
|
||||
}
|
||||
|
||||
return ccmObject;
|
||||
return ccmObject.get();
|
||||
}
|
||||
|
||||
// use in package
|
||||
|
|
@ -86,14 +88,14 @@ class CMSUserObjectStruct {
|
|||
final RoleRepository roleRepo = cdiUtil
|
||||
.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(
|
||||
"Failed to find party with ID %d.", roleId));
|
||||
}
|
||||
|
||||
return role;
|
||||
return role.get();
|
||||
}
|
||||
|
||||
public static Role getRole(final PageState state) {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import org.librecms.CmsConstants;
|
|||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
/**
|
||||
|
|
@ -263,14 +264,14 @@ public class ObjectAddAdmin extends SimpleContainer
|
|||
|
||||
// Add each checked user to the object
|
||||
for (final String roleId : roleIds) {
|
||||
final Role role = roleRepo.findById(Long.parseLong(roleId));
|
||||
if (role == null) {
|
||||
final Optional<Role> role = roleRepo.findById(Long.parseLong(roleId));
|
||||
if (!role.isPresent()) {
|
||||
throw new FormProcessException(new GlobalizedMessage(
|
||||
"cms.ui.permissions.cannot_add_user",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
}
|
||||
permissionManager.grantPrivilege(ItemPrivileges.ADMINISTER,
|
||||
role,
|
||||
role.get(),
|
||||
object);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ import com.arsdigita.bebop.table.TableCellRenderer;
|
|||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.dispatcher.AccessDeniedException;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.ui.CcmObjectSelectionModel;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
|
@ -44,7 +42,6 @@ import com.arsdigita.util.UncheckedWrapperException;
|
|||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.security.Party;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.libreccm.security.PermissionManager;
|
||||
import org.libreccm.security.Role;
|
||||
|
|
@ -52,9 +49,9 @@ import org.libreccm.security.RoleRepository;
|
|||
import org.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ObjectAdminListing extends SimpleContainer {
|
||||
|
|
@ -146,14 +143,14 @@ public class ObjectAdminListing extends SimpleContainer {
|
|||
ItemPrivileges.ADMINISTER, object);
|
||||
|
||||
final String roleId = (String) event.getRowKey();
|
||||
final Role role = roleRepo.findById(Long.parseLong(roleId));
|
||||
if (role == null) {
|
||||
final Optional<Role> role = roleRepo.findById(Long.parseLong(roleId));
|
||||
if (!role.isPresent()) {
|
||||
throw new UncheckedWrapperException(String.format(
|
||||
"No role with id %s found.", roleId));
|
||||
}
|
||||
|
||||
permissionManager.revokePrivilege(ItemPrivileges.ADMINISTER,
|
||||
role,
|
||||
role.get(),
|
||||
object);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class ContentSectionSummaryController {
|
|||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<RowData<Long>> createReportData(final ContentSection section) {
|
||||
final ContentSection contentSection = sectionRepo.findById(
|
||||
section.getObjectId());
|
||||
section.getObjectId()).get();
|
||||
|
||||
final List<Folder> rootFolders = contentSection.getRootDocumentsFolder()
|
||||
.getSubFolders();
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ class BaseRoleItemPane extends BaseItemPane {
|
|||
PartyRepository.class);
|
||||
final RoleManager roleManager = cdiUtil.findBean(
|
||||
RoleManager.class);
|
||||
final Party party = partyRepository.findById(itemId);
|
||||
final Party party = partyRepository.findById(itemId).get();
|
||||
|
||||
roleManager.removeRoleFromParty(role, party);
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ public class RoleAdminPane extends BaseAdminPane<String> {
|
|||
final RoleRepository roleRepository = cdiUtil.findBean(
|
||||
RoleRepository.class);
|
||||
final Long id = Long.parseLong(selectionModel.getSelectedKey(state));
|
||||
final Role role = roleRepository.findById(id);
|
||||
final Role role = roleRepository.findById(id).get();
|
||||
|
||||
roleRepository.delete(role);
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class RolePartyAddForm extends PartyAddForm {
|
|||
final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.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
|
||||
Party party;
|
||||
|
|
@ -108,7 +108,7 @@ class RolePartyAddForm extends PartyAddForm {
|
|||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("parties[" + i + "] = " + parties[i]);
|
||||
}
|
||||
party = partyRepository.findByName(parties[i]);
|
||||
party = partyRepository.findByName(parties[i]).get();
|
||||
roleManager.assignRoleToParty(role, party);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ import org.librecms.lifecycle.LifecycleDefinitionRepository;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
import javax.persistence.NoResultException;
|
||||
|
|
@ -225,12 +226,20 @@ public class EditType extends CMSForm
|
|||
final ContentTypeRepository typeRepo = cdiUtil.findBean(
|
||||
ContentTypeRepository.class);
|
||||
|
||||
final Optional<ContentType> result;
|
||||
try {
|
||||
return typeRepo.findById(Long.parseLong(key));
|
||||
} catch (NumberFormatException
|
||||
| NoResultException ex) {
|
||||
result = typeRepo.findById(Long.parseLong(key));
|
||||
} catch (NumberFormatException ex) {
|
||||
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(
|
||||
ContentTypeManager.class);
|
||||
|
||||
ContentType type = null;
|
||||
try {
|
||||
type = typeRepo.findById(key);
|
||||
} catch (NoResultException ex) {
|
||||
final Optional<ContentType> type = typeRepo.findById(key);
|
||||
if (!type.isPresent()) {
|
||||
LOGGER.error("Can't find ContentType with key {}", key);
|
||||
LOGGER.error(ex);
|
||||
|
||||
throw new FormProcessException(new GlobalizedMessage(
|
||||
"cms.ui.type.content_editing_failed",
|
||||
CmsConstants.CMS_BUNDLE,
|
||||
|
|
@ -281,20 +286,20 @@ public class EditType extends CMSForm
|
|||
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
|
||||
type.getLabel().addValue(kernelConfig.getDefaultLocale(), label);
|
||||
type.getDescription().addValue(kernelConfig.getDefaultLocale(),
|
||||
type.get().getLabel().addValue(kernelConfig.getDefaultLocale(), label);
|
||||
type.get().getDescription().addValue(kernelConfig.getDefaultLocale(),
|
||||
description);
|
||||
|
||||
typeRepo.save(type);
|
||||
typeRepo.save(type.get());
|
||||
|
||||
// Handle default lifecycle and workflow.
|
||||
final LifecycleDefinition defaultLifecycle = lifecycleDefRepo.findById(
|
||||
lifecycleId);
|
||||
lifecycleId).get();
|
||||
final WorkflowTemplate defaultWorkflow = workflowTemplateRepo.findById(
|
||||
workflowId);
|
||||
workflowId).get();
|
||||
|
||||
typeManager.setDefaultLifecycle(type, defaultLifecycle);
|
||||
typeManager.setDefaultWorkflow(type, defaultWorkflow);
|
||||
typeManager.setDefaultLifecycle(type.get(), defaultLifecycle);
|
||||
typeManager.setDefaultWorkflow(type.get(), defaultWorkflow);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public class TypePermissionsTable extends Table implements TableActionListener {
|
|||
|
||||
if (TABLE_COL_ACTION.equals(column.getHeaderKey().toString())) {
|
||||
final Role role = roleRepo.findById(Long.parseLong(
|
||||
event.getRowKey().toString()));
|
||||
event.getRowKey().toString())).get();
|
||||
ContentType contentType = getType().getContentType(state);
|
||||
|
||||
controller.toggleTypeUsePermission(contentType, role);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class TypePermissionsTableController {
|
|||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<RowData<Long>> retrieveTypePermissions(
|
||||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class AssignedTaskController {
|
|||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
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,
|
||||
workflow);
|
||||
|
||||
|
|
|
|||
|
|
@ -174,8 +174,8 @@ public final class AssignedTaskSection extends Section {
|
|||
final AssignableTaskRepository userTaskRepo = cdiUtil.findBean(
|
||||
AssignableTaskRepository.class);
|
||||
final Shiro shiro = cdiUtil.findBean(Shiro.class);
|
||||
return userTaskRepo.findEnabledTasksForWorkflow(shiro.getUser(),
|
||||
workflow);
|
||||
return userTaskRepo.findEnabledTasksForWorkflow(
|
||||
shiro.getUser().get(), workflow);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ public final class AssignedTaskTable extends Table {
|
|||
|
||||
if (column == 1) {
|
||||
final AssignableTask task = userTaskRepo.findById((Long) event
|
||||
.getRowKey());
|
||||
final User currentUser = shiro.getUser();
|
||||
.getRowKey()).get();
|
||||
final User currentUser = shiro.getUser().get();
|
||||
final User lockingUser = task.getLockingUser();
|
||||
if (task.isLocked()
|
||||
&& lockingUser != null
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class BaseTaskForm extends BaseForm {
|
|||
selectedId = Long.parseLong(selectedDependency);
|
||||
addedTask = toRemove.remove(selectedId);
|
||||
if (addedTask == null) {
|
||||
toAdd.put(selectedId, taskRepo.findById(selectedId));
|
||||
toAdd.put(selectedId, taskRepo.findById(selectedId).get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ abstract class BaseWorkflowItemPane extends BaseItemPane {
|
|||
final User lockingUser = task.getLockingUser();
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final Shiro shiro = cdiUtil.findBean(Shiro.class);
|
||||
final User currentUser = shiro.getUser();
|
||||
final User currentUser = shiro.getUser().get();
|
||||
|
||||
return task.isLocked() && (lockingUser == null
|
||||
|| lockingUser.equals(currentUser));
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import com.arsdigita.bebop.PageState;
|
|||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.cms.CMS;
|
||||
|
||||
import org.librecms.workflow.CmsTask;
|
||||
import com.arsdigita.web.Web;
|
||||
import org.libreccm.workflow.Workflow;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
|
|
@ -75,7 +75,7 @@ final class ItemWorkflowItemPane extends BaseWorkflowItemPane {
|
|||
final TaskRepository taskRepo = cdiUtil.findBean(
|
||||
TaskRepository.class);
|
||||
|
||||
return (CmsTask) taskRepo.findById(Long.parseLong(taskId));
|
||||
return (CmsTask) taskRepo.findById(Long.parseLong(taskId)).get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import org.librecms.contentsection.ContentItem;
|
|||
class ItemWorkflowSelectForm extends CMSForm {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
ItemWorkflowSelectForm.class);
|
||||
ItemWorkflowSelectForm.class);
|
||||
|
||||
private RadioGroup radioGroup;
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ class ItemWorkflowSelectForm extends CMSForm {
|
|||
|
||||
@Override
|
||||
public final void process(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
final Long flowId = (Long) radioGroup.getValue(state);
|
||||
|
|
@ -98,13 +98,16 @@ class ItemWorkflowSelectForm extends CMSForm {
|
|||
if (item.getWorkflow() == null) {
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final WorkflowTemplateRepository templateRepo = cdiUtil.
|
||||
findBean(WorkflowTemplateRepository.class);
|
||||
findBean(WorkflowTemplateRepository.class);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class ItemWorkflowSelectionModel extends ParameterSingleSelectionModel {
|
|||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ContentItemRepository itemRepo = cdiUtil.findBean(ContentItemRepository.class);
|
||||
final ContentItem item = itemRepo.findById((Long) super.getSelectedKey(
|
||||
state));
|
||||
state)).get();
|
||||
|
||||
return item.getWorkflow().getWorkflowId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class TaskAddRole extends CMSForm {
|
|||
if (roleIds != null) {
|
||||
for (final String roleId : roleIds) {
|
||||
final Role role = roleRepository.findById(Long
|
||||
.parseLong(roleId));
|
||||
.parseLong(roleId)).get();
|
||||
taskManager.assignTask(task, role);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.arsdigita.bebop.PageState;
|
|||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ui.UserAddForm;
|
||||
import com.arsdigita.cms.ui.UserSearchForm;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
|
@ -40,7 +39,6 @@ import org.libreccm.security.UserRepository;
|
|||
import org.libreccm.workflow.WorkflowManager;
|
||||
import org.librecms.CmsConstants;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -150,7 +148,7 @@ class TaskAddUser extends SimpleContainer {
|
|||
User user;
|
||||
|
||||
for (int i = 0; i < users.length; i++) {
|
||||
user = userRepo.findById(Long.parseLong(users[i]));
|
||||
user = userRepo.findById(Long.parseLong(users[i])).get();
|
||||
|
||||
//ToDo
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class TaskFinishFormController {
|
|||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
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()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ final class TaskItemPane extends BaseItemPane {
|
|||
AssignableTaskManager.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);
|
||||
|
||||
|
|
@ -387,7 +387,7 @@ final class TaskItemPane extends BaseItemPane {
|
|||
final RoleRepository roleRepo = cdiUtil.findBean(
|
||||
RoleRepository.class);
|
||||
|
||||
final Role role = roleRepo.findById(roleId);
|
||||
final Role role = roleRepo.findById(roleId).get();
|
||||
taskManager.retractTask(task, role);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ public class ContentItemManager {
|
|||
// Ensure that we are using a fresh folder and that the folder was
|
||||
// retrieved in this transaction to avoid problems with lazy fetched
|
||||
// data.
|
||||
final Folder theFolder = folderRepo.findById(folder.getObjectId());
|
||||
final Folder theFolder = folderRepo.findById(folder.getObjectId()).get();
|
||||
|
||||
theFolder.getObjects()
|
||||
.stream()
|
||||
|
|
@ -1120,7 +1120,7 @@ public class ContentItemManager {
|
|||
// Ensure that we are using a fresh folder and that the folder was
|
||||
// retrieved in this transaction to avoid problems with lazy fetched
|
||||
// data.
|
||||
final Folder theFolder = folderRepo.findById(folder.getObjectId());
|
||||
final Folder theFolder = folderRepo.findById(folder.getObjectId()).get();
|
||||
|
||||
theFolder.getObjects()
|
||||
.stream()
|
||||
|
|
@ -1384,10 +1384,8 @@ public class ContentItemManager {
|
|||
*/
|
||||
public Optional<Folder> getItemFolder(final ContentItem item) {
|
||||
final List<Categorization> result = item.getCategories().stream()
|
||||
.filter(categorization -> {
|
||||
return CATEGORIZATION_TYPE_FOLDER.
|
||||
equals(categorization.getType());
|
||||
})
|
||||
.filter(categorization -> CATEGORIZATION_TYPE_FOLDER.equals(
|
||||
categorization.getType()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (result.size() > 0) {
|
||||
|
|
|
|||
|
|
@ -103,9 +103,9 @@ public class ContentItemRepository
|
|||
@SuppressWarnings("unchecked")
|
||||
public <T extends ContentItem> Optional<T> findById(final long itemId,
|
||||
final Class<T> type) {
|
||||
final CcmObject result = ccmObjectRepo.findById(itemId);
|
||||
if (result.getClass().isAssignableFrom(type)) {
|
||||
return Optional.of((T) result);
|
||||
final Optional<CcmObject> result = ccmObjectRepo.findById(itemId);
|
||||
if (result.get().getClass().isAssignableFrom(type)) {
|
||||
return Optional.of((T) result.get());
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,10 +351,10 @@ public class MultilingualItemResolver implements ItemResolver {
|
|||
// No template context here.
|
||||
return generateDraftURL(section, itemId);
|
||||
} else if (CMSDispatcher.PREVIEW.equals(context)) {
|
||||
final ContentItem item = itemRepo.findById(itemId);
|
||||
final ContentItem item = itemRepo.findById(itemId).get();
|
||||
return generatePreviewURL(section, item, templateContext);
|
||||
} 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);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -395,10 +395,10 @@ public class SimpleItemResolver implements ItemResolver {
|
|||
if (ContentItemVersion.DRAFT.toString().equals(context)) {
|
||||
return generateDraftURL(itemId, section);
|
||||
} 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);
|
||||
} else if (CMSDispatcher.PREVIEW.equals(context)) {
|
||||
final ContentItem item = itemRepo.findById(itemId);
|
||||
final ContentItem item = itemRepo.findById(itemId).get();
|
||||
return generatePreviewURL(item, section, templateContext);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ public class AssetManagerTest {
|
|||
"timestamp",
|
||||
"uuid"})
|
||||
public void shareAsset() throws MimeTypeParseException {
|
||||
final Folder folder = folderRepo.findById(-420L);
|
||||
final Folder folder = folderRepo.findById(-420L).get();
|
||||
assertThat(folder, is(not(nullValue())));
|
||||
|
||||
final File file = new File();
|
||||
|
|
@ -224,7 +224,6 @@ public class AssetManagerTest {
|
|||
|
||||
assetManager.shareAsset(file, folder);
|
||||
|
||||
assertThat(file, is(not(nullValue())));
|
||||
assertThat(file.getDisplayName(), is(equalTo("datasheet.pdf")));
|
||||
}
|
||||
|
||||
|
|
@ -242,8 +241,7 @@ public class AssetManagerTest {
|
|||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void shareAssetNull() {
|
||||
final Folder folder = folderRepo.findById(-420L);
|
||||
assertThat(folder, is(not(nullValue())));
|
||||
final Folder folder = folderRepo.findById(-420L).get();
|
||||
|
||||
assetManager.shareAsset(null, folder);
|
||||
}
|
||||
|
|
@ -286,11 +284,9 @@ public class AssetManagerTest {
|
|||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void shareAlreadySharedAsset() {
|
||||
final Folder folder = folderRepo.findById(-420L);
|
||||
assertThat(folder, is(not(nullValue())));
|
||||
final Folder folder = folderRepo.findById(-420L).get();
|
||||
|
||||
final Asset asset = assetRepo.findById(-700L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-700L).get();
|
||||
|
||||
assetManager.shareAsset(asset, folder);
|
||||
}
|
||||
|
|
@ -328,11 +324,9 @@ public class AssetManagerTest {
|
|||
"object_order",
|
||||
"uuid"})
|
||||
public void moveAssetToOtherFolder() {
|
||||
final Asset asset = assetRepo.findById(-900L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-900L).get();
|
||||
|
||||
final Folder folder = folderRepo.findById(-410L);
|
||||
assertThat(folder, is(not(nullValue())));
|
||||
final Folder folder = folderRepo.findById(-410L).get();
|
||||
|
||||
assetManager.move(asset, folder);
|
||||
}
|
||||
|
|
@ -354,11 +348,9 @@ public class AssetManagerTest {
|
|||
"object_order",
|
||||
"uuid"})
|
||||
public void moveAssetToFolderInOtherContentSection() {
|
||||
final Asset asset = assetRepo.findById(-900L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-900L).get();
|
||||
|
||||
final Folder folder = folderRepo.findById(-1600L);
|
||||
assertThat(folder, is(not(nullValue())));
|
||||
final Folder folder = folderRepo.findById(-1600L).get();
|
||||
|
||||
assetManager.move(asset, folder);
|
||||
}
|
||||
|
|
@ -379,8 +371,7 @@ public class AssetManagerTest {
|
|||
public void moveAssetNull() {
|
||||
final Asset asset = null;
|
||||
|
||||
final Folder folder = folderRepo.findById(-410L);
|
||||
assertThat(folder, is(not(nullValue())));
|
||||
final Folder folder = folderRepo.findById(-410L).get();
|
||||
|
||||
assetManager.move(asset, folder);
|
||||
}
|
||||
|
|
@ -399,8 +390,7 @@ public class AssetManagerTest {
|
|||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveAssetTargetFolderIsNull() {
|
||||
final Asset asset = assetRepo.findById(-900L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-900L).get();
|
||||
|
||||
final Folder targetFolder = null;
|
||||
|
||||
|
|
@ -421,11 +411,9 @@ public class AssetManagerTest {
|
|||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveAssetTargetFolderIsNotAssetFolder() {
|
||||
final Asset asset = assetRepo.findById(-900L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-900L).get();
|
||||
|
||||
final Folder folder = folderRepo.findById(-200L);
|
||||
assertThat(folder, is(not(nullValue())));
|
||||
final Folder folder = folderRepo.findById(-200L).get();
|
||||
|
||||
assetManager.move(asset, folder);
|
||||
}
|
||||
|
|
@ -450,11 +438,9 @@ public class AssetManagerTest {
|
|||
"categorization_id",
|
||||
"object_order"})
|
||||
public void copyAssetToOtherFolder() {
|
||||
final Asset asset = assetRepo.findById(-1100L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-1100L).get();
|
||||
|
||||
final Folder targetFolder = folderRepo.findById(-400L);
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
final Folder targetFolder = folderRepo.findById(-400L).get();
|
||||
|
||||
assetManager.copy(asset, targetFolder);
|
||||
}
|
||||
|
|
@ -479,11 +465,9 @@ public class AssetManagerTest {
|
|||
"categorization_id",
|
||||
"object_order"})
|
||||
public void copyAssetToSameFolder() {
|
||||
final Asset asset = assetRepo.findById(-1100L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-1100L).get();
|
||||
|
||||
final Folder targetFolder = folderRepo.findById(-420L);
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
final Folder targetFolder = folderRepo.findById(-420L).get();
|
||||
|
||||
assetManager.copy(asset, targetFolder);
|
||||
assetManager.copy(asset, targetFolder);
|
||||
|
|
@ -510,11 +494,9 @@ public class AssetManagerTest {
|
|||
"categorization_id",
|
||||
"object_order"})
|
||||
public void copyAssetToOtherContentSection() {
|
||||
final Asset asset = assetRepo.findById(-1100L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-1100L).get();
|
||||
|
||||
final Folder targetFolder = folderRepo.findById(-1600L);
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
final Folder targetFolder = folderRepo.findById(-1600L).get();
|
||||
|
||||
assetManager.copy(asset, targetFolder);
|
||||
}
|
||||
|
|
@ -535,8 +517,7 @@ public class AssetManagerTest {
|
|||
public void copyAssetNull() {
|
||||
final Asset asset = null;
|
||||
|
||||
final Folder targetFolder = folderRepo.findById(-420L);
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
final Folder targetFolder = folderRepo.findById(-420L).get();
|
||||
|
||||
assetManager.copy(asset, targetFolder);
|
||||
}
|
||||
|
|
@ -555,8 +536,7 @@ public class AssetManagerTest {
|
|||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void copyAssetTargetFolderIsNull() {
|
||||
final Asset asset = assetRepo.findById(-1100L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-1100L).get();
|
||||
|
||||
final Folder targetFolder = null;
|
||||
|
||||
|
|
@ -577,11 +557,9 @@ public class AssetManagerTest {
|
|||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void copyAssetTargetFolderIsNotAssetFolder() {
|
||||
final Asset asset = assetRepo.findById(-1100L);
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-1100L).get();
|
||||
|
||||
final Folder targetFolder = folderRepo.findById(-200L);
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
final Folder targetFolder = folderRepo.findById(-200L).get();
|
||||
|
||||
assetManager.copy(asset, targetFolder);
|
||||
}
|
||||
|
|
@ -598,17 +576,11 @@ public class AssetManagerTest {
|
|||
@ShouldMatchDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
public void verifyIsAssetInUse() {
|
||||
final Asset header = assetRepo.findById(-700L);
|
||||
final Asset phb = assetRepo.findById(-800L);
|
||||
final Asset servicesHeader = assetRepo.findById(-900L);
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L);
|
||||
final Asset catalog = assetRepo.findById(-1100L);
|
||||
|
||||
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())));
|
||||
final Asset header = assetRepo.findById(-700L).get();
|
||||
final Asset phb = assetRepo.findById(-800L).get();
|
||||
final Asset servicesHeader = assetRepo.findById(-900L).get();
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
|
||||
final Asset catalog = assetRepo.findById(-1100L).get();
|
||||
|
||||
assertThat(assetManager.isAssetInUse(header), is(true));
|
||||
assertThat(assetManager.isAssetInUse(phb), is(false));
|
||||
|
|
@ -629,17 +601,11 @@ public class AssetManagerTest {
|
|||
@ShouldMatchDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
public void verifyGetAssetPathWithoutContentSection() {
|
||||
final Asset header = assetRepo.findById(-700L);
|
||||
final Asset phb = assetRepo.findById(-800L);
|
||||
final Asset servicesHeader = assetRepo.findById(-900L);
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L);
|
||||
final Asset catalog = assetRepo.findById(-1100L);
|
||||
|
||||
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())));
|
||||
final Asset header = assetRepo.findById(-700L).get();
|
||||
final Asset phb = assetRepo.findById(-800L).get();
|
||||
final Asset servicesHeader = assetRepo.findById(-900L).get();
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
|
||||
final Asset catalog = assetRepo.findById(-1100L).get();
|
||||
|
||||
assertThat(assetManager.getAssetPath(header),
|
||||
is(equalTo("/media/images/header.png")));
|
||||
|
|
@ -665,17 +631,11 @@ public class AssetManagerTest {
|
|||
@ShouldMatchDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
public void verifyGetAssetPathWithContentSection() {
|
||||
final Asset header = assetRepo.findById(-700L);
|
||||
final Asset phb = assetRepo.findById(-800L);
|
||||
final Asset servicesHeader = assetRepo.findById(-900L);
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L);
|
||||
final Asset catalog = assetRepo.findById(-1100L);
|
||||
|
||||
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())));
|
||||
final Asset header = assetRepo.findById(-700L).get();
|
||||
final Asset phb = assetRepo.findById(-800L).get();
|
||||
final Asset servicesHeader = assetRepo.findById(-900L).get();
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
|
||||
final Asset catalog = assetRepo.findById(-1100L).get();
|
||||
|
||||
assertThat(assetManager.getAssetPath(header, true),
|
||||
is(equalTo("info:/media/images/header.png")));
|
||||
|
|
@ -701,25 +661,15 @@ public class AssetManagerTest {
|
|||
@ShouldMatchDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
public void verifyGetAssetFolder() {
|
||||
final Asset header = assetRepo.findById(-700L);
|
||||
final Asset phb = assetRepo.findById(-800L);
|
||||
final Asset servicesHeader = assetRepo.findById(-900L);
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L);
|
||||
final Asset catalog = assetRepo.findById(-1100L);
|
||||
final Asset header = assetRepo.findById(-700L).get();
|
||||
final Asset phb = assetRepo.findById(-800L).get();
|
||||
final Asset servicesHeader = assetRepo.findById(-900L).get();
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
|
||||
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())));
|
||||
|
||||
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 Folder media = folderRepo.findById(-400L).get();
|
||||
final Folder images = folderRepo.findById(-410L).get();
|
||||
final Folder downloads = folderRepo.findById(-420L).get();
|
||||
|
||||
final Optional<Folder> headerFolder = assetManager
|
||||
.getAssetFolder(header);
|
||||
|
|
@ -756,27 +706,16 @@ public class AssetManagerTest {
|
|||
@ShouldMatchDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
public void verifyGetAssetFolders() {
|
||||
final Asset header = assetRepo.findById(-700L);
|
||||
final Asset phb = assetRepo.findById(-800L);
|
||||
final Asset servicesHeader = assetRepo.findById(-900L);
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L);
|
||||
final Asset catalog = assetRepo.findById(-1100L);
|
||||
final Asset header = assetRepo.findById(-700L).get();
|
||||
final Asset phb = assetRepo.findById(-800L).get();
|
||||
final Asset servicesHeader = assetRepo.findById(-900L).get();
|
||||
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
|
||||
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())));
|
||||
|
||||
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 Folder infoAssets = folderRepo.findById(-300L).get();
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
final Folder images = folderRepo.findById(-410L).get();
|
||||
final Folder downloads = folderRepo.findById(-420L).get();
|
||||
|
||||
final List<Folder> headerFolders = assetManager.getAssetFolders(header);
|
||||
final List<Folder> phbFolders = assetManager.getAssetFolders(phb);
|
||||
|
|
|
|||
|
|
@ -199,9 +199,7 @@ public class AssetRepositoryTest {
|
|||
excludeColumns = {"timestamp", "object_order"}
|
||||
)
|
||||
public void deleteUnusedAsset() {
|
||||
final Asset asset = assetRepo.findById(-800L);
|
||||
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-800L).get();
|
||||
|
||||
assetRepo.delete(asset);
|
||||
}
|
||||
|
|
@ -220,9 +218,7 @@ public class AssetRepositoryTest {
|
|||
+ "data.xml")
|
||||
@ShouldThrowException(AssetInUseException.class)
|
||||
public void deleteUsedAsset() {
|
||||
final Asset asset = assetRepo.findById(-700L);
|
||||
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
final Asset asset = assetRepo.findById(-700L).get();
|
||||
|
||||
assetRepo.delete(asset);
|
||||
}
|
||||
|
|
@ -324,8 +320,8 @@ public class AssetRepositoryTest {
|
|||
@UsingDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void findAssetsByFolder() {
|
||||
final Folder media = folderRepo.findById(-400L);
|
||||
final Folder data = folderRepo.findById(-500L);
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
final Folder data = folderRepo.findById(-500L).get();
|
||||
|
||||
final List<Asset> mediaAssets = assetRepo.findByFolder(media);
|
||||
final List<Asset> dataAssets = assetRepo.findByFolder(data);
|
||||
|
|
@ -344,8 +340,8 @@ public class AssetRepositoryTest {
|
|||
@UsingDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void countAssetsInFolder() {
|
||||
final Folder media = folderRepo.findById(-400L);
|
||||
final Folder data = folderRepo.findById(-500L);
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
final Folder data = folderRepo.findById(-500L).get();
|
||||
|
||||
assertThat(assetRepo.countAssetsInFolder(media), is(5L));
|
||||
assertThat(assetRepo.countAssetsInFolder(data), is(0L));
|
||||
|
|
@ -360,7 +356,7 @@ public class AssetRepositoryTest {
|
|||
@UsingDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void filterAssetByFolderAndName() {
|
||||
final Folder media = folderRepo.findById(-400L);
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
|
||||
final List<Asset> result1 = assetRepo.filterByFolderAndName(media,
|
||||
"hea");
|
||||
|
|
@ -383,7 +379,7 @@ public class AssetRepositoryTest {
|
|||
@UsingDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void countFilterAssetByFolderAndName() {
|
||||
final Folder media = folderRepo.findById(-400L);
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
|
||||
assertThat(assetRepo.countFilterByFolderAndName(media, "hea"),
|
||||
is(1L));
|
||||
|
|
@ -401,7 +397,7 @@ public class AssetRepositoryTest {
|
|||
@UsingDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void filterAssetsByFolderAndType() {
|
||||
final Folder media = folderRepo.findById(-400L);
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
|
||||
final List<Asset> images = assetRepo.filterByFolderAndType(media,
|
||||
Image.class);
|
||||
|
|
@ -434,7 +430,7 @@ public class AssetRepositoryTest {
|
|||
@UsingDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void countFilterAssetsByFolderAndType() {
|
||||
final Folder media = folderRepo.findById(-400L);
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
|
||||
assertThat(assetRepo.countFilterByFolderAndType(media, Image.class),
|
||||
is(3L));
|
||||
|
|
@ -454,7 +450,7 @@ public class AssetRepositoryTest {
|
|||
@UsingDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void filterAssetsByFolderAndTypeAndName() {
|
||||
final Folder media = folderRepo.findById(-400L);
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
|
||||
final List<Asset> result1 = assetRepo.filterByFolderAndTypeAndName(
|
||||
media, Image.class, "hea");
|
||||
|
|
@ -476,7 +472,7 @@ public class AssetRepositoryTest {
|
|||
@UsingDataSet(
|
||||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void countFilterAssetsByFolderAndTypeAndName() {
|
||||
final Folder media = folderRepo.findById(-400L);
|
||||
final Folder media = folderRepo.findById(-400L).get();
|
||||
|
||||
assertThat(assetRepo.countFilterByFolderAndTypeAndName(
|
||||
media, Image.class, "hea"),
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ public class ContentItemManagerTest {
|
|||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-110L);
|
||||
.findById(-110L).get();
|
||||
|
||||
final Article article = itemManager.createContentItem(
|
||||
"new-article",
|
||||
|
|
@ -417,7 +417,7 @@ public class ContentItemManagerTest {
|
|||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-110L);
|
||||
.findById(-110L).get();
|
||||
|
||||
itemManager.createContentItem("Test",
|
||||
section,
|
||||
|
|
@ -446,7 +446,7 @@ public class ContentItemManagerTest {
|
|||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-110L);
|
||||
.findById(-110L).get();
|
||||
|
||||
itemManager.createContentItem(null,
|
||||
section,
|
||||
|
|
@ -500,7 +500,7 @@ public class ContentItemManagerTest {
|
|||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-110L);
|
||||
.findById(-110L).get();
|
||||
|
||||
itemManager.createContentItem("Test",
|
||||
section,
|
||||
|
|
@ -534,7 +534,7 @@ public class ContentItemManagerTest {
|
|||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final Folder targetFolder = folderRepo.findById(-2120L);
|
||||
final Folder targetFolder = folderRepo.findById(-2120L).get();
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
|
||||
itemManager.move(item.get(), targetFolder);
|
||||
|
|
@ -562,7 +562,7 @@ public class ContentItemManagerTest {
|
|||
})
|
||||
public void moveItemToOtherContentSection() {
|
||||
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(targetFolder, is(not(nullValue())));
|
||||
|
|
@ -585,7 +585,7 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveToOtherContentSectionTypeNotPresent() {
|
||||
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(targetFolder, is(not(nullValue())));
|
||||
|
|
@ -607,7 +607,7 @@ public class ContentItemManagerTest {
|
|||
+ "ContentItemManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveItemNull() {
|
||||
final Folder targetFolder = folderRepo.findById(-2120L);
|
||||
final Folder targetFolder = folderRepo.findById(-2120L).get();
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
|
||||
itemManager.move(null, targetFolder);
|
||||
|
|
@ -665,7 +665,7 @@ public class ContentItemManagerTest {
|
|||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final Folder targetFolder = folderRepo.findById(-2120L);
|
||||
final Folder targetFolder = folderRepo.findById(-2120L).get();
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
|
||||
itemManager.copy(item.get(), targetFolder);
|
||||
|
|
@ -701,7 +701,7 @@ public class ContentItemManagerTest {
|
|||
})
|
||||
public void copyToFolderInOtherSection() {
|
||||
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(targetFolder, is(not(nullValue())));
|
||||
|
|
@ -728,7 +728,7 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void copyToFolderInOtherSectionTypeNotPresent() {
|
||||
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(targetFolder, is(not(nullValue())));
|
||||
|
|
@ -770,7 +770,7 @@ public class ContentItemManagerTest {
|
|||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final Folder targetFolder = folderRepo.findById(-2110L);
|
||||
final Folder targetFolder = folderRepo.findById(-2110L).get();
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
|
||||
itemManager.copy(item.get(), targetFolder);
|
||||
|
|
@ -791,7 +791,7 @@ public class ContentItemManagerTest {
|
|||
+ "ContentItemManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void copyItemNull() {
|
||||
final Folder targetFolder = folderRepo.findById(-2120L);
|
||||
final Folder targetFolder = folderRepo.findById(-2120L).get();
|
||||
assertThat(targetFolder, is(not(nullValue())));
|
||||
|
||||
itemManager.copy(null, targetFolder);
|
||||
|
|
@ -892,7 +892,7 @@ public class ContentItemManagerTest {
|
|||
public void publishItemWithLifecycle() {
|
||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||
final LifecycleDefinition lifecycleDef = lifecycleDefinitionRepo
|
||||
.findById(-200L);
|
||||
.findById(-200L).get();
|
||||
assertThat(item.isPresent(), is(true));
|
||||
assertThat(lifecycleDef, is(not(nullValue())));
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,11 @@ import java.util.stream.Collectors;
|
|||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||
import org.libreccm.security.User;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -68,9 +72,9 @@ import static org.junit.Assert.*;
|
|||
public class ContentItemPermissionTest {
|
||||
|
||||
private static final String QUERY = "SELECT i FROM ContentItem i "
|
||||
+ "JOIN i.permissions p "
|
||||
+ "WHERE p.grantee IN :roles "
|
||||
+ "AND p.grantedPrivilege = 'view_draft_items' "
|
||||
+ "JOIN i.permissions p "
|
||||
+ "WHERE p.grantee IN :roles "
|
||||
+ "AND p.grantedPrivilege = 'view_draft_items' "
|
||||
+ "ORDER BY i.displayName";
|
||||
|
||||
@Inject
|
||||
|
|
@ -101,63 +105,63 @@ public class ContentItemPermissionTest {
|
|||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.librecms.contentsection.ContentItemPermissionTest.war").
|
||||
addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
|
||||
.addPackage(org.libreccm.categorization.Categorization.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
||||
.addPackage(org.libreccm.configuration.Configuration.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.core.CcmCore.class.getPackage())
|
||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||
.addPackage(com.arsdigita.bebop.Component.class.getPackage())
|
||||
.addPackage(com.arsdigita.bebop.util.BebopConstants.class
|
||||
.getPackage())
|
||||
.addClass(com.arsdigita.kernel.KernelConfig.class)
|
||||
.addClass(com.arsdigita.runtime.CCMResourceManager.class)
|
||||
.addClass(com.arsdigita.dispatcher.RequestContext.class)
|
||||
.addClass(com.arsdigita.dispatcher.AccessDeniedException.class)
|
||||
.addClass(
|
||||
com.arsdigita.cms.dispatcher.ContentItemDispatcher.class).
|
||||
addClass(com.arsdigita.dispatcher.Dispatcher.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class).
|
||||
addClass(
|
||||
com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class).
|
||||
addClass(
|
||||
com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class).
|
||||
addClass(
|
||||
com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class)
|
||||
.addClass(org.librecms.dispatcher.ItemResolver.class)
|
||||
.addClass(org.libreccm.portation.Portable.class)
|
||||
.addPackage(com.arsdigita.util.Lockable.class.getPackage())
|
||||
.addPackage(com.arsdigita.web.BaseServlet.class.getPackage())
|
||||
.addPackage(org.librecms.Cms.class.getPackage())
|
||||
.addPackage(org.librecms.contentsection.Asset.class.getPackage()).
|
||||
addPackage(org.librecms.contentsection.AttachmentList.class
|
||||
.getPackage())
|
||||
.addPackage(org.librecms.lifecycle.Lifecycle.class.getPackage())
|
||||
.addPackage(org.librecms.contentsection.ContentSection.class
|
||||
.getPackage())
|
||||
.addPackage(org.librecms.contenttypes.Article.class.getPackage()).
|
||||
addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||
.getPackage())
|
||||
// .addAsLibraries(getModuleDependencies())
|
||||
.addAsLibraries(getCcmCoreDependencies())
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.librecms.contentsection.ContentItemPermissionTest.war")
|
||||
.addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
|
||||
.addPackage(org.libreccm.categorization.Categorization.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
||||
.addPackage(org.libreccm.configuration.Configuration.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.core.CcmCore.class.getPackage())
|
||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString.class
|
||||
.getPackage())
|
||||
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||
.addPackage(com.arsdigita.bebop.Component.class.getPackage())
|
||||
.addPackage(com.arsdigita.bebop.util.BebopConstants.class
|
||||
.getPackage())
|
||||
.addClass(com.arsdigita.kernel.KernelConfig.class)
|
||||
.addClass(com.arsdigita.runtime.CCMResourceManager.class)
|
||||
.addClass(com.arsdigita.dispatcher.RequestContext.class)
|
||||
.addClass(com.arsdigita.dispatcher.AccessDeniedException.class)
|
||||
.addClass(
|
||||
com.arsdigita.cms.dispatcher.ContentItemDispatcher.class).
|
||||
addClass(com.arsdigita.dispatcher.Dispatcher.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class)
|
||||
.addClass(
|
||||
com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class)
|
||||
.addClass(org.librecms.dispatcher.ItemResolver.class)
|
||||
.addClass(org.libreccm.portation.Portable.class)
|
||||
.addPackage(com.arsdigita.util.Lockable.class.getPackage())
|
||||
.addPackage(com.arsdigita.web.BaseServlet.class.getPackage())
|
||||
.addPackage(org.librecms.Cms.class.getPackage())
|
||||
.addPackage(org.librecms.contentsection.Asset.class.getPackage()).
|
||||
addPackage(org.librecms.contentsection.AttachmentList.class
|
||||
.getPackage())
|
||||
.addPackage(org.librecms.lifecycle.Lifecycle.class.getPackage())
|
||||
.addPackage(org.librecms.contentsection.ContentSection.class
|
||||
.getPackage())
|
||||
.addPackage(org.librecms.contenttypes.Article.class.getPackage()).
|
||||
addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||
.getPackage())
|
||||
// .addAsLibraries(getModuleDependencies())
|
||||
.addAsLibraries(getCcmCoreDependencies())
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -180,19 +184,20 @@ public class ContentItemPermissionTest {
|
|||
@Test
|
||||
@InSequence(100)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemPermissionTest/data.xml")
|
||||
+ "ContentItemPermissionTest/data.xml")
|
||||
public void accessByNoUser() {
|
||||
final List<Role> roles;
|
||||
if (shiro.getUser() == null) {
|
||||
roles = new ArrayList<>();
|
||||
final Optional<User> user = shiro.getUser();
|
||||
if (user.isPresent()) {
|
||||
roles = user.get().getRoleMemberships().stream()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
roles = shiro.getUser().getRoleMemberships().stream()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
roles = new ArrayList<>();
|
||||
}
|
||||
|
||||
final TypedQuery<ContentItem> query = entityManager.createQuery(
|
||||
QUERY, ContentItem.class);
|
||||
QUERY, ContentItem.class);
|
||||
query.setParameter("roles", roles);
|
||||
final List<ContentItem> result = query.getResultList();
|
||||
|
||||
|
|
@ -202,19 +207,20 @@ public class ContentItemPermissionTest {
|
|||
@Test
|
||||
@InSequence(200)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemPermissionTest/data.xml")
|
||||
+ "ContentItemPermissionTest/data.xml")
|
||||
public void accessByUser1() {
|
||||
final UsernamePasswordToken token = new UsernamePasswordToken(
|
||||
"user1@example.org", "foo123");
|
||||
"user1@example.org", "foo123");
|
||||
token.setRememberMe(true);
|
||||
subject.login(token);
|
||||
|
||||
final List<Role> roles = shiro.getUser().getRoleMemberships().stream()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
final List<Role> roles = shiro.getUser().get().getRoleMemberships()
|
||||
.stream()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final TypedQuery<ContentItem> query = entityManager.createQuery(
|
||||
QUERY, ContentItem.class);
|
||||
QUERY, ContentItem.class);
|
||||
query.setParameter("roles", roles);
|
||||
final List<ContentItem> result = query.getResultList();
|
||||
|
||||
|
|
@ -226,19 +232,20 @@ public class ContentItemPermissionTest {
|
|||
@Test
|
||||
@InSequence(300)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemPermissionTest/data.xml")
|
||||
+ "ContentItemPermissionTest/data.xml")
|
||||
public void accessByUser2() {
|
||||
final UsernamePasswordToken token = new UsernamePasswordToken(
|
||||
"user2@example.org", "foo123");
|
||||
"user2@example.org", "foo123");
|
||||
token.setRememberMe(true);
|
||||
subject.login(token);
|
||||
|
||||
final List<Role> roles = shiro.getUser().getRoleMemberships().stream()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
final List<Role> roles = shiro.getUser().get().getRoleMemberships()
|
||||
.stream()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final TypedQuery<ContentItem> query = entityManager.createQuery(
|
||||
QUERY, ContentItem.class);
|
||||
QUERY, ContentItem.class);
|
||||
query.setParameter("roles", roles);
|
||||
final List<ContentItem> result = query.getResultList();
|
||||
|
||||
|
|
@ -249,19 +256,20 @@ public class ContentItemPermissionTest {
|
|||
@Test
|
||||
@InSequence(400)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemPermissionTest/data.xml")
|
||||
+ "ContentItemPermissionTest/data.xml")
|
||||
public void accessByUser3() {
|
||||
final UsernamePasswordToken token = new UsernamePasswordToken(
|
||||
"user3@example.org", "foo123");
|
||||
"user3@example.org", "foo123");
|
||||
token.setRememberMe(true);
|
||||
subject.login(token);
|
||||
|
||||
final List<Role> roles = shiro.getUser().getRoleMemberships().stream()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
final List<Role> roles = shiro.getUser().get().getRoleMemberships()
|
||||
.stream()
|
||||
.map(membership -> membership.getRole())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final TypedQuery<ContentItem> query = entityManager.createQuery(
|
||||
QUERY, ContentItem.class);
|
||||
QUERY, ContentItem.class);
|
||||
query.setParameter("roles", roles);
|
||||
final List<ContentItem> result = query.getResultList();
|
||||
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ public class ContentItemRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemRepositoryTest/data.xml")
|
||||
public void findByFolder() {
|
||||
final Category folder = categoryRepo.findById(-2100L);
|
||||
final Category folder = categoryRepo.findById(-2100L).get();
|
||||
|
||||
assertThat(folder.getObjects().size(), is(4));
|
||||
|
||||
|
|
@ -253,7 +253,7 @@ public class ContentItemRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemRepositoryTest/data.xml")
|
||||
public void countItemsInFolder() {
|
||||
final Category folder = categoryRepo.findById(-2100L);
|
||||
final Category folder = categoryRepo.findById(-2100L).get();
|
||||
|
||||
assertThat(itemRepo.countItemsInFolder(folder), is(4L));
|
||||
}
|
||||
|
|
@ -263,7 +263,7 @@ public class ContentItemRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemRepositoryTest/data.xml")
|
||||
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, "article2"), is(1L));
|
||||
|
|
@ -278,7 +278,7 @@ public class ContentItemRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemRepositoryTest/data.xml")
|
||||
public void filterByFolderAndName() {
|
||||
final Category folder = categoryRepo.findById(-2100L);
|
||||
final Category folder = categoryRepo.findById(-2100L).get();
|
||||
|
||||
final List<ContentItem> articles = itemRepo.filterByFolderAndName(
|
||||
folder, "article");
|
||||
|
|
@ -300,7 +300,7 @@ public class ContentItemRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemRepositoryTest/data.xml")
|
||||
public void countFilterByFolderAndName() {
|
||||
final Category folder = categoryRepo.findById(-2100L);
|
||||
final Category folder = categoryRepo.findById(-2100L).get();
|
||||
|
||||
assertThat(itemRepo.countFilterByFolderAndName(folder, "article"),
|
||||
is(3L));
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ public class ContentSectionManagerTest {
|
|||
@InSequence(350)
|
||||
public void removeRole() {
|
||||
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);
|
||||
}
|
||||
|
|
@ -412,7 +412,7 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(352)
|
||||
public void removeRoleSectionIsNull() {
|
||||
final Role role = roleRepository.findByName("info_publisher");
|
||||
final Role role = roleRepository.findByName("info_publisher").get();
|
||||
|
||||
manager.removeRoleFromContentSection(null, role);
|
||||
}
|
||||
|
|
@ -433,15 +433,11 @@ public class ContentSectionManagerTest {
|
|||
"creation_date"})
|
||||
@InSequence(400)
|
||||
public void addContentTypeToSection() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
|
||||
.findById(-13002L);
|
||||
.findById(-13002L).get();
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-14001L);
|
||||
|
||||
assertThat(section, is(not(nullValue())));
|
||||
assertThat(lifecycleDef, is(not(nullValue())));
|
||||
assertThat(workflowTemplate, is(not(nullValue())));
|
||||
.findById(-14001L).get();
|
||||
|
||||
manager.addContentTypeToSection(Event.class,
|
||||
section,
|
||||
|
|
@ -462,15 +458,11 @@ public class ContentSectionManagerTest {
|
|||
+ "ContentSectionManagerTest/data.xml")
|
||||
@InSequence(500)
|
||||
public void addAlreadyAddedContentTypeToSection() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
|
||||
.findById(-13002L);
|
||||
.findById(-13002L).get();
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-14002L);
|
||||
|
||||
assertThat(section, is(not(nullValue())));
|
||||
assertThat(lifecycleDef, is(not(nullValue())));
|
||||
assertThat(workflowTemplate, is(not(nullValue())));
|
||||
.findById(-14002L).get();
|
||||
|
||||
manager.addContentTypeToSection(News.class,
|
||||
section,
|
||||
|
|
@ -492,15 +484,11 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(600)
|
||||
public void addContentTypeToSectionTypeIsNull() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
|
||||
.findById(-13002L);
|
||||
.findById(-13002L).get();
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-14002L);
|
||||
|
||||
assertThat(section, is(not(nullValue())));
|
||||
assertThat(lifecycleDef, is(not(nullValue())));
|
||||
assertThat(workflowTemplate, is(not(nullValue())));
|
||||
.findById(-14002L).get();
|
||||
|
||||
manager.addContentTypeToSection(null,
|
||||
section,
|
||||
|
|
@ -524,12 +512,9 @@ public class ContentSectionManagerTest {
|
|||
@InSequence(700)
|
||||
public void addContentTypeToSectionSectionIsNull() {
|
||||
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
|
||||
.findById(-13002L);
|
||||
.findById(-13002L).get();
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-14002L);
|
||||
|
||||
assertThat(lifecycleDef, is(not(nullValue())));
|
||||
assertThat(workflowTemplate, is(not(nullValue())));
|
||||
.findById(-14002L).get();
|
||||
|
||||
manager.addContentTypeToSection(Event.class,
|
||||
null,
|
||||
|
|
@ -551,12 +536,9 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(800)
|
||||
public void addContentTypeToSectionLifecycleIsNull() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-14001L);
|
||||
|
||||
assertThat(section, is(not(nullValue())));
|
||||
assertThat(workflowTemplate, is(not(nullValue())));
|
||||
.findById(-14001L).get();
|
||||
|
||||
manager.addContentTypeToSection(Event.class,
|
||||
section,
|
||||
|
|
@ -578,12 +560,9 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(900)
|
||||
public void addContentTypeToSectionWorkflowIsNull() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
|
||||
.findById(-13002L);
|
||||
|
||||
assertThat(section, is(not(nullValue())));
|
||||
assertThat(lifecycleDef, is(not(nullValue())));
|
||||
.findById(-13002L).get();
|
||||
|
||||
manager.addContentTypeToSection(Event.class,
|
||||
section,
|
||||
|
|
@ -606,15 +585,11 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(1000)
|
||||
public void addContentTypeToSectionLifecycleNotInSection() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
|
||||
.findById(-13003L);
|
||||
.findById(-13003L).get();
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-14001L);
|
||||
|
||||
assertThat(section, is(not(nullValue())));
|
||||
assertThat(lifecycleDef, is(not(nullValue())));
|
||||
assertThat(workflowTemplate, is(not(nullValue())));
|
||||
.findById(-14001L).get();
|
||||
|
||||
manager.addContentTypeToSection(Event.class,
|
||||
section,
|
||||
|
|
@ -636,15 +611,11 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(1100)
|
||||
public void addContentTypeToSectionWorkflowNoInSection() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
|
||||
.findById(-13002L);
|
||||
.findById(-13002L).get();
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-14003L);
|
||||
|
||||
assertThat(section, is(not(nullValue())));
|
||||
assertThat(lifecycleDef, is(not(nullValue())));
|
||||
assertThat(workflowTemplate, is(not(nullValue())));
|
||||
.findById(-14003L).get();
|
||||
|
||||
manager.addContentTypeToSection(Event.class,
|
||||
section,
|
||||
|
|
@ -661,7 +632,7 @@ public class ContentSectionManagerTest {
|
|||
+ "ContentSectionManagerTest/data.xml")
|
||||
@InSequence(1200)
|
||||
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(News.class, section), is(true));
|
||||
|
|
@ -679,7 +650,7 @@ public class ContentSectionManagerTest {
|
|||
+ "ContentSectionManagerTest/after-remove-contenttype.xml")
|
||||
@InSequence(1300)
|
||||
public void removeContentTypeFromSection() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
|
||||
manager.removeContentTypeFromSection(News.class, section);
|
||||
}
|
||||
|
|
@ -698,7 +669,7 @@ public class ContentSectionManagerTest {
|
|||
+ "ContentSectionManagerTest/data.xml")
|
||||
@InSequence(1301)
|
||||
public void removeNotExistingContentTypeFromSection() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
|
||||
manager.removeContentTypeFromSection(Event.class, section);
|
||||
}
|
||||
|
|
@ -718,7 +689,7 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(1400)
|
||||
public void removeContentTypeFromSectionTypeInUse() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
|
||||
manager.removeContentTypeFromSection(Article.class, section);
|
||||
}
|
||||
|
|
@ -738,7 +709,7 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(1400)
|
||||
public void removeContentTypeFromSectionTypeIsNull() {
|
||||
final ContentSection section = repository.findById(-1100L);
|
||||
final ContentSection section = repository.findById(-1100L).get();
|
||||
|
||||
manager.removeContentTypeFromSection(null, section);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ public class ContentTypeRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentTypeRepositoryTest/data.xml")
|
||||
public void findByContentSection() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final List<ContentType> types = contentTypeRepo.findByContentSection(
|
||||
section);
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ public class ContentTypeRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentTypeRepositoryTest/data.xml")
|
||||
public void findByContentSectionAndClass() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final Optional<ContentType> articleType = contentTypeRepo
|
||||
.findByContentSectionAndClass(section, Article.class);
|
||||
final Optional<ContentType> newsType = contentTypeRepo
|
||||
|
|
@ -271,7 +271,7 @@ public class ContentTypeRepositoryTest {
|
|||
+ "ContentTypeRepositoryTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void findByContentSectionAndClassNull() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final Class<? extends ContentItem> type = null;
|
||||
contentTypeRepo.findByContentSectionAndClass(section, type);
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ public class ContentTypeRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentTypeRepositoryTest/data.xml")
|
||||
public void findByContentSectionAndClassName() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final Optional<ContentType> articleType = contentTypeRepo
|
||||
.findByContentSectionAndClass(section, Article.class.getName());
|
||||
final Optional<ContentType> newsType = contentTypeRepo
|
||||
|
|
@ -339,7 +339,7 @@ public class ContentTypeRepositoryTest {
|
|||
+ "ContentTypeRepositoryTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void findByContentSectionAndClassNameNull() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final String type = null;
|
||||
contentTypeRepo.findByContentSectionAndClass(section, type);
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ public class ContentTypeRepositoryTest {
|
|||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentTypeRepositoryTest/data.xml")
|
||||
public void verifyIsContentTypeInUse() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final Optional<ContentType> articleType = contentTypeRepo
|
||||
.findByContentSectionAndClass(section, Article.class);
|
||||
final Optional<ContentType> newsType = contentTypeRepo
|
||||
|
|
@ -378,7 +378,7 @@ public class ContentTypeRepositoryTest {
|
|||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentTypeRepositoryTest/after-delete.xml")
|
||||
public void deleteUnusedContentType() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final Optional<ContentType> newsType = contentTypeRepo
|
||||
.findByContentSectionAndClass(section, News.class);
|
||||
assertThat(newsType.isPresent(), is(true));
|
||||
|
|
@ -398,7 +398,7 @@ public class ContentTypeRepositoryTest {
|
|||
+ "ContentTypeRepositoryTest/data.xml")
|
||||
@ShouldThrowException(UnauthorizedException.class)
|
||||
public void deleteUnusedContentTypeUnauthorized() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final Optional<ContentType> newsType = contentTypeRepo
|
||||
.findByContentSectionAndClass(section, News.class);
|
||||
assertThat(newsType.isPresent(), is(true));
|
||||
|
|
@ -418,7 +418,7 @@ public class ContentTypeRepositoryTest {
|
|||
+ "ContentTypeRepositoryTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void deleteContentTypeInUse() {
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L);
|
||||
final ContentSection section = contentSectionRepo.findById(-1001L).get();
|
||||
final Optional<ContentType> articleType = contentTypeRepo
|
||||
.findByContentSectionAndClass(section, Article.class);
|
||||
assertThat(articleType.isPresent(), is(true));
|
||||
|
|
|
|||
|
|
@ -43,8 +43,11 @@ import org.junit.runner.RunWith;
|
|||
import org.libreccm.tests.categories.IntegrationTest;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
|
@ -165,10 +168,10 @@ public class FolderManagerTest {
|
|||
"content_section_id"})
|
||||
@InSequence(1000)
|
||||
public void createDocumentsFolder() {
|
||||
final Folder parent = folderRepo.findById(-2005L);
|
||||
assertThat(parent, is(not(nullValue())));
|
||||
final Optional<Folder> parent = folderRepo.findById(-2005L);
|
||||
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.getName(), is(equalTo("test")));
|
||||
|
|
@ -189,10 +192,10 @@ public class FolderManagerTest {
|
|||
"content_section_id"})
|
||||
@InSequence(1100)
|
||||
public void createAssetsFolder() {
|
||||
final Folder parent = folderRepo.findById(-2013L);
|
||||
assertThat(parent, is(not(nullValue())));
|
||||
final Optional<Folder> parent = folderRepo.findById(-2013L);
|
||||
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.getName(), is(equalTo("test")));
|
||||
|
|
@ -220,10 +223,10 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(1500)
|
||||
public void createFolderNullName() {
|
||||
final Folder parent = folderRepo.findById(-2005L);
|
||||
assertThat(parent, is(not(nullValue())));
|
||||
final Optional<Folder> parent = folderRepo.findById(-2005L);
|
||||
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)
|
||||
@InSequence(1500)
|
||||
public void createFolderEmptyName() {
|
||||
final Folder parent = folderRepo.findById(-2005L);
|
||||
assertThat(parent, is(not(nullValue())));
|
||||
final Optional<Folder> parent = folderRepo.findById(-2005L);
|
||||
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)
|
||||
public void deleteFolder() {
|
||||
//docs-1-1-1
|
||||
final Folder folder = folderRepo.findById(-2007L);
|
||||
final Folder folder = folderRepo.findById(-2007L).get();
|
||||
folderManager.deleteFolder(folder);
|
||||
}
|
||||
|
||||
|
|
@ -266,7 +269,7 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(2100)
|
||||
public void deleteNonEmptyFolder() {
|
||||
final Folder folder = folderRepo.findById(-2008L);
|
||||
final Folder folder = folderRepo.findById(-2008L).get();
|
||||
folderManager.deleteFolder(folder);
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +282,7 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(2100)
|
||||
public void deleteNonEmptySubFolder() {
|
||||
final Folder folder = folderRepo.findById(-2006L);
|
||||
final Folder folder = folderRepo.findById(-2006L).get();
|
||||
folderManager.deleteFolder(folder);
|
||||
}
|
||||
|
||||
|
|
@ -292,7 +295,7 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(2210)
|
||||
public void deleteRootFolder() {
|
||||
final Folder folder = folderRepo.findById(-2003L);
|
||||
final Folder folder = folderRepo.findById(-2003L).get();
|
||||
folderManager.deleteFolder(folder);
|
||||
}
|
||||
|
||||
|
|
@ -318,8 +321,8 @@ public class FolderManagerTest {
|
|||
@InSequence(3000)
|
||||
public void moveFolder() {
|
||||
//docs-1-1-2 to docs-2
|
||||
final Folder folder = folderRepo.findById(-2008L);
|
||||
final Folder target = folderRepo.findById(-2010L);
|
||||
final Folder folder = folderRepo.findById(-2008L).get();
|
||||
final Folder target = folderRepo.findById(-2010L).get();
|
||||
|
||||
folderManager.moveFolder(folder, target);
|
||||
}
|
||||
|
|
@ -335,8 +338,8 @@ public class FolderManagerTest {
|
|||
public void moveFolderTargetFolderSameName() {
|
||||
//docs-1/downloads to /docs-2/
|
||||
|
||||
final Folder folder = folderRepo.findById(-2009L);
|
||||
final Folder target = folderRepo.findById(-2010L);
|
||||
final Folder folder = folderRepo.findById(-2009L).get();
|
||||
final Folder target = folderRepo.findById(-2010L).get();
|
||||
|
||||
folderManager.moveFolder(folder, target);
|
||||
}
|
||||
|
|
@ -350,8 +353,8 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(3100)
|
||||
public void moveDocumentsFolderToAssetsFolder() {
|
||||
final Folder folder = folderRepo.findById(-2009L);
|
||||
final Folder target = folderRepo.findById(-2014L);
|
||||
final Folder folder = folderRepo.findById(-2009L).get();
|
||||
final Folder target = folderRepo.findById(-2014L).get();
|
||||
|
||||
folderManager.moveFolder(folder, target);
|
||||
}
|
||||
|
|
@ -365,8 +368,8 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(3110)
|
||||
public void moveAssetsFolderToDocumentsFolder() {
|
||||
final Folder folder = folderRepo.findById(-2014L);
|
||||
final Folder target = folderRepo.findById(-2010L);
|
||||
final Folder folder = folderRepo.findById(-2014L).get();
|
||||
final Folder target = folderRepo.findById(-2010L).get();
|
||||
|
||||
folderManager.moveFolder(folder, target);
|
||||
}
|
||||
|
|
@ -380,7 +383,7 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(3110)
|
||||
public void moveFolderToItself() {
|
||||
final Folder folder = folderRepo.findById(-2008L);
|
||||
final Folder folder = folderRepo.findById(-2008L).get();
|
||||
|
||||
folderManager.moveFolder(folder, folder);
|
||||
}
|
||||
|
|
@ -394,7 +397,7 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(3200)
|
||||
public void moveFolderNull() {
|
||||
final Folder target = folderRepo.findById(-2010L);
|
||||
final Folder target = folderRepo.findById(-2010L).get();
|
||||
folderManager.moveFolder(null, target);
|
||||
}
|
||||
|
||||
|
|
@ -407,7 +410,7 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(3210)
|
||||
public void moveFolderTargetNull() {
|
||||
final Folder folder = folderRepo.findById(-2008L);
|
||||
final Folder folder = folderRepo.findById(-2008L).get();
|
||||
|
||||
folderManager.moveFolder(folder, null);
|
||||
}
|
||||
|
|
@ -421,8 +424,8 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(3300)
|
||||
public void moveFolderWithLiveItems() {
|
||||
final Folder folder = folderRepo.findById(-2011L);
|
||||
final Folder target = folderRepo.findById(-2010L);
|
||||
final Folder folder = folderRepo.findById(-2011L).get();
|
||||
final Folder target = folderRepo.findById(-2010L).get();
|
||||
|
||||
folderManager.moveFolder(folder, target);
|
||||
}
|
||||
|
|
@ -436,8 +439,8 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(3310)
|
||||
public void moveFolderWithLiveItemsInSubFolder() {
|
||||
final Folder folder = folderRepo.findById(-2010L);
|
||||
final Folder target = folderRepo.findById(-2005L);
|
||||
final Folder folder = folderRepo.findById(-2010L).get();
|
||||
final Folder target = folderRepo.findById(-2005L).get();
|
||||
|
||||
folderManager.moveFolder(folder, target);
|
||||
}
|
||||
|
|
@ -451,8 +454,8 @@ public class FolderManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(3320)
|
||||
public void moveFolderToOtherSection() {
|
||||
final Folder folder = folderRepo.findById(-2008L);
|
||||
final Folder target = folderRepo.findById(-2003L);
|
||||
final Folder folder = folderRepo.findById(-2008L).get();
|
||||
final Folder target = folderRepo.findById(-2003L).get();
|
||||
|
||||
folderManager.moveFolder(folder, target);
|
||||
}
|
||||
|
|
@ -462,21 +465,21 @@ public class FolderManagerTest {
|
|||
+ "FolderManagerTest/data.xml")
|
||||
@InSequence(3400)
|
||||
public void getFolderPath() {
|
||||
final Folder infoRoot = folderRepo.findById(-2001L);
|
||||
final Folder infoAssets = folderRepo.findById(-2002L);
|
||||
final Folder projectsRoot = folderRepo.findById(-2003L);
|
||||
final Folder projectsAssets = folderRepo.findById(-2004L);
|
||||
final Folder docs1 = folderRepo.findById(-2005L);
|
||||
final Folder docs11 = folderRepo.findById(-2006L);
|
||||
final Folder docs111 = folderRepo.findById(-2007L);
|
||||
final Folder docs112 = folderRepo.findById(-2008L);
|
||||
final Folder downloads1 = folderRepo.findById(-2009L);
|
||||
final Folder docs2 = folderRepo.findById(-2010L);
|
||||
final Folder docs21 = folderRepo.findById(-2011L);
|
||||
final Folder downloads2 = folderRepo.findById(-2012L);
|
||||
final Folder assets1 = folderRepo.findById(-2013L);
|
||||
final Folder assets11 = folderRepo.findById(-2014L);
|
||||
final Folder assets12 = folderRepo.findById(-2015L);
|
||||
final Folder infoRoot = folderRepo.findById(-2001L).get();
|
||||
final Folder infoAssets = folderRepo.findById(-2002L).get();
|
||||
final Folder projectsRoot = folderRepo.findById(-2003L).get();
|
||||
final Folder projectsAssets = folderRepo.findById(-2004L).get();
|
||||
final Folder docs1 = folderRepo.findById(-2005L).get();
|
||||
final Folder docs11 = folderRepo.findById(-2006L).get();
|
||||
final Folder docs111 = folderRepo.findById(-2007L).get();
|
||||
final Folder docs112 = folderRepo.findById(-2008L).get();
|
||||
final Folder downloads1 = folderRepo.findById(-2009L).get();
|
||||
final Folder docs2 = folderRepo.findById(-2010L).get();
|
||||
final Folder docs21 = folderRepo.findById(-2011L).get();
|
||||
final Folder downloads2 = folderRepo.findById(-2012L).get();
|
||||
final Folder assets1 = folderRepo.findById(-2013L).get();
|
||||
final Folder assets11 = folderRepo.findById(-2014L).get();
|
||||
final Folder assets12 = folderRepo.findById(-2015L).get();
|
||||
|
||||
assertThat(folderManager.getFolderPath(infoRoot),
|
||||
is(equalTo("/info_root/")));
|
||||
|
|
@ -515,21 +518,21 @@ public class FolderManagerTest {
|
|||
+ "FolderManagerTest/data.xml")
|
||||
@InSequence(3410)
|
||||
public void getFolderPathWithContentSection() {
|
||||
final Folder infoRoot = folderRepo.findById(-2001L);
|
||||
final Folder infoAssets = folderRepo.findById(-2002L);
|
||||
final Folder projectsRoot = folderRepo.findById(-2003L);
|
||||
final Folder projectsAssets = folderRepo.findById(-2004L);
|
||||
final Folder docs1 = folderRepo.findById(-2005L);
|
||||
final Folder docs11 = folderRepo.findById(-2006L);
|
||||
final Folder docs111 = folderRepo.findById(-2007L);
|
||||
final Folder docs112 = folderRepo.findById(-2008L);
|
||||
final Folder downloads1 = folderRepo.findById(-2009L);
|
||||
final Folder docs2 = folderRepo.findById(-2010L);
|
||||
final Folder docs21 = folderRepo.findById(-2011L);
|
||||
final Folder downloads2 = folderRepo.findById(-2012L);
|
||||
final Folder assets1 = folderRepo.findById(-2013L);
|
||||
final Folder assets11 = folderRepo.findById(-2014L);
|
||||
final Folder assets12 = folderRepo.findById(-2015L);
|
||||
final Folder infoRoot = folderRepo.findById(-2001L).get();
|
||||
final Folder infoAssets = folderRepo.findById(-2002L).get();
|
||||
final Folder projectsRoot = folderRepo.findById(-2003L).get();
|
||||
final Folder projectsAssets = folderRepo.findById(-2004L).get();
|
||||
final Folder docs1 = folderRepo.findById(-2005L).get();
|
||||
final Folder docs11 = folderRepo.findById(-2006L).get();
|
||||
final Folder docs111 = folderRepo.findById(-2007L).get();
|
||||
final Folder docs112 = folderRepo.findById(-2008L).get();
|
||||
final Folder downloads1 = folderRepo.findById(-2009L).get();
|
||||
final Folder docs2 = folderRepo.findById(-2010L).get();
|
||||
final Folder docs21 = folderRepo.findById(-2011L).get();
|
||||
final Folder downloads2 = folderRepo.findById(-2012L).get();
|
||||
final Folder assets1 = folderRepo.findById(-2013L).get();
|
||||
final Folder assets11 = folderRepo.findById(-2014L).get();
|
||||
final Folder assets12 = folderRepo.findById(-2015L).get();
|
||||
|
||||
assertThat(folderManager.getFolderPath(infoRoot, true),
|
||||
is(equalTo("info:/info_root/")));
|
||||
|
|
|
|||
|
|
@ -207,11 +207,7 @@ public class ItemAttachmentManagerTest {
|
|||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
// final File file = new File();
|
||||
// file.setDisplayName("assets510-2a");
|
||||
// file.setFileName("asset-510-2a.pdf");
|
||||
// file.setMimeType(new MimeType("application/pdf"));
|
||||
final Asset file = assetRepo.findById(-720L);
|
||||
final Asset file = assetRepo.findById(-720L).get();
|
||||
|
||||
attachmentManager.attachAsset(file, item.get().getAttachments().get(1));
|
||||
}
|
||||
|
|
@ -236,7 +232,7 @@ public class ItemAttachmentManagerTest {
|
|||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final Asset shared = assetRepo.findById(-610L);
|
||||
final Asset shared = assetRepo.findById(-610L).get();
|
||||
|
||||
attachmentManager.attachAsset(shared,
|
||||
item.get().getAttachments().get(1));
|
||||
|
|
@ -258,7 +254,7 @@ public class ItemAttachmentManagerTest {
|
|||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
assertThat(item.isPresent(), is(true));
|
||||
|
||||
final Asset shared = assetRepo.findById(-620L);
|
||||
final Asset shared = assetRepo.findById(-620L).get();
|
||||
|
||||
attachmentManager.attachAsset(shared,
|
||||
item.get().getAttachments().get(1));
|
||||
|
|
@ -302,7 +298,7 @@ public class ItemAttachmentManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void attachAssetToListNull() {
|
||||
final AttachmentList list = null;
|
||||
final Asset shared = assetRepo.findById(-610L);
|
||||
final Asset shared = assetRepo.findById(-610L).get();
|
||||
|
||||
attachmentManager.attachAsset(shared, list);
|
||||
}
|
||||
|
|
@ -321,7 +317,7 @@ public class ItemAttachmentManagerTest {
|
|||
+ "after-unattach-shared.xml",
|
||||
excludeColumns = {"timestamp"})
|
||||
public void unattachSharedAsset() {
|
||||
final Asset asset = assetRepo.findById(-610L);
|
||||
final Asset asset = assetRepo.findById(-610L).get();
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
|
@ -348,7 +344,7 @@ public class ItemAttachmentManagerTest {
|
|||
+ "after-unattach-nonshared.xml",
|
||||
excludeColumns = {"timestamp"})
|
||||
public void unattachNonSharedAsset() {
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
final Asset asset = assetRepo.findById(-720L).get();
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
|
@ -372,7 +368,7 @@ public class ItemAttachmentManagerTest {
|
|||
@ShouldMatchDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
public void unattachAssetNotAttached() {
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
final Asset asset = assetRepo.findById(-720L).get();
|
||||
final Optional<ContentItem> item = itemRepo.findById(-510L);
|
||||
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
|
@ -421,7 +417,7 @@ public class ItemAttachmentManagerTest {
|
|||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void unattachAssetFromListNull() {
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
final Asset asset = assetRepo.findById(-720L).get();
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
||||
final AttachmentList list = null;
|
||||
|
|
@ -509,7 +505,7 @@ public class ItemAttachmentManagerTest {
|
|||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveUpInListNull() {
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
final Asset asset = assetRepo.findById(-720L).get();
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
||||
final AttachmentList list = null;
|
||||
|
|
@ -597,7 +593,7 @@ public class ItemAttachmentManagerTest {
|
|||
+ "ItemAttachmentManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void moveDownInListNull() {
|
||||
final Asset asset = assetRepo.findById(-720L);
|
||||
final Asset asset = assetRepo.findById(-720L).get();
|
||||
assertThat(asset, is(not(nullValue())));
|
||||
|
||||
final AttachmentList list = null;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ import java.util.stream.Collectors;
|
|||
@Configuration
|
||||
public final class KernelConfig {
|
||||
|
||||
private static final String EMAIL = "email";
|
||||
private static final String SCREEN_NAME = "screen_name";
|
||||
public static final String USER_IDENTIFIER_EMAIL = "email";
|
||||
public static final String USER_IDENTIFIER_SCREEN_NAME = "screen_name";
|
||||
|
||||
@Setting
|
||||
private boolean debugEnabled = false;
|
||||
|
|
@ -52,7 +52,7 @@ public final class KernelConfig {
|
|||
private boolean dataPermissionCheckEnabled = true;
|
||||
|
||||
@Setting
|
||||
private String primaryUserIdentifier = EMAIL;
|
||||
private String primaryUserIdentifier = USER_IDENTIFIER_EMAIL;
|
||||
|
||||
@Setting
|
||||
private boolean ssoEnabled = false;
|
||||
|
|
@ -113,8 +113,8 @@ public final class KernelConfig {
|
|||
}
|
||||
|
||||
public void setPrimaryUserIdentifier(final String primaryUserIdentifier) {
|
||||
if (SCREEN_NAME.equals(primaryUserIdentifier)
|
||||
|| EMAIL.equals(primaryUserIdentifier)) {
|
||||
if (USER_IDENTIFIER_SCREEN_NAME.equals(primaryUserIdentifier)
|
||||
|| USER_IDENTIFIER_EMAIL.equals(primaryUserIdentifier)) {
|
||||
this.primaryUserIdentifier = primaryUserIdentifier;
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
|
|
@ -124,11 +124,11 @@ public final class KernelConfig {
|
|||
}
|
||||
|
||||
public boolean emailIsPrimaryIdentifier() {
|
||||
return EMAIL.equals(primaryUserIdentifier);
|
||||
return USER_IDENTIFIER_EMAIL.equals(primaryUserIdentifier);
|
||||
}
|
||||
|
||||
public boolean screenNameIsPrimaryIdentifier() {
|
||||
return SCREEN_NAME.equals(primaryUserIdentifier);
|
||||
return USER_IDENTIFIER_SCREEN_NAME.equals(primaryUserIdentifier);
|
||||
}
|
||||
|
||||
public boolean isSsoEnabled() {
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ public class ACSObjectSelectionModel implements SingleSelectionModel {
|
|||
final CcmObjectRepository repository = cdiUtil.findBean(
|
||||
CcmObjectRepository.class);
|
||||
|
||||
return repository.findById(objectId);
|
||||
return repository.findById(objectId).get();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public abstract class SecurityContainer extends SimpleContainer {
|
|||
public boolean isVisible(final PageState state) {
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
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) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class CcmObjectSelectionModel<T extends CcmObject>
|
|||
final CcmObjectRepository repository = CdiUtil.createCdiUtil().findBean(
|
||||
CcmObjectRepository.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
final T object = (T) repository.findById(key);
|
||||
final T object = (T) repository.findById(key).get();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import org.libreccm.cdi.utils.CdiUtil;
|
|||
import org.libreccm.security.User;
|
||||
import org.libreccm.security.UserRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import static com.arsdigita.ui.UI.*;
|
||||
|
|
@ -61,7 +63,7 @@ public class UserBanner extends SimpleComponent {
|
|||
final UserRepository userRepository = cdiUtil.findBean(
|
||||
UserRepository.class);
|
||||
|
||||
final User user;
|
||||
final Optional<User> user;
|
||||
if ("email".equals(config.getPrimaryUserIdentifier())) {
|
||||
user = userRepository.findByEmailAddress(
|
||||
(String) subject.getPrincipal());
|
||||
|
|
@ -70,15 +72,18 @@ public class UserBanner extends SimpleComponent {
|
|||
.findByName((String) subject.getPrincipal());
|
||||
}
|
||||
|
||||
if (user != null) {
|
||||
contentElem.addAttribute("givenName", user.getGivenName());
|
||||
contentElem.addAttribute("familyName", user.getFamilyName());
|
||||
contentElem.addAttribute("screenName", user.getName());
|
||||
if (user.isPresent()) {
|
||||
contentElem.addAttribute("givenName",
|
||||
user.get().getGivenName());
|
||||
contentElem.addAttribute("familyName",
|
||||
user.get().getFamilyName());
|
||||
contentElem.addAttribute("screenName",
|
||||
user.get().getName());
|
||||
contentElem.addAttribute("primaryEmail",
|
||||
user.getPrimaryEmailAddress()
|
||||
user.get().getPrimaryEmailAddress()
|
||||
.getAddress());
|
||||
contentElem.addAttribute("userID",
|
||||
Long.toString(user.getPartyId()));
|
||||
Long.toString(user.get().getPartyId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
package com.arsdigita.ui.admin.applications;
|
||||
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
|
|
@ -77,9 +76,8 @@ public abstract class AbstractAppInstanceForm extends Form {
|
|||
final ApplicationRepository appRepo = CdiUtil.createCdiUtil()
|
||||
.findBean(ApplicationRepository.class);
|
||||
|
||||
final CcmApplication result = appRepo.findById(Long.parseLong(
|
||||
return appRepo.findById(Long.parseLong(
|
||||
selectedAppInstance.getSelectedKey(state)));
|
||||
return Optional.of(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,9 +70,8 @@ public abstract class AbstractAppSettingsPane extends SimpleContainer {
|
|||
final ApplicationRepository appRepo = CdiUtil.createCdiUtil()
|
||||
.findBean(ApplicationRepository.class);
|
||||
|
||||
final CcmApplication result = appRepo.findById(Long.parseLong(
|
||||
return appRepo.findById(Long.parseLong(
|
||||
selectedAppInstance.getSelectedKey(state)));
|
||||
return Optional.of(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import java.lang.reflect.Constructor;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
|
|
@ -98,11 +99,11 @@ public class ApplicationsTab extends LayoutPanel {
|
|||
|
||||
final ApplicationRepository appRepo = CdiUtil.createCdiUtil()
|
||||
.findBean(ApplicationRepository.class);
|
||||
final CcmApplication application = appRepo.findById(
|
||||
final Optional<CcmApplication> application = appRepo.findById(
|
||||
Long.parseLong(instanceId));
|
||||
if (application != null) {
|
||||
if (application.isPresent()) {
|
||||
selectedAppType.setSelectedKey(
|
||||
state, application.getApplicationType());
|
||||
state, application.get().getApplicationType());
|
||||
}
|
||||
|
||||
showAppSettings(state);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class CategoriesTreeModel implements TreeModel {
|
|||
final CategoryRepository categoryRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(domain.getRoot()
|
||||
.getObjectId());
|
||||
.getObjectId()).get();
|
||||
return new CategoryTreeNode(category);
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ public class CategoriesTreeModel implements TreeModel {
|
|||
final CategoryRepository categoryRepo = CdiUtil.createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepo.findById(
|
||||
((CategoryTreeNode) node).getCategory().getObjectId());
|
||||
((CategoryTreeNode) node).getCategory().getObjectId()).get();
|
||||
|
||||
return (category.getSubCategories() != null
|
||||
&& !category.getSubCategories().isEmpty());
|
||||
|
|
@ -69,7 +69,7 @@ public class CategoriesTreeModel implements TreeModel {
|
|||
final CategoryRepository categoryRepo = CdiUtil.createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepo.findById(
|
||||
((CategoryTreeNode) node).getCategory().getObjectId());
|
||||
((CategoryTreeNode) node).getCategory().getObjectId()).get();
|
||||
|
||||
return new SubCategoryNodesIterator(category.getSubCategories());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class CategoriesTreeModelBuilder
|
|||
final DomainRepository domainRepository = CdiUtil.createCdiUtil().
|
||||
findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
return new CategoriesTreeModel(domain);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class CategoryCreateForm extends Form {
|
|||
final CategoryRepository categoryRepository = CdiUtil
|
||||
.createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(Long
|
||||
.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
.parseLong(selectedCategoryId.getSelectedKey(state))).get();
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.create_new_subcategory",
|
||||
ADMIN_BUNDLE,
|
||||
|
|
@ -108,7 +108,8 @@ public class CategoryCreateForm extends Form {
|
|||
CategoryManager.class);
|
||||
|
||||
final Category selectedCategory = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)))
|
||||
.get();
|
||||
|
||||
final FormData data = e.getFormData();
|
||||
final String categoryNameData = data.getString(CATEGORY_NAME);
|
||||
|
|
|
|||
|
|
@ -52,17 +52,17 @@ public class CategoryDescriptionForm extends Form {
|
|||
private final SaveCancelSection saveCancelSection;
|
||||
|
||||
public CategoryDescriptionForm(
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedCategoryId,
|
||||
final ParameterSingleSelectionModel<String> selectedLanguage) {
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedCategoryId,
|
||||
final ParameterSingleSelectionModel<String> selectedLanguage) {
|
||||
|
||||
super("categoryDescriptionForm", new BoxPanel(BoxPanel.VERTICAL));
|
||||
|
||||
this.categoriesTab = categoriesTab;
|
||||
|
||||
final ActionLink backLink = new ActionLink(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.description.edit.back",
|
||||
ADMIN_BUNDLE));
|
||||
"ui.admin.categories.category.description.edit.back",
|
||||
ADMIN_BUNDLE));
|
||||
backLink.addActionListener(e -> {
|
||||
categoriesTab.hideDomainTitleForm(e.getPageState());
|
||||
});
|
||||
|
|
@ -72,28 +72,28 @@ public class CategoryDescriptionForm extends Form {
|
|||
final PageState state = e.getPageState();
|
||||
|
||||
final CategoryRepository categoryRepository = CdiUtil.
|
||||
createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category selectedCategory = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
.getSelectedKey(state));
|
||||
|
||||
final Label target = (Label) e.getTarget();
|
||||
|
||||
if (selectedCategory.getDescription().hasValue(selectedLocale)) {
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.description.edit_for_lang",
|
||||
ADMIN_BUNDLE,
|
||||
new String[]{selectedCategory.getName(),
|
||||
selectedLocale.toString()}));
|
||||
"ui.admin.categories.category.description.edit_for_lang",
|
||||
ADMIN_BUNDLE,
|
||||
new String[]{selectedCategory.getName(),
|
||||
selectedLocale.toString()}));
|
||||
} else {
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.description.add_for_lang",
|
||||
ADMIN_BUNDLE,
|
||||
new String[]{selectedCategory.getName(),
|
||||
selectedLocale.toString()}));
|
||||
"ui.admin.categories.category.description.add_for_lang",
|
||||
ADMIN_BUNDLE,
|
||||
new String[]{selectedCategory.getName(),
|
||||
selectedLocale.toString()}));
|
||||
}
|
||||
});
|
||||
heading.setClassAttr("heading");
|
||||
|
|
@ -101,7 +101,7 @@ public class CategoryDescriptionForm extends Form {
|
|||
|
||||
description = new TextArea(LOCALIZED_CATEGORY_DESC);
|
||||
description.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.description.label", ADMIN_BUNDLE));
|
||||
"ui.admin.categories.category.description.label", ADMIN_BUNDLE));
|
||||
description.setCols(60);
|
||||
description.setRows(10);
|
||||
add(description);
|
||||
|
|
@ -113,12 +113,12 @@ public class CategoryDescriptionForm extends Form {
|
|||
final PageState state = e.getPageState();
|
||||
|
||||
final CategoryRepository categoryRepository = CdiUtil.
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category selectedCategory = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
.getSelectedKey(state));
|
||||
|
||||
if (selectedCategory.getDescription().hasValue(selectedLocale)) {
|
||||
description.setValue(state, selectedCategory.getDescription()
|
||||
|
|
@ -129,17 +129,17 @@ public class CategoryDescriptionForm extends Form {
|
|||
addValidationListener(e -> {
|
||||
|
||||
if (saveCancelSection.getSaveButton().isSelected(
|
||||
e.getPageState())) {
|
||||
e.getPageState())) {
|
||||
final FormData data = e.getFormData();
|
||||
|
||||
final String titleData = data.getString(LOCALIZED_CATEGORY_DESC);
|
||||
|
||||
if (Strings.isBlank(titleData)) {
|
||||
data.addError(
|
||||
LOCALIZED_CATEGORY_DESC,
|
||||
new GlobalizedMessage(
|
||||
"ui.admin.categories.category.description.error.not_blank",
|
||||
ADMIN_BUNDLE));
|
||||
LOCALIZED_CATEGORY_DESC,
|
||||
new GlobalizedMessage(
|
||||
"ui.admin.categories.category.description.error.not_blank",
|
||||
ADMIN_BUNDLE));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -149,16 +149,17 @@ public class CategoryDescriptionForm extends Form {
|
|||
|
||||
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
||||
final CategoryRepository categoryRepository = CdiUtil
|
||||
.createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
.createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category selectedCategory = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)))
|
||||
.get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
.getSelectedKey(state));
|
||||
|
||||
final String titleData = e.getFormData().getString(
|
||||
LOCALIZED_CATEGORY_DESC);
|
||||
LOCALIZED_CATEGORY_DESC);
|
||||
|
||||
selectedCategory.getDescription().addValue(selectedLocale,
|
||||
titleData);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public class CategoryDescriptionTable extends Table {
|
|||
CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.
|
||||
getSelectedKey(state)));
|
||||
getSelectedKey(state))).get();
|
||||
category.getDescription().removeValue(locale);
|
||||
|
||||
categoryRepository.save(category);
|
||||
|
|
@ -199,7 +199,7 @@ public class CategoryDescriptionTable extends Table {
|
|||
final CategoryRepository categoryRepository = CdiUtil.
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
selectedCategory = categoryRepository.findById(Long.parseLong(
|
||||
selectedCategoryId.getSelectedKey(state)));
|
||||
selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
locales = new ArrayList<>();
|
||||
if (selectedCategory.getDescription() != null) {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class CategoryDetails extends SegmentedPanel {
|
|||
final CategoryRepository categoryRepo = CdiUtil.createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepo.findById(Long.parseLong(
|
||||
selectedCategoryId.getSelectedKey(state)));
|
||||
selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category_details.heading",
|
||||
|
|
@ -115,7 +115,8 @@ class CategoryDetails extends SegmentedPanel {
|
|||
final CategoryRepository categoryRepo = CdiUtil
|
||||
.createCdiUtil().findBean(CategoryRepository.class);
|
||||
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
|
||||
//category of a domain and can't be moved
|
||||
|
|
@ -202,7 +203,7 @@ class CategoryDetails extends SegmentedPanel {
|
|||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(
|
||||
state)));
|
||||
state))).get();
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Set<String> supportedLanguages = kernelConfig.
|
||||
getSupportedLanguages();
|
||||
|
|
@ -248,7 +249,7 @@ class CategoryDetails extends SegmentedPanel {
|
|||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(
|
||||
state)));
|
||||
state))).get();
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Set<String> supportedLanguages = kernelConfig.
|
||||
getSupportedLanguages();
|
||||
|
|
@ -287,7 +288,7 @@ class CategoryDetails extends SegmentedPanel {
|
|||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(
|
||||
state)));
|
||||
state))).get();
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Set<String> supportedLanguages = kernelConfig.
|
||||
getSupportedLanguages();
|
||||
|
|
@ -335,7 +336,7 @@ class CategoryDetails extends SegmentedPanel {
|
|||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(
|
||||
state)));
|
||||
state))).get();
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Set<String> supportedLanguages = kernelConfig.
|
||||
getSupportedLanguages();
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class CategoryEditForm extends Form {
|
|||
final CategoryRepository categoryRepository = CdiUtil
|
||||
.createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(Long
|
||||
.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
.parseLong(selectedCategoryId.getSelectedKey(state))).get();
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.edit_category",
|
||||
ADMIN_BUNDLE,
|
||||
|
|
@ -117,7 +117,7 @@ public class CategoryEditForm extends Form {
|
|||
final CategoryRepository categoryRepository = cdiUtil.findBean(
|
||||
CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(Long
|
||||
.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
.parseLong(selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
categoryName.setValue(state, category.getName());
|
||||
final List<String> props = new ArrayList<>();
|
||||
|
|
@ -161,15 +161,17 @@ public class CategoryEditForm extends Form {
|
|||
CategoryManager.class);
|
||||
|
||||
final Category category = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)))
|
||||
.get();
|
||||
|
||||
final FormData data = e.getFormData();
|
||||
final String categoryNameData = data.getString(CATEGORY_NAME);
|
||||
|
||||
category.setName(categoryNameData);
|
||||
|
||||
final List<String> propertiesData = Arrays.asList((String[]) data.get(
|
||||
CATEGORY_PROPERTIES));
|
||||
final List<String> propertiesData = Arrays.asList(
|
||||
(String[]) data.get(
|
||||
CATEGORY_PROPERTIES));
|
||||
category.setEnabled(propertiesData.contains(ENABLED));
|
||||
category.setVisible(propertiesData.contains(VISIBLE));
|
||||
category.setAbstractCategory(propertiesData.contains(ABSTRACT));
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class CategoryMover extends Form {
|
|||
final CategoryRepository categoryRepo = CdiUtil
|
||||
.createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepo.findById(Long.parseLong(
|
||||
selectedCategoryId.getSelectedKey(state)));
|
||||
selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.move.heading",
|
||||
|
|
@ -94,10 +94,10 @@ public class CategoryMover extends Form {
|
|||
CategoryManager.class);
|
||||
|
||||
final Category category = categoryRepo.findById(Long.parseLong(
|
||||
selectedCategoryId.getSelectedKey(state)));
|
||||
selectedCategoryId.getSelectedKey(state))).get();
|
||||
final Category parent = category.getParentCategory();
|
||||
final Category target = categoryRepo.findById(Long.parseLong(
|
||||
(String) categoryTree.getSelectedKey(state)));
|
||||
(String) categoryTree.getSelectedKey(state))).get();
|
||||
|
||||
categoryManager.removeSubCategoryFromCategory(category, parent);
|
||||
categoryManager.addSubCategoryToCategory(category, target);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class CategoryMoverModel implements TreeModel {
|
|||
final CategoryRepository categoryRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(domain.getRoot()
|
||||
.getObjectId());
|
||||
.getObjectId()).get();
|
||||
return new CategoryMoverNode(category);
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ public class CategoryMoverModel implements TreeModel {
|
|||
final CategoryRepository categoryRepo = CdiUtil.createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepo.findById(
|
||||
((CategoryMoverNode) node).getCategory().getObjectId());
|
||||
((CategoryMoverNode) node).getCategory().getObjectId()).get();
|
||||
|
||||
final List<Category> subCategories = new ArrayList<>();
|
||||
category.getSubCategories().forEach(c -> {
|
||||
|
|
|
|||
|
|
@ -58,12 +58,12 @@ public class CategoryMoverModelBuilder
|
|||
final DomainRepository domainRepository = cdiUtil.findBean(
|
||||
DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
final CategoryRepository categoryRepository = cdiUtil.findBean(
|
||||
CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(Long.parseLong(
|
||||
selectedCategoryId.getSelectedKey(state)));
|
||||
selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
return new CategoryMoverModel(domain, category);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class CategoryPropertySheetModelBuilder
|
|||
final CategoryRepository categoryRepository = CdiUtil.
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
selectedCategory = categoryRepository.findById(Long.parseLong(
|
||||
categoryIdStr));
|
||||
categoryIdStr)).get();
|
||||
}
|
||||
|
||||
return new CategoryPropertySheetModel(selectedCategory);
|
||||
|
|
|
|||
|
|
@ -51,16 +51,16 @@ public class CategoryTitleForm extends Form {
|
|||
private final SaveCancelSection saveCancelSection;
|
||||
|
||||
public CategoryTitleForm(
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedCategoryId,
|
||||
final ParameterSingleSelectionModel<String> selectedLanguage) {
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedCategoryId,
|
||||
final ParameterSingleSelectionModel<String> selectedLanguage) {
|
||||
|
||||
super("categoryTitleForm", new BoxPanel(BoxPanel.VERTICAL));
|
||||
|
||||
this.categoriesTab = categoriesTab;
|
||||
|
||||
final ActionLink backLink = new ActionLink(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.title.edit.back", ADMIN_BUNDLE));
|
||||
"ui.admin.categories.category.title.edit.back", ADMIN_BUNDLE));
|
||||
backLink.addActionListener(e -> {
|
||||
categoriesTab.hideDomainTitleForm(e.getPageState());
|
||||
});
|
||||
|
|
@ -70,28 +70,28 @@ public class CategoryTitleForm extends Form {
|
|||
final PageState state = e.getPageState();
|
||||
|
||||
final CategoryRepository categoryRepository = CdiUtil.
|
||||
createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
createCdiUtil()
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category selectedCategory = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
.getSelectedKey(state));
|
||||
|
||||
final Label target = (Label) e.getTarget();
|
||||
|
||||
if (selectedCategory.getTitle().hasValue(selectedLocale)) {
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.title.edit_for_lang",
|
||||
ADMIN_BUNDLE,
|
||||
new String[]{selectedCategory.getName(),
|
||||
selectedLocale.toString()}));
|
||||
"ui.admin.categories.category.title.edit_for_lang",
|
||||
ADMIN_BUNDLE,
|
||||
new String[]{selectedCategory.getName(),
|
||||
selectedLocale.toString()}));
|
||||
} else {
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.title.add_for_lang",
|
||||
ADMIN_BUNDLE,
|
||||
new String[]{selectedCategory.getName(),
|
||||
selectedLocale.toString()}));
|
||||
"ui.admin.categories.category.title.add_for_lang",
|
||||
ADMIN_BUNDLE,
|
||||
new String[]{selectedCategory.getName(),
|
||||
selectedLocale.toString()}));
|
||||
}
|
||||
});
|
||||
heading.setClassAttr("heading");
|
||||
|
|
@ -99,7 +99,7 @@ public class CategoryTitleForm extends Form {
|
|||
|
||||
title = new TextField(LOCALIZED_CATEGORY_TITLE);
|
||||
title.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.category.title.label", ADMIN_BUNDLE));
|
||||
"ui.admin.categories.category.title.label", ADMIN_BUNDLE));
|
||||
add(title);
|
||||
|
||||
saveCancelSection = new SaveCancelSection();
|
||||
|
|
@ -109,12 +109,12 @@ public class CategoryTitleForm extends Form {
|
|||
final PageState state = e.getPageState();
|
||||
|
||||
final CategoryRepository categoryRepository = CdiUtil.
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category selectedCategory = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
.getSelectedKey(state));
|
||||
|
||||
if (selectedCategory.getTitle().hasValue(selectedLocale)) {
|
||||
title.setValue(state, selectedCategory.getTitle().getValue(
|
||||
|
|
@ -127,14 +127,14 @@ public class CategoryTitleForm extends Form {
|
|||
final FormData data = e.getFormData();
|
||||
|
||||
final String titleData = data.
|
||||
getString(LOCALIZED_CATEGORY_TITLE);
|
||||
getString(LOCALIZED_CATEGORY_TITLE);
|
||||
|
||||
if (Strings.isBlank(titleData)) {
|
||||
data.addError(
|
||||
LOCALIZED_CATEGORY_TITLE,
|
||||
new GlobalizedMessage(
|
||||
"ui.admin.categories.category.title.error.not_blank",
|
||||
ADMIN_BUNDLE));
|
||||
LOCALIZED_CATEGORY_TITLE,
|
||||
new GlobalizedMessage(
|
||||
"ui.admin.categories.category.title.error.not_blank",
|
||||
ADMIN_BUNDLE));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -144,15 +144,16 @@ public class CategoryTitleForm extends Form {
|
|||
|
||||
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
||||
final CategoryRepository categoryRepository = CdiUtil.
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category selectedCategory = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(state)))
|
||||
.get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
.getSelectedKey(state));
|
||||
|
||||
final String titleData = e.getFormData().getString(
|
||||
LOCALIZED_CATEGORY_TITLE);
|
||||
LOCALIZED_CATEGORY_TITLE);
|
||||
|
||||
selectedCategory.getTitle().addValue(selectedLocale, titleData);
|
||||
categoryRepository.save(selectedCategory);
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class CategoryTitleTable extends Table {
|
|||
CategoryRepository.class);
|
||||
final Category category = categoryRepository.findById(
|
||||
Long.parseLong(selectedCategoryId.
|
||||
getSelectedKey(state)));
|
||||
getSelectedKey(state))).get();
|
||||
category.getTitle().removeValue(locale);
|
||||
|
||||
categoryRepository.save(category);
|
||||
|
|
@ -197,7 +197,7 @@ public class CategoryTitleTable extends Table {
|
|||
final CategoryRepository categoryRepository = CdiUtil.
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
selectedCategory = categoryRepository.findById(Long.parseLong(
|
||||
selectedCategoryId.getSelectedKey(state)));
|
||||
selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
locales = new ArrayList<>();
|
||||
if (selectedCategory.getTitle() != null) {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class DomainDescriptionForm extends Form {
|
|||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
final Domain selectedDomain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
|
|
@ -113,7 +113,7 @@ class DomainDescriptionForm extends Form {
|
|||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
final Domain selectedDomain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
|
|
@ -150,7 +150,8 @@ class DomainDescriptionForm extends Form {
|
|||
.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
final Domain selectedDomain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)))
|
||||
.get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ class DomainDescriptionTable extends Table {
|
|||
private final ParameterSingleSelectionModel<String> selectedLanguage;
|
||||
|
||||
public DomainDescriptionTable(
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedDomainId,
|
||||
final ParameterSingleSelectionModel<String> selectedLanguage) {
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedDomainId,
|
||||
final ParameterSingleSelectionModel<String> selectedLanguage) {
|
||||
|
||||
super();
|
||||
|
||||
|
|
@ -74,30 +74,30 @@ class DomainDescriptionTable extends Table {
|
|||
setIdAttr("domainDescriptionTable");
|
||||
|
||||
setEmptyView(new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.none",
|
||||
ADMIN_BUNDLE)));
|
||||
"ui.admin.categories.domain_details.description.none",
|
||||
ADMIN_BUNDLE)));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(new TableColumn(
|
||||
COL_LOCALE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.col_lang",
|
||||
ADMIN_BUNDLE))));
|
||||
COL_LOCALE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.col_lang",
|
||||
ADMIN_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_VALUE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.col_value",
|
||||
ADMIN_BUNDLE))));
|
||||
COL_VALUE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.col_value",
|
||||
ADMIN_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_EDIT,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.col_edit",
|
||||
ADMIN_BUNDLE))));
|
||||
COL_EDIT,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.col_edit",
|
||||
ADMIN_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_DEL,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.col_del",
|
||||
ADMIN_BUNDLE))));
|
||||
COL_DEL,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.col_del",
|
||||
ADMIN_BUNDLE))));
|
||||
|
||||
columnModel.get(COL_EDIT).setCellRenderer(new TableCellRenderer() {
|
||||
|
||||
|
|
@ -129,9 +129,9 @@ class DomainDescriptionTable extends Table {
|
|||
} else {
|
||||
final ControlLink link = new ControlLink((Component) value);
|
||||
link.setConfirmation(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description"
|
||||
+ ".del_confirm",
|
||||
ADMIN_BUNDLE));
|
||||
"ui.admin.categories.domain_details.description"
|
||||
+ ".del_confirm",
|
||||
ADMIN_BUNDLE));
|
||||
return link;
|
||||
}
|
||||
}
|
||||
|
|
@ -152,13 +152,13 @@ class DomainDescriptionTable extends Table {
|
|||
break;
|
||||
case COL_DEL:
|
||||
final Locale locale = new Locale((String) event
|
||||
.getRowKey());
|
||||
.getRowKey());
|
||||
final DomainRepository domainRepository = CdiUtil
|
||||
.createCdiUtil().
|
||||
findBean(DomainRepository.class);
|
||||
.createCdiUtil().
|
||||
findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId
|
||||
.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId
|
||||
.getSelectedKey(state))).get();
|
||||
domain.getDescription().removeValue(locale);
|
||||
|
||||
domainRepository.save(domain);
|
||||
|
|
@ -179,8 +179,8 @@ class DomainDescriptionTable extends Table {
|
|||
}
|
||||
|
||||
private class DomainDescriptionTableModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table,
|
||||
|
|
@ -200,13 +200,13 @@ class DomainDescriptionTable extends Table {
|
|||
|
||||
public DomainDescriptionTableModel(final PageState state) {
|
||||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
.findBean(DomainRepository.class);
|
||||
selectedDomain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
locales = new ArrayList<>();
|
||||
locales.addAll(selectedDomain.getDescription()
|
||||
.getAvailableLocales());
|
||||
.getAvailableLocales());
|
||||
locales.sort((l1, l2) -> {
|
||||
return l1.toString().compareTo(l2.toString());
|
||||
});
|
||||
|
|
@ -234,15 +234,15 @@ class DomainDescriptionTable extends Table {
|
|||
return selectedDomain.getDescription().getValue(locale);
|
||||
case COL_EDIT:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.edit",
|
||||
ADMIN_BUNDLE));
|
||||
"ui.admin.categories.domain_details.description.edit",
|
||||
ADMIN_BUNDLE));
|
||||
case COL_DEL:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.description.del",
|
||||
ADMIN_BUNDLE));
|
||||
"ui.admin.categories.domain_details.description.del",
|
||||
ADMIN_BUNDLE));
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Not a valid column index");
|
||||
"Not a valid column index");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class DomainDetails extends SegmentedPanel {
|
|||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain.details.heading",
|
||||
|
|
@ -163,7 +163,8 @@ class DomainDetails extends SegmentedPanel {
|
|||
final DomainRepository domainRepository = CdiUtil
|
||||
.createCdiUtil().findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long
|
||||
.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
.parseLong(selectedDomainId.getSelectedKey(state)))
|
||||
.get();
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Set<String> supportedLanguages = kernelConfig
|
||||
.getSupportedLanguages();
|
||||
|
|
@ -208,8 +209,7 @@ class DomainDetails extends SegmentedPanel {
|
|||
final DomainRepository domainRepository = CdiUtil
|
||||
.createCdiUtil().findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long
|
||||
.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
.parseLong(selectedDomainId.getSelectedKey(state))).get();
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Set<String> supportedLanguages = kernelConfig
|
||||
.getSupportedLanguages();
|
||||
|
|
@ -247,8 +247,8 @@ class DomainDetails extends SegmentedPanel {
|
|||
final DomainRepository domainRepository = CdiUtil
|
||||
.createCdiUtil().findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long
|
||||
.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
.parseLong(selectedDomainId.getSelectedKey(state)))
|
||||
.get();
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Set<String> supportedLanguages = kernelConfig
|
||||
.getSupportedLanguages();
|
||||
|
|
@ -294,8 +294,7 @@ class DomainDetails extends SegmentedPanel {
|
|||
final DomainRepository domainRepository = CdiUtil
|
||||
.createCdiUtil().findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long
|
||||
.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
.parseLong(selectedDomainId.getSelectedKey(state))).get();
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Set<String> supportedLanguages = kernelConfig
|
||||
.getSupportedLanguages();
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class DomainForm extends Form {
|
|||
final DomainRepository domainRepository = CdiUtil.
|
||||
createCdiUtil().findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
selectedDomainId.getSelectedKey(state))).get();
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_form.heading.edit",
|
||||
ADMIN_BUNDLE,
|
||||
|
|
@ -130,7 +130,7 @@ class DomainForm extends Form {
|
|||
final DomainRepository domainRepository = cdiUtil.findBean(
|
||||
DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(Long.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
domainKey.setValue(state, domain.getDomainKey());
|
||||
domainUri.setValue(state, domain.getUri());
|
||||
|
|
@ -202,7 +202,7 @@ class DomainForm extends Form {
|
|||
}
|
||||
} else {
|
||||
domain = domainRepository.findById(Long.parseLong(
|
||||
selectedDomainId.getSelectedKey(state)));
|
||||
selectedDomainId.getSelectedKey(state))).get();
|
||||
}
|
||||
domain.setDomainKey(domainKeyData);
|
||||
domain.setUri(domainUriData);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class DomainMappingAddForm extends Form {
|
|||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(
|
||||
selectedDomainId.getSelectedKey(e.getPageState())),
|
||||
"Domain.withOwners");
|
||||
"Domain.withOwners").get();
|
||||
|
||||
final List<CcmApplication> applications = appRepository
|
||||
.findAll();
|
||||
|
|
@ -130,10 +130,10 @@ class DomainMappingAddForm extends Form {
|
|||
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)),
|
||||
"Domain.withOwners");
|
||||
"Domain.withOwners").get();
|
||||
final CcmApplication application = appRepository.findById(
|
||||
Long.parseLong(data.getString(DOMAIN_MAPPING_OWNER)),
|
||||
"CcmApplication.withDomains");
|
||||
"CcmApplication.withDomains").get();
|
||||
|
||||
domainManager.addDomainOwner(application, domain);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -130,10 +130,10 @@ class DomainMappingsTable extends Table {
|
|||
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(event
|
||||
.getPageState())));
|
||||
.getPageState()))).get();
|
||||
|
||||
final CcmApplication owner = appRepository.findById(
|
||||
Long.parseLong((String)event.getRowKey()));
|
||||
Long.parseLong((String)event.getRowKey())).get();
|
||||
|
||||
domainManager.removeDomainOwner(owner, domain);
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ class DomainMappingsTable extends Table {
|
|||
.findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)),
|
||||
"Domain.withOwners");
|
||||
"Domain.withOwners").get();
|
||||
|
||||
domainOwnerships = new ArrayList<>(domain.getOwners());
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class DomainPropertySheetModelBuilder
|
|||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
selectedDomain = domainRepository.findById(Long.parseLong(
|
||||
domainIdStr));
|
||||
domainIdStr)).get();
|
||||
}
|
||||
|
||||
return new DomainPropertySheetModel(selectedDomain);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class DomainTitleForm extends Form {
|
|||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
final Domain selectedDomain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
|
|
@ -111,7 +111,7 @@ class DomainTitleForm extends Form {
|
|||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
final Domain selectedDomain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
|
|
@ -148,7 +148,8 @@ class DomainTitleForm extends Form {
|
|||
.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
final Domain selectedDomain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)))
|
||||
.get();
|
||||
|
||||
final Locale selectedLocale = new Locale(selectedLanguage
|
||||
.getSelectedKey(state));
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ class DomainTitleTable extends Table {
|
|||
private final ParameterSingleSelectionModel<String> selectedLanguage;
|
||||
|
||||
public DomainTitleTable(
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedDomainId,
|
||||
final ParameterSingleSelectionModel<String> selectedLanguage) {
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedDomainId,
|
||||
final ParameterSingleSelectionModel<String> selectedLanguage) {
|
||||
|
||||
super();
|
||||
|
||||
|
|
@ -74,29 +74,29 @@ class DomainTitleTable extends Table {
|
|||
setIdAttr("domainTitleTable");
|
||||
|
||||
setEmptyView(new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.none", ADMIN_BUNDLE)));
|
||||
"ui.admin.categories.domain_details.title.none", ADMIN_BUNDLE)));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(new TableColumn(
|
||||
COL_LOCALE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.col_lang",
|
||||
ADMIN_BUNDLE))));
|
||||
COL_LOCALE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.col_lang",
|
||||
ADMIN_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_VALUE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.col_value",
|
||||
ADMIN_BUNDLE))));
|
||||
COL_VALUE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.col_value",
|
||||
ADMIN_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_EDIT,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.col_edit",
|
||||
ADMIN_BUNDLE))));
|
||||
COL_EDIT,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.col_edit",
|
||||
ADMIN_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_DEL,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.col_del",
|
||||
ADMIN_BUNDLE))));
|
||||
COL_DEL,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.col_del",
|
||||
ADMIN_BUNDLE))));
|
||||
|
||||
columnModel.get(COL_EDIT).setCellRenderer(new TableCellRenderer() {
|
||||
|
||||
|
|
@ -128,8 +128,8 @@ class DomainTitleTable extends Table {
|
|||
} else {
|
||||
final ControlLink link = new ControlLink((Component) value);
|
||||
link.setConfirmation(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.del_confirm",
|
||||
ADMIN_BUNDLE));
|
||||
"ui.admin.categories.domain_details.title.del_confirm",
|
||||
ADMIN_BUNDLE));
|
||||
return link;
|
||||
}
|
||||
}
|
||||
|
|
@ -150,13 +150,13 @@ class DomainTitleTable extends Table {
|
|||
break;
|
||||
case COL_DEL:
|
||||
final Locale locale = new Locale((String) event
|
||||
.getRowKey());
|
||||
.getRowKey());
|
||||
final DomainRepository domainRepository = CdiUtil
|
||||
.createCdiUtil().
|
||||
findBean(DomainRepository.class);
|
||||
.createCdiUtil().
|
||||
findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId
|
||||
.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId
|
||||
.getSelectedKey(state))).get();
|
||||
domain.getTitle().removeValue(locale);
|
||||
|
||||
domainRepository.save(domain);
|
||||
|
|
@ -176,8 +176,8 @@ class DomainTitleTable extends Table {
|
|||
}
|
||||
|
||||
private class DomainTitleTableModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
|
|
@ -196,9 +196,9 @@ class DomainTitleTable extends Table {
|
|||
|
||||
public DomainTitleTableModel(final PageState state) {
|
||||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
.findBean(DomainRepository.class);
|
||||
selectedDomain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state))).get();
|
||||
|
||||
locales = new ArrayList<>();
|
||||
locales.addAll(selectedDomain.getTitle().getAvailableLocales());
|
||||
|
|
@ -229,17 +229,17 @@ class DomainTitleTable extends Table {
|
|||
return selectedDomain.getTitle().getValue(locale);
|
||||
case COL_EDIT:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.edit",
|
||||
ADMIN_BUNDLE
|
||||
"ui.admin.categories.domain_details.title.edit",
|
||||
ADMIN_BUNDLE
|
||||
));
|
||||
case COL_DEL:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.title.del",
|
||||
ADMIN_BUNDLE
|
||||
"ui.admin.categories.domain_details.title.del",
|
||||
ADMIN_BUNDLE
|
||||
));
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Not a valid column index");
|
||||
"Not a valid column index");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -199,9 +199,9 @@ public class SubCategoriesTable extends Table {
|
|||
.findBean(CategoryManager.class);
|
||||
final Category parentCategory = categoryRepo.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(
|
||||
state)));
|
||||
state))).get();
|
||||
final Category subCategory = categoryRepo.findById(Long
|
||||
.parseLong((String) event.getRowKey()));
|
||||
.parseLong((String) event.getRowKey())).get();
|
||||
categoryManager.decreaseCategoryOrder(subCategory,
|
||||
parentCategory);
|
||||
break;
|
||||
|
|
@ -214,9 +214,9 @@ public class SubCategoriesTable extends Table {
|
|||
.findBean(CategoryManager.class);
|
||||
final Category parentCategory = categoryRepo.findById(
|
||||
Long.parseLong(selectedCategoryId.getSelectedKey(
|
||||
state)));
|
||||
state))).get();
|
||||
final Category subCategory = categoryRepo.findById(Long
|
||||
.parseLong((String) event.getRowKey()));
|
||||
.parseLong((String) event.getRowKey())).get();
|
||||
categoryManager.increaseCategoryOrder(subCategory,
|
||||
parentCategory);
|
||||
break;
|
||||
|
|
@ -232,7 +232,7 @@ public class SubCategoriesTable extends Table {
|
|||
final CategoryRepository categoryRepo = cdiUtil
|
||||
.findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepo.findById(Long
|
||||
.parseLong((String) event.getRowKey()));
|
||||
.parseLong((String) event.getRowKey())).get();
|
||||
categoryRepo.delete(category);
|
||||
break;
|
||||
}
|
||||
|
|
@ -271,7 +271,7 @@ public class SubCategoriesTable extends Table {
|
|||
final CategoryRepository categoryRepo = CdiUtil.
|
||||
createCdiUtil().findBean(CategoryRepository.class);
|
||||
final Category category = categoryRepo.findById(Long.parseLong(
|
||||
selectedCategoryId.getSelectedKey(state)));
|
||||
selectedCategoryId.getSelectedKey(state))).get();
|
||||
|
||||
subCategories = new ArrayList<>(category.getSubCategories());
|
||||
subCategories.sort((c1, c2) -> {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class GroupAddMemberForm extends Form {
|
|||
final GroupRepository groupRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(GroupRepository.class);
|
||||
final Group group = groupRepository.findById(Long.parseLong(
|
||||
selectedGroupId.getSelectedKey(state)));
|
||||
selectedGroupId.getSelectedKey(state))).get();
|
||||
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.group_details.add_member.header",
|
||||
|
|
@ -191,10 +191,11 @@ class GroupAddMemberForm extends Form {
|
|||
final GroupManager groupManager = cdiUtil.findBean(
|
||||
GroupManager.class);
|
||||
final User user = userRepository.findById(Long
|
||||
.parseLong(key));
|
||||
.parseLong(key)).get();
|
||||
final Group group = groupRepository.findById(
|
||||
Long.parseLong(
|
||||
selectedGroupId.getSelectedKey(state)));
|
||||
selectedGroupId.getSelectedKey(state)))
|
||||
.get();
|
||||
groupManager.addMemberToGroup(user, group);
|
||||
groupAdmin.hideGroupMemberAddForm(state);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class GroupDetails extends BoxPanel {
|
|||
final GroupRepository groupRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(GroupRepository.class);
|
||||
final Group group = groupRepository.findById(Long.parseLong(
|
||||
selectedGroupId.getSelectedKey(state)));
|
||||
selectedGroupId.getSelectedKey(state))).get();
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.group_details.header",
|
||||
ADMIN_BUNDLE,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import org.libreccm.cdi.utils.CdiUtil;
|
|||
import org.libreccm.security.Group;
|
||||
import org.libreccm.security.GroupRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +114,8 @@ class GroupForm extends Form {
|
|||
final GroupRepository groupRepository = cdiUtil.findBean(
|
||||
GroupRepository.class);
|
||||
|
||||
if (groupRepository.findByName(groupNameData) != null) {
|
||||
final Optional<Group> group = groupRepository.findByName(groupNameData);
|
||||
if (group.isPresent()) {
|
||||
data.addError(GROUP_NAME, new GlobalizedMessage(
|
||||
"ui.admin.group.error.name_already_in_use",
|
||||
ADMIN_BUNDLE));
|
||||
|
|
@ -132,7 +135,7 @@ class GroupForm extends Form {
|
|||
GroupRepository.class);
|
||||
|
||||
final Group group = groupRepository.findById(Long.parseLong(
|
||||
selectedGroupIdStr));
|
||||
selectedGroupIdStr)).get();
|
||||
groupName.setValue(state, group.getName());
|
||||
}
|
||||
});
|
||||
|
|
@ -158,7 +161,7 @@ class GroupForm extends Form {
|
|||
groupRepository.save(group);
|
||||
} else {
|
||||
final Group group = groupRepository.findById(Long.parseLong(
|
||||
selectedGroupIdStr));
|
||||
selectedGroupIdStr)).get();
|
||||
group.setName(groupNameData);
|
||||
|
||||
groupRepository.save(group);
|
||||
|
|
|
|||
|
|
@ -132,10 +132,10 @@ class GroupMembersTable extends Table {
|
|||
final GroupManager groupManager = cdiUtil.findBean(
|
||||
GroupManager.class);
|
||||
final User user = userRepository.findById(Long
|
||||
.parseLong(key));
|
||||
.parseLong(key)).get();
|
||||
final Group group = groupRepository.findById(
|
||||
Long.parseLong(
|
||||
selectedGroupId.getSelectedKey(state)));
|
||||
selectedGroupId.getSelectedKey(state))).get();
|
||||
groupManager.removeMemberFromGroup(user, group);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -186,7 +186,7 @@ class GroupMembersTable extends Table {
|
|||
final GroupRepository groupRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(GroupRepository.class);
|
||||
final Group group = groupRepository.findById(Long.parseLong(
|
||||
selectedGroupId.getSelectedKey(state)));
|
||||
selectedGroupId.getSelectedKey(state))).get();
|
||||
|
||||
members = new ArrayList<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class GroupPropertySheetModelBuilder
|
|||
} else {
|
||||
final GroupRepository groupRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(GroupRepository.class);
|
||||
selectedGroup = groupRepository.findById(Long.parseLong(groupIdStr));
|
||||
selectedGroup = groupRepository.findById(Long.parseLong(groupIdStr)).get();
|
||||
}
|
||||
|
||||
return new GroupPropertySheetModel(selectedGroup);
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class GroupsTable extends Table {
|
|||
final GroupRepository groupRepository = CdiUtil
|
||||
.createCdiUtil().findBean(GroupRepository.class);
|
||||
final Group group = groupRepository.findById(
|
||||
Long.parseLong(key));
|
||||
Long.parseLong(key)).get();
|
||||
groupRepository.delete(group);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class RoleAddMemberForm extends Form {
|
|||
final RoleRepository roleRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(RoleRepository.class);
|
||||
final Role role = roleRepository.findById(Long.parseLong(
|
||||
selectedRoleId.getSelectedKey(state)));
|
||||
selectedRoleId.getSelectedKey(state))).get();
|
||||
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.role_members.add.heading",
|
||||
|
|
@ -169,10 +169,10 @@ class RoleAddMemberForm extends Form {
|
|||
final RoleManager roleManager = cdiUtil.findBean(
|
||||
RoleManager.class);
|
||||
final Party party = partyRepository.findById(
|
||||
Long.parseLong(key));
|
||||
Long.parseLong(key)).get();
|
||||
final Role role = roleRepository.findById(
|
||||
Long.parseLong(
|
||||
selectedRoleId.getSelectedKey(state)));
|
||||
selectedRoleId.getSelectedKey(state))).get();
|
||||
roleManager.assignRoleToParty(role, party);
|
||||
roleAdmin.hideRoleMemberAddForm(state);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class RoleDetails extends BoxPanel {
|
|||
final RoleRepository roleRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(RoleRepository.class);
|
||||
final Role role = roleRepository.findById(Long.parseLong(
|
||||
selectedRoleId.getSelectedKey(state)));
|
||||
selectedRoleId.getSelectedKey(state))).get();
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.role_details.heading",
|
||||
ADMIN_BUNDLE,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import org.libreccm.cdi.utils.CdiUtil;
|
|||
import org.libreccm.security.Role;
|
||||
import org.libreccm.security.RoleRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
|
|
@ -106,7 +108,8 @@ class RoleForm extends Form {
|
|||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final RoleRepository roleRepository = cdiUtil.findBean(
|
||||
RoleRepository.class);
|
||||
if (roleRepository.findByName(roleNameData) != null) {
|
||||
final Optional<Role> role = roleRepository.findByName(roleNameData);
|
||||
if (role.isPresent()) {
|
||||
data.addError(ROLE_NAME, new GlobalizedMessage(
|
||||
"ui.admin.role.error.name_already_in_use",
|
||||
ADMIN_BUNDLE));
|
||||
|
|
@ -126,7 +129,7 @@ class RoleForm extends Form {
|
|||
RoleRepository.class);
|
||||
|
||||
final Role role = roleRepository.findById(Long.parseLong(
|
||||
selectedRoleIdStr));
|
||||
selectedRoleIdStr)).get();
|
||||
roleName.setValue(state, role.getName());
|
||||
}
|
||||
});
|
||||
|
|
@ -151,7 +154,7 @@ class RoleForm extends Form {
|
|||
roleRepository.save(role);
|
||||
} else {
|
||||
final Role role = roleRepository.findById(Long.parseLong(
|
||||
selectedRoleIdStr));
|
||||
selectedRoleIdStr)).get();
|
||||
role.setName(roleNameData);
|
||||
|
||||
roleRepository.save(role);
|
||||
|
|
|
|||
|
|
@ -119,9 +119,9 @@ class RoleMembersTable extends Table {
|
|||
final RoleManager roleManager = cdiUtil.findBean(
|
||||
RoleManager.class);
|
||||
final Party party = partyRepository.findById(Long
|
||||
.parseLong(key));
|
||||
.parseLong(key)).get();
|
||||
final Role role = roleRepository.findById(
|
||||
Long.parseLong(selectedRoleId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedRoleId.getSelectedKey(state))).get();
|
||||
roleManager.removeRoleFromParty(role, party);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -173,7 +173,7 @@ class RoleMembersTable extends Table {
|
|||
final RoleRepository roleRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(RoleRepository.class);
|
||||
final Role role = roleRepository.findById(Long.parseLong(
|
||||
selectedRoleId.getSelectedKey(state)));
|
||||
selectedRoleId.getSelectedKey(state))).get();
|
||||
|
||||
members = new ArrayList<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class RolePermissionsForm extends Form {
|
|||
final RoleRepository roleRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(RoleRepository.class);
|
||||
final Role role = roleRepository.findById(Long.parseLong(
|
||||
selectedRoleId.getSelectedKey(state)));
|
||||
selectedRoleId.getSelectedKey(state))).get();
|
||||
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.role_details.add_permission.heading",
|
||||
|
|
@ -170,7 +170,7 @@ class RolePermissionsForm extends Form {
|
|||
RoleRepository.class);
|
||||
|
||||
final Role role = roleRepository.findById(Long.parseLong(
|
||||
selectedRoleId.getSelectedKey(state)));
|
||||
selectedRoleId.getSelectedKey(state))).get();
|
||||
final PermissionManager permissionManager = cdiUtil.findBean(
|
||||
PermissionManager.class);
|
||||
if (objectIdData == null || objectIdData.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class RolePermissionsTable extends Table {
|
|||
final PermissionManager permissionManager = cdiUtil
|
||||
.findBean(PermissionManager.class);
|
||||
final Role role = roleRepository.findById(
|
||||
Long.parseLong(selectedRoleId.getSelectedKey(state)));
|
||||
Long.parseLong(selectedRoleId.getSelectedKey(state))).get();
|
||||
final Permission permission = permissionManager
|
||||
.findById(Long.parseLong(key));
|
||||
if (permission.getObject() == null) {
|
||||
|
|
@ -176,7 +176,7 @@ class RolePermissionsTable extends Table {
|
|||
.findBean(RoleRepository.class);
|
||||
final Role role = roleRepository.findById(
|
||||
Long.parseLong(selectedRoleId.getSelectedKey(state)),
|
||||
Role.ENTITY_GRPAH_WITH_PERMISSIONS);
|
||||
Role.ENTITY_GRPAH_WITH_PERMISSIONS).get();
|
||||
|
||||
permissions = new ArrayList<>(role.getPermissions());
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ class RolePropertySheetModelBuilder extends LockableImpl
|
|||
} else {
|
||||
final RoleRepository roleRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(RoleRepository.class);
|
||||
selectedRole = roleRepository.findById(Long.parseLong(roleIdStr));
|
||||
selectedRole = roleRepository.findById(Long.parseLong(roleIdStr))
|
||||
.get();
|
||||
}
|
||||
|
||||
return new RolePropertySheetModel(selectedRole);
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class RolesTable extends Table {
|
|||
final RoleRepository roleRepository = CdiUtil
|
||||
.createCdiUtil().findBean(RoleRepository.class);
|
||||
final Role role = roleRepository.findById(Long
|
||||
.parseLong(key));
|
||||
.parseLong(key)).get();
|
||||
roleRepository.delete(role);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class ActionLinks extends BoxPanel {
|
|||
final UserRepository userRepository = cdiUtil.findBean(
|
||||
UserRepository.class);
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
selectedUserId.getSelectedKey(e.getPageState())));
|
||||
selectedUserId.getSelectedKey(e.getPageState()))).get();
|
||||
final ChallengeManager challengeManager = cdiUtil.findBean(
|
||||
ChallengeManager.class);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class EmailForm extends Form {
|
|||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
userIdStr));
|
||||
userIdStr)).get();
|
||||
EmailAddress email = null;
|
||||
if (user.getPrimaryEmailAddress().getAddress().equals(selected)) {
|
||||
email = user.getPrimaryEmailAddress();
|
||||
|
|
@ -147,7 +147,7 @@ class EmailForm extends Form {
|
|||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
userIdStr));
|
||||
userIdStr)).get();
|
||||
EmailAddress email = null;
|
||||
if (selected == null) {
|
||||
email = new EmailAddress();
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class EmailTable extends Table {
|
|||
final UserRepository userRepository = CdiUtil
|
||||
.createCdiUtil().findBean(UserRepository.class);
|
||||
final User user = userRepository.findById(Long
|
||||
.parseLong(userIdStr));
|
||||
.parseLong(userIdStr)).get();
|
||||
EmailAddress email = null;
|
||||
for (EmailAddress current : user.getEmailAddresses()) {
|
||||
if (current.getAddress().equals(key)) {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class EmailTableModelBuilder extends LockableImpl
|
|||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final long userId = Long.parseLong(userIdStr);
|
||||
selectedUser = userRepository.findById(userId);
|
||||
selectedUser = userRepository.findById(userId).get();
|
||||
}
|
||||
|
||||
return new EmailTableModel(selectedUser);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ class GroupMembershipsForm extends Form {
|
|||
final String userIdStr = selectedUserId.getSelectedKey(state);
|
||||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final User user = userRepository.findById(Long.parseLong(userIdStr));
|
||||
final User user = userRepository.findById(Long.parseLong(userIdStr))
|
||||
.get();
|
||||
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.user.edit_group_memberships",
|
||||
|
|
@ -136,7 +137,7 @@ class GroupMembershipsForm extends Form {
|
|||
final PageState state = e.getPageState();
|
||||
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
selectedUserId.getSelectedKey(state)));
|
||||
selectedUserId.getSelectedKey(state))).get();
|
||||
final List<Group> assignedGroups = new ArrayList<>();
|
||||
user.getGroupMemberships().forEach(m -> {
|
||||
assignedGroups.add(m.getGroup());
|
||||
|
|
@ -168,12 +169,12 @@ class GroupMembershipsForm extends Form {
|
|||
GROUPS_SELECTOR);
|
||||
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
selectedUserId.getSelectedKey(state)));
|
||||
selectedUserId.getSelectedKey(state))).get();
|
||||
final List<Group> selectedGroups = new ArrayList<>();
|
||||
if (selectedGroupIds != null) {
|
||||
Arrays.stream(selectedGroupIds).forEach(id -> {
|
||||
final Group group = groupRepository.findById(
|
||||
Long.parseLong(id));
|
||||
Long.parseLong(id)).get();
|
||||
selectedGroups.add(group);
|
||||
});
|
||||
}
|
||||
|
|
@ -195,7 +196,7 @@ class GroupMembershipsForm extends Form {
|
|||
//The group is maybe detached or not fully loaded,
|
||||
//therefore we load the group from the database.
|
||||
final Group group = groupRepository.findById(
|
||||
g.getPartyId());
|
||||
g.getPartyId()).get();
|
||||
groupManager.removeMemberFromGroup(user, group);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class GroupsRolesTableModelBuilder extends LockableImpl
|
|||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final long userId = Long.parseLong(userIdStr);
|
||||
selectedUser = userRepository.findById(userId);
|
||||
selectedUser = userRepository.findById(userId).get();
|
||||
}
|
||||
|
||||
return new GroupsRolesTableModel(selectedUser);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class PasswordSetForm extends Form {
|
|||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
userIdStr));
|
||||
userIdStr)).get();
|
||||
|
||||
final UserManager userManager = CdiUtil.createCdiUtil()
|
||||
.findBean(
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class PrimaryEmailTableModelBuilder extends LockableImpl
|
|||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final long userId = Long.parseLong(userIdStr);
|
||||
selectedUser = userRepository.findById(userId);
|
||||
selectedUser = userRepository.findById(userId).get();
|
||||
}
|
||||
|
||||
return new PrimaryEmailTableModel(selectedUser);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ class RoleMembershipsForm extends Form {
|
|||
final String userIdStr = selectedUserId.getSelectedKey(state);
|
||||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final User user = userRepository.findById(Long.parseLong(userIdStr));
|
||||
final User user = userRepository.findById(Long.parseLong(userIdStr))
|
||||
.get();
|
||||
|
||||
target.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.user_edit_role_memberships",
|
||||
|
|
@ -136,7 +137,7 @@ class RoleMembershipsForm extends Form {
|
|||
final PageState state = e.getPageState();
|
||||
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
selectedUserId.getSelectedKey(state)));
|
||||
selectedUserId.getSelectedKey(state))).get();
|
||||
final List<Role> assignedRoles = new ArrayList<>();
|
||||
user.getRoleMemberships().forEach(m -> {
|
||||
assignedRoles.add(m.getRole());
|
||||
|
|
@ -170,12 +171,12 @@ class RoleMembershipsForm extends Form {
|
|||
ROLES_SELECTOR);
|
||||
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
selectedUserId.getSelectedKey(state)));
|
||||
selectedUserId.getSelectedKey(state))).get();
|
||||
final List<Role> selectedRoles = new ArrayList<>();
|
||||
if (selectedRolesIds != null) {
|
||||
Arrays.stream(selectedRolesIds).forEach(id -> {
|
||||
final Role role = roleRepository.findById(
|
||||
Long.parseLong(id));
|
||||
Long.parseLong(id)).get();
|
||||
selectedRoles.add(role);
|
||||
});
|
||||
}
|
||||
|
|
@ -196,7 +197,8 @@ class RoleMembershipsForm extends Form {
|
|||
if (!selectedRoles.contains(r)) {
|
||||
//Role is maybe detached or not fully loaded,
|
||||
//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);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue