CCM NG: Several small things

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4556 8810af33-2d31-482b-a856-94f89814c4df

Former-commit-id: 642b528358
pull/2/head
jensp 2017-02-08 15:01:21 +00:00
parent 25491c4b87
commit b22235d53a
29 changed files with 231 additions and 212 deletions

View File

@ -29,6 +29,7 @@ import org.apache.logging.log4j.Logger;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contentsection.FolderManager;
class FolderEditForm extends FolderBaseForm { class FolderEditForm extends FolderBaseForm {
@ -52,7 +53,11 @@ class FolderEditForm extends FolderBaseForm {
final FolderRequestLocal parent = new FolderRequestLocal(null) { final FolderRequestLocal parent = new FolderRequestLocal(null) {
@Override @Override
protected final Object initialValue(final PageState state) { protected final Object initialValue(final PageState state) {
return folder.getFolder(state).getParentFolder(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final FolderManager folderManager = cdiUtil.findBean(
FolderManager.class);
return folderManager.getParentFolder(getFolder(state))
.orElse(null);
} }
}; };

View File

@ -21,14 +21,17 @@ package com.arsdigita.cms.ui.permissions;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.security.Permission; import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.security.PermissionManager; import org.libreccm.security.PermissionManager;
import org.libreccm.security.Role; import org.libreccm.security.Role;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionRepository;
import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.contentsection.privileges.ItemPrivileges;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
@ -42,6 +45,9 @@ import javax.transaction.Transactional;
@RequestScoped @RequestScoped
class CMSPermissionsTableController { class CMSPermissionsTableController {
@Inject
private ContentSectionRepository sectionRepo;
@Inject @Inject
private PermissionManager permissionManager; private PermissionManager permissionManager;
@ -52,7 +58,14 @@ class CMSPermissionsTableController {
public List<CMSPermissionsTableRow> buildDirectPermissionsRows( public List<CMSPermissionsTableRow> buildDirectPermissionsRows(
final CcmObject object) { final CcmObject object) {
final List<Role> roles = CMS.getContext().getContentSection().getRoles(); final Optional<ContentSection> section = sectionRepo.findById(CMS
.getContext().getContentSection().getObjectId());
final List<Role> roles = section
.orElseThrow(() -> new UnexpectedErrorException(String.format(
"The content section %s from the CMS context was not found in"
+ "the database.",
Objects.toString(CMS.getContext().getContentSection()))))
.getRoles();
return roles.stream() return roles.stream()
.map(role -> buildRow(role, object)) .map(role -> buildRow(role, object))
@ -63,7 +76,7 @@ class CMSPermissionsTableController {
} }
private CMSPermissionsTableRow buildRow(final Role role, private CMSPermissionsTableRow buildRow(final Role role,
final CcmObject object) { final CcmObject object) {
final List<String> privileges = permissionManager final List<String> privileges = permissionManager
.listDefiniedPrivileges(ItemPrivileges.class); .listDefiniedPrivileges(ItemPrivileges.class);
@ -79,8 +92,8 @@ class CMSPermissionsTableController {
} }
private CMSPermissionsTableColumn buildColumn(final Role role, private CMSPermissionsTableColumn buildColumn(final Role role,
final CcmObject object, final CcmObject object,
final String privilege) { final String privilege) {
final CMSPermissionsTableColumn column = new CMSPermissionsTableColumn(); final CMSPermissionsTableColumn column = new CMSPermissionsTableColumn();
column.setPrivilege(privilege); column.setPrivilege(privilege);

View File

@ -24,6 +24,7 @@ import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.Configuration; import org.libreccm.configuration.Configuration;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.configuration.Setting; import org.libreccm.configuration.Setting;
import org.libreccm.core.UnexpectedErrorException;
import org.librecms.dispatcher.ItemResolver; import org.librecms.dispatcher.ItemResolver;
import org.librecms.dispatcher.SimpleItemResolver; import org.librecms.dispatcher.SimpleItemResolver;
@ -695,7 +696,7 @@ public class CMSConfig {
resolverClasses.add((Class<ItemResolver>) Class.forName( resolverClasses.add((Class<ItemResolver>) Class.forName(
className)); className));
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
throw new UncheckedWrapperException(String.format( throw new UnexpectedErrorException(String.format(
"ItemResolver class \"%s\" not found.", className), ex); "ItemResolver class \"%s\" not found.", className), ex);
} }
} }
@ -720,7 +721,7 @@ public class CMSConfig {
// resolverClasses.add((Class<TemplateResolver>) Class.forName( // resolverClasses.add((Class<TemplateResolver>) Class.forName(
// className)); // className));
// } catch (ClassNotFoundException ex) { // } catch (ClassNotFoundException ex) {
// throw new UncheckedWrapperException(String.format( // throw new UnexpectedErrorException(String.format(
// "ItemResolver class \"%s\" not found.", className), ex); // "ItemResolver class \"%s\" not found.", className), ex);
// } // }
// } // }

View File

@ -18,8 +18,6 @@
*/ */
package org.librecms.contentsection; package org.librecms.contentsection;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -45,6 +43,7 @@ import org.librecms.contentsection.privileges.AssetPrivileges;
import java.util.Objects; import java.util.Objects;
import org.libreccm.categorization.ObjectNotAssignedToCategoryException; import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import java.beans.BeanInfo; import java.beans.BeanInfo;
@ -68,7 +67,7 @@ import static org.librecms.CmsConstants.*;
public class AssetManager { public class AssetManager {
private static final Logger LOGGER = LogManager. private static final Logger LOGGER = LogManager.
getLogger(AssetManager.class); getLogger(AssetManager.class);
@Inject @Inject
private EntityManager entityManager; private EntityManager entityManager;
@ -94,15 +93,15 @@ public class AssetManager {
* thrown. * thrown.
* *
* *
* @param asset The {@link Asset} to share. * @param asset The {@link Asset} to share.
* @param folder The {@link Folder} in which the {@link Asset} is created. * @param folder The {@link Folder} in which the {@link Asset} is created.
*/ */
@AuthorizationRequired @AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public void shareAsset( public void shareAsset(
final Asset asset, final Asset asset,
@RequiresPrivilege(AssetPrivileges.CREATE_NEW) @RequiresPrivilege(AssetPrivileges.CREATE_NEW)
final Folder folder) { final Folder folder) {
if (asset == null) { if (asset == null) {
throw new IllegalArgumentException("Can't share asset null."); throw new IllegalArgumentException("Can't share asset null.");
@ -114,14 +113,14 @@ public class AssetManager {
if (isShared(asset)) { if (isShared(asset)) {
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(
"The asset %s is already shared.", "The asset %s is already shared.",
Objects.toString(asset))); Objects.toString(asset)));
} }
categoryManager.addObjectToCategory( categoryManager.addObjectToCategory(
asset, asset,
folder, folder,
CmsConstants.CATEGORIZATION_TYPE_FOLDER); CmsConstants.CATEGORIZATION_TYPE_FOLDER);
} }
/** /**
@ -132,12 +131,12 @@ public class AssetManager {
* @param asset The asset the check. * @param asset The asset the check.
* *
* @return {@code true} is the {@link Asset} is shared, * @return {@code true} is the {@link Asset} is shared,
* {@code false if not}. * {@code false if not}.
*/ */
public boolean isShared(final Asset asset) { public boolean isShared(final Asset asset) {
if (asset == null) { if (asset == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Can't determine if null is a shared asset."); "Can't determine if null is a shared asset.");
} }
return getAssetFolder(asset).isPresent(); return getAssetFolder(asset).isPresent();
@ -153,9 +152,9 @@ public class AssetManager {
final List<Asset> assets = assetRepo.findAll(); final List<Asset> assets = assetRepo.findAll();
final List<Asset> orphaned = assets.stream() final List<Asset> orphaned = assets.stream()
.filter(asset -> asset.getCategories().isEmpty() .filter(asset -> asset.getCategories().isEmpty()
&& asset.getItemAttachments().isEmpty()). && asset.getItemAttachments().isEmpty()).
collect(Collectors.toList()); collect(Collectors.toList());
orphaned.forEach(orphan -> assetRepo.delete(orphan)); orphaned.forEach(orphan -> assetRepo.delete(orphan));
} }
@ -163,17 +162,17 @@ public class AssetManager {
/** /**
* Moves an {@link Asset} to an folder. * Moves an {@link Asset} to an folder.
* *
* @param asset The {@link Asset} to move. * @param asset The {@link Asset} to move.
* @param targetFolder The folder to which the {@link Asset} is moved. Must * @param targetFolder The folder to which the {@link Asset} is moved. Must
* be an asset folder. * be an asset folder.
*/ */
@AuthorizationRequired @AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public void move( public void move(
@RequiresPrivilege(AssetPrivileges.EDIT) @RequiresPrivilege(AssetPrivileges.EDIT)
final Asset asset, final Asset asset,
@RequiresPrivilege(AssetPrivileges.CREATE_NEW) @RequiresPrivilege(AssetPrivileges.CREATE_NEW)
final Folder targetFolder) { final Folder targetFolder) {
if (asset == null) { if (asset == null) {
throw new IllegalArgumentException("No asset to move provided."); throw new IllegalArgumentException("No asset to move provided.");
@ -185,8 +184,8 @@ public class AssetManager {
if (targetFolder.getType() != FolderType.ASSETS_FOLDER) { if (targetFolder.getType() != FolderType.ASSETS_FOLDER) {
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(
"The provided target folder %s is not an asset folder.", "The provided target folder %s is not an asset folder.",
Objects.toString(targetFolder))); Objects.toString(targetFolder)));
} }
final Optional<Folder> currentFolder = getAssetFolder(asset); final Optional<Folder> currentFolder = getAssetFolder(asset);
@ -196,7 +195,7 @@ public class AssetManager {
categoryManager.removeObjectFromCategory(asset, categoryManager.removeObjectFromCategory(asset,
currentFolder.get()); currentFolder.get());
} catch (ObjectNotAssignedToCategoryException ex) { } catch (ObjectNotAssignedToCategoryException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} }
@ -208,7 +207,7 @@ public class AssetManager {
/** /**
* Copies an {@link Asset}. * Copies an {@link Asset}.
* *
* @param asset The {@link Asset} to copy. * @param asset The {@link Asset} to copy.
* @param targetFolder The folder to which the {@link Asset} is copied. * @param targetFolder The folder to which the {@link Asset} is copied.
* *
* @return The copy of the {@code asset}. * @return The copy of the {@code asset}.
@ -230,26 +229,26 @@ public class AssetManager {
if (targetFolder.getType() != FolderType.ASSETS_FOLDER) { if (targetFolder.getType() != FolderType.ASSETS_FOLDER) {
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(
"The provided target folder %s is not an asset folder.", "The provided target folder %s is not an asset folder.",
Objects.toString(targetFolder))); Objects.toString(targetFolder)));
} }
final Asset copy; final Asset copy;
try { try {
copy = asset.getClass().newInstance(); copy = asset.getClass().newInstance();
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
final BeanInfo beanInfo; final BeanInfo beanInfo;
try { try {
beanInfo = Introspector.getBeanInfo(asset.getClass()); beanInfo = Introspector.getBeanInfo(asset.getClass());
} catch (IntrospectionException ex) { } catch (IntrospectionException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
for (final PropertyDescriptor propertyDescriptor : beanInfo for (final PropertyDescriptor propertyDescriptor : beanInfo
.getPropertyDescriptors()) { .getPropertyDescriptors()) {
if (propertyIsExcluded(propertyDescriptor.getName())) { if (propertyIsExcluded(propertyDescriptor.getName())) {
continue; continue;
} }
@ -269,49 +268,49 @@ public class AssetManager {
source = (LocalizedString) readMethod.invoke(asset); source = (LocalizedString) readMethod.invoke(asset);
target = (LocalizedString) readMethod.invoke(copy); target = (LocalizedString) readMethod.invoke(copy);
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
source.getAvailableLocales().forEach( source.getAvailableLocales().forEach(
locale -> target.addValue(locale, locale -> target.addValue(locale,
source.getValue(locale))); source.getValue(locale)));
} else if (propType != null } else if (propType != null
&& propType.isAssignableFrom(Asset.class)) { && propType.isAssignableFrom(Asset.class)) {
final Asset linkedAsset; final Asset linkedAsset;
try { try {
linkedAsset = (Asset) readMethod.invoke(asset); linkedAsset = (Asset) readMethod.invoke(asset);
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
try { try {
writeMethod.invoke(copy, linkedAsset); writeMethod.invoke(copy, linkedAsset);
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} else if (propType != null } else if (propType != null
&& propType.isAssignableFrom(List.class)) { && propType.isAssignableFrom(List.class)) {
final List<Object> source; final List<Object> source;
final List<Object> target; final List<Object> target;
try { try {
source = (List<Object>) readMethod.invoke(asset); source = (List<Object>) readMethod.invoke(asset);
target = (List<Object>) readMethod.invoke(copy); target = (List<Object>) readMethod.invoke(copy);
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
target.addAll(source); target.addAll(source);
} else if (propType != null } else if (propType != null
&& propType.isAssignableFrom(Map.class)) { && propType.isAssignableFrom(Map.class)) {
final Map<Object, Object> source; final Map<Object, Object> source;
final Map<Object, Object> target; final Map<Object, Object> target;
@ -319,14 +318,14 @@ public class AssetManager {
source = (Map<Object, Object>) readMethod.invoke(asset); source = (Map<Object, Object>) readMethod.invoke(asset);
target = (Map<Object, Object>) readMethod.invoke(copy); target = (Map<Object, Object>) readMethod.invoke(copy);
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new RuntimeException(ex); throw new UnexpectedErrorException(ex);
} }
source.forEach((key, value) -> target.put(key, value)); source.forEach((key, value) -> target.put(key, value));
} else if (propType != null } else if (propType != null
&& propType.isAssignableFrom(Set.class)) { && propType.isAssignableFrom(Set.class)) {
final Set<Object> source; final Set<Object> source;
final Set<Object> target; final Set<Object> target;
@ -334,8 +333,8 @@ public class AssetManager {
source = (Set<Object>) readMethod.invoke(asset); source = (Set<Object>) readMethod.invoke(asset);
target = (Set<Object>) readMethod.invoke(copy); target = (Set<Object>) readMethod.invoke(copy);
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
@ -346,17 +345,17 @@ public class AssetManager {
value = readMethod.invoke(asset); value = readMethod.invoke(asset);
writeMethod.invoke(copy, value); writeMethod.invoke(copy, value);
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} }
} }
if (targetFolder.equals(getAssetFolder(asset).orElse(null))) { if (targetFolder.equals(getAssetFolder(asset).orElse(null))) {
final long number = assetRepo.countFilterByFolderAndName( final long number = assetRepo.countFilterByFolderAndName(
targetFolder, String.format("%s_copy", targetFolder, String.format("%s_copy",
asset.getDisplayName())); asset.getDisplayName()));
final long index = number + 1; final long index = number + 1;
copy.setDisplayName(String.format("%s_copy%d", copy.setDisplayName(String.format("%s_copy%d",
copy.getDisplayName(), copy.getDisplayName(),
@ -395,7 +394,7 @@ public class AssetManager {
* @param asset The {@link Asset} to check for usage. * @param asset The {@link Asset} to check for usage.
* *
* @return {@code true} if the {@link Asset} is in use, {@link false} if * @return {@code true} if the {@link Asset} is in use, {@link false} if
* not. * not.
*/ */
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public boolean isAssetInUse(final Asset asset) { public boolean isAssetInUse(final Asset asset) {
@ -414,7 +413,7 @@ public class AssetManager {
* @param asset The {@link Assset} for which the path is generated. * @param asset The {@link Assset} for which the path is generated.
* *
* @return The path of the {@link Asset}. If the {@link Asset} is a non * @return The path of the {@link Asset}. If the {@link Asset} is a non
* shared asset the path is empty. * shared asset the path is empty.
* *
* @see #getAssetPath(org.librecms.assets.Asset, boolean) * @see #getAssetPath(org.librecms.assets.Asset, boolean)
*/ */
@ -425,23 +424,24 @@ public class AssetManager {
/** /**
* Returns the path of an item as String. * Returns the path of an item as String.
* *
* @param asset The {@link Asset} for which the path is generated. * @param asset The {@link Asset} for which the path is
* generated.
* @param withContentSection Whether to include the content section into the * @param withContentSection Whether to include the content section into the
* path or not. * path or not.
* *
* @return The path of the asset. For non shared assets this is an empty * @return The path of the asset. For non shared assets this is an empty
* string. * string.
* *
* @see #getAssetPath(org.librecms.assets.Asset) * @see #getAssetPath(org.librecms.assets.Asset)
*/ */
public String getAssetPath(final Asset asset, public String getAssetPath(final Asset asset,
final boolean withContentSection) { final boolean withContentSection) {
final List<Categorization> result = asset.getCategories().stream() final List<Categorization> result = asset.getCategories().stream()
.filter(categorization -> { .filter(categorization -> {
return CATEGORIZATION_TYPE_FOLDER.equals( return CATEGORIZATION_TYPE_FOLDER.equals(
categorization.getType()); categorization.getType());
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
if (result.isEmpty()) { if (result.isEmpty()) {
return ""; return "";
@ -459,9 +459,16 @@ public class AssetManager {
final String path = String.join("/", tokens); final String path = String.join("/", tokens);
if (withContentSection) { if (withContentSection) {
final String sectionName final Category category = result.get(0).getCategory();
= ((Folder) result.get(0).getCategory()). final Optional<Folder> folder = folderRepo.findById(
getSection().getDisplayName(); category.getObjectId());
final String sectionName;
if (folder.isPresent()) {
sectionName = folder.get().getSection().getDisplayName();
} else {
sectionName = "?";
}
return String.format("%s:/%s", sectionName, path); return String.format("%s:/%s", sectionName, path);
} else { } else {
return String.format("/%s", path); return String.format("/%s", path);
@ -475,15 +482,15 @@ public class AssetManager {
* @param asset * @param asset
* *
* @return A list of the folders which form the path of the asset. For non * @return A list of the folders which form the path of the asset. For non
* shared assets an empty list is returned. * shared assets an empty list is returned.
*/ */
public List<Folder> getAssetFolders(final Asset asset) { public List<Folder> getAssetFolders(final Asset asset) {
final List<Categorization> result = asset.getCategories().stream() final List<Categorization> result = asset.getCategories().stream()
.filter(categorization -> { .filter(categorization -> {
return CATEGORIZATION_TYPE_FOLDER.equals(categorization return CATEGORIZATION_TYPE_FOLDER.equals(categorization
.getType()); .getType());
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
final List<Folder> folders = new ArrayList<>(); final List<Folder> folders = new ArrayList<>();
if (!result.isEmpty()) { if (!result.isEmpty()) {
@ -492,12 +499,12 @@ public class AssetManager {
folders.add((Folder) current); folders.add((Folder) current);
} else { } else {
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(
"The asset %s is assigned to the category %s with the" "The asset %s is assigned to the category %s with the"
+ "categorization type \"%s\", but the Category is not" + "categorization type \"%s\", but the Category is not"
+ "a folder. This is no supported.", + "a folder. This is no supported.",
asset.getUuid(), asset.getUuid(),
current.getUuid(), current.getUuid(),
CATEGORIZATION_TYPE_FOLDER)); CATEGORIZATION_TYPE_FOLDER));
} }
while (current.getParentCategory() != null) { while (current.getParentCategory() != null) {
@ -506,12 +513,12 @@ public class AssetManager {
folders.add((Folder) current); folders.add((Folder) current);
} else { } else {
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(
"The asset %s is assigned to the category %s with the" "The asset %s is assigned to the category %s with the"
+ "categorization type \"%s\", but the Category is not" + "categorization type \"%s\", but the Category is not"
+ "a folder. This is no supported.", + "a folder. This is no supported.",
asset.getUuid(), asset.getUuid(),
current.getUuid(), current.getUuid(),
CATEGORIZATION_TYPE_FOLDER)); CATEGORIZATION_TYPE_FOLDER));
} }
} }
} }
@ -526,27 +533,29 @@ public class AssetManager {
* @param asset The asset. * @param asset The asset.
* *
* @return The folder in which the asset is placed. If the asset is a non * @return The folder in which the asset is placed. If the asset is a non
* shared asset an empty {@link Optional} is returned. * shared asset an empty {@link Optional} is returned.
*/ */
public Optional<Folder> getAssetFolder(final Asset asset) { public Optional<Folder> getAssetFolder(final Asset asset) {
if (asset == null) { if (asset == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Can't retrieve the folder for asset null."); "Can't retrieve the folder for asset null.");
} }
if (asset.getCategories() == null) { if (asset.getCategories() == null) {
return Optional.empty(); return Optional.empty();
} }
return asset.getCategories().stream() final Optional<Category> category = asset.getCategories().stream()
.filter(categorization -> { .filter(categorization -> CATEGORIZATION_TYPE_FOLDER.equals(
return CATEGORIZATION_TYPE_FOLDER.equals( categorization.getType()))
categorization.getType()); .map(categorization -> categorization.getCategory())
}) .findFirst();
.map(categorization -> {
return (Folder) categorization.getCategory(); if (category.isPresent()) {
}) return folderRepo.findById(category.get().getObjectId());
.findFirst(); } else {
return Optional.empty();
}
} }
} }

View File

@ -18,13 +18,13 @@
*/ */
package org.librecms.contentsection; package org.librecms.contentsection;
import com.arsdigita.util.UncheckedWrapperException;
import org.libreccm.auditing.AbstractAuditedEntityRepository; import org.libreccm.auditing.AbstractAuditedEntityRepository;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.ObjectNotAssignedToCategoryException; import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
import org.libreccm.core.CcmObjectRepository; import org.libreccm.core.CcmObjectRepository;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege; import org.libreccm.security.RequiresPrivilege;
import org.librecms.contentsection.privileges.AssetPrivileges; import org.librecms.contentsection.privileges.AssetPrivileges;
@ -130,7 +130,7 @@ public class AssetRepository
try { try {
categoryManager.removeObjectFromCategory(asset, category); categoryManager.removeObjectFromCategory(asset, category);
} catch (ObjectNotAssignedToCategoryException ex) { } catch (ObjectNotAssignedToCategoryException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} }

View File

@ -19,14 +19,13 @@
package org.librecms.contentsection; package org.librecms.contentsection;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.util.UncheckedWrapperException;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.security.RequiresPrivilege; import org.libreccm.security.RequiresPrivilege;
import org.librecms.CmsConstants;
import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.contentsection.privileges.ItemPrivileges;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
@ -91,7 +90,7 @@ public class ContentItemL10NManager {
LocalizedString.class)) LocalizedString.class))
.collect(Collectors.toList()); .collect(Collectors.toList());
} catch (IntrospectionException ex) { } catch (IntrospectionException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} }
@ -102,7 +101,7 @@ public class ContentItemL10NManager {
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} }

View File

@ -19,7 +19,6 @@
package org.librecms.contentsection; package org.librecms.contentsection;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.util.UncheckedWrapperException;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -42,6 +41,7 @@ import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.ObjectNotAssignedToCategoryException; import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege; import org.libreccm.security.RequiresPrivilege;
@ -68,8 +68,8 @@ import java.util.UUID;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.security.PermissionManager;
import org.librecms.contentsection.privileges.TypePrivileges; import org.librecms.contentsection.privileges.TypePrivileges;
/** /**
@ -615,7 +615,7 @@ public class ContentItemManager {
try { try {
target = source.getClass().newInstance(); target = source.getClass().newInstance();
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
copyAsset(source, target); copyAsset(source, target);
@ -655,7 +655,7 @@ public class ContentItemManager {
try { try {
beanInfo = Introspector.getBeanInfo(source.getClass()); beanInfo = Introspector.getBeanInfo(source.getClass());
} catch (IntrospectionException ex) { } catch (IntrospectionException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
for (final PropertyDescriptor propertyDescriptor : beanInfo. for (final PropertyDescriptor propertyDescriptor : beanInfo.
@ -685,7 +685,7 @@ public class ContentItemManager {
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
copyLocalizedString(sourceStr, targetStr); copyLocalizedString(sourceStr, targetStr);
@ -697,7 +697,7 @@ public class ContentItemManager {
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} }
} }
@ -860,7 +860,7 @@ public class ContentItemManager {
targetAsset = sourceAttachment.getAsset().getClass() targetAsset = sourceAttachment.getAsset().getClass()
.newInstance(); .newInstance();
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
copyAsset(sourceAsset, targetAsset); copyAsset(sourceAsset, targetAsset);

View File

@ -19,11 +19,11 @@
package org.librecms.contentsection; package org.librecms.contentsection;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.util.UncheckedWrapperException;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.CoreConstants; import org.libreccm.core.CoreConstants;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.Permission; import org.libreccm.security.Permission;
import org.libreccm.security.PermissionManager; import org.libreccm.security.PermissionManager;
@ -459,14 +459,14 @@ public class ContentSectionManager {
itemResolverClazz); itemResolverClazz);
if (instance.isUnsatisfied()) { if (instance.isUnsatisfied()) {
throw new UncheckedWrapperException(String.format( throw new UnexpectedErrorException(String.format(
"No ItemResolver \"{}\" found.", "No ItemResolver \"{}\" found.",
itemResolverClazz.getName())); itemResolverClazz.getName()));
} else { } else {
return instance.get(); return instance.get();
} }
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} }

View File

@ -107,14 +107,14 @@ public class Folder extends Category implements Serializable {
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
public Folder getParentFolder() { // public Folder getParentFolder() {
final Category parent = getParentCategory(); // final Category parent = getParentCategory();
if (parent == null) { // if (parent == null) {
return null; // return null;
} else { // } else {
return (Folder) getParentCategory(); // return (Folder) getParentCategory();
} // }
} // }
@Override @Override
public int hashCode() { public int hashCode() {

View File

@ -20,12 +20,14 @@ package org.librecms.contentsection;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.CategoryManager;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
@ -106,6 +108,15 @@ public class FolderManager {
HAS_LIVE_ITEMS HAS_LIVE_ITEMS
} }
public Optional<Folder> getParentFolder(final Folder folder) {
final Category parentCategory = folder.getParentCategory();
if (parentCategory == null) {
return Optional.empty();
} else {
return folderRepo.findById(parentCategory.getObjectId());
}
}
/** /**
* Creates new folder as sub folder of the provided parent folder. The type * Creates new folder as sub folder of the provided parent folder. The type
* and the content section to which the folder belongs are the same as for * and the content section to which the folder belongs are the same as for
@ -158,7 +169,7 @@ public class FolderManager {
return FolderIsDeletable.IS_NOT_EMPTY; return FolderIsDeletable.IS_NOT_EMPTY;
} }
if (folder.getParentFolder() == null) { if (!getParentFolder(folder).isPresent()) {
return FolderIsDeletable.IS_ROOT_FOLDER; return FolderIsDeletable.IS_ROOT_FOLDER;
} }
@ -225,7 +236,7 @@ public class FolderManager {
final FolderIsMovable status = folderIsMovable(folder, target); final FolderIsMovable status = folderIsMovable(folder, target);
switch (status) { switch (status) {
case YES: { case YES: {
final Folder source = folder.getParentFolder(); final Folder source = getParentFolder(folder).get();
categoryManager.removeSubCategoryFromCategory(folder, source); categoryManager.removeSubCategoryFromCategory(folder, source);
final boolean sameName = target.getSubCategories() final boolean sameName = target.getSubCategories()
.stream() .stream()
@ -348,7 +359,7 @@ public class FolderManager {
"Can't check if a server can be moved to null."); "Can't check if a server can be moved to null.");
} }
if (folder.getParentFolder() == null) { if (!getParentFolder(folder).isPresent()) {
return FolderIsMovable.IS_ROOT_FOLDER; return FolderIsMovable.IS_ROOT_FOLDER;
} }
@ -427,8 +438,8 @@ public class FolderManager {
tokens.add(folder.getName()); tokens.add(folder.getName());
Folder current = folder; Folder current = folder;
while (current.getParentFolder() != null) { while (getParentFolder(current).isPresent()) {
current = current.getParentFolder(); current = getParentFolder(current).get();
tokens.add(current.getName()); tokens.add(current.getName());
} }
@ -458,11 +469,11 @@ public class FolderManager {
} }
final List<Folder> folders = new ArrayList<>(); final List<Folder> folders = new ArrayList<>();
if (folder.getParentFolder() != null) { if (getParentFolder(folder).isPresent()) {
Folder currentFolder = folder.getParentFolder(); Optional<Folder> currentFolder = getParentFolder(folder);
while(currentFolder != null) { while(currentFolder.isPresent()) {
folders.add(currentFolder); folders.add(currentFolder.get());
currentFolder = folder.getParentFolder(); currentFolder = getParentFolder(currentFolder.get());
} }
} }

View File

@ -19,8 +19,8 @@
package org.librecms.workflow; package org.librecms.workflow;
import com.arsdigita.cms.workflow.TaskURLGenerator; import com.arsdigita.cms.workflow.TaskURLGenerator;
import com.arsdigita.util.UncheckedWrapperException;
import org.libreccm.core.UnexpectedErrorException;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
@ -48,7 +48,7 @@ public class CmsTaskManager {
urlGenerator = urlGeneratorClass.newInstance(); urlGenerator = urlGeneratorClass.newInstance();
} catch (IllegalAccessException } catch (IllegalAccessException
| InstantiationException ex) { | InstantiationException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
return urlGenerator.generateURL(item.getObjectId(), task.getTaskId()); return urlGenerator.generateURL(item.getObjectId(), task.getTaskId());

View File

@ -18,11 +18,10 @@
*/ */
package org.libreccm.pagemodel; package org.libreccm.pagemodel;
import com.arsdigita.util.UncheckedWrapperException;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.libreccm.core.CoreConstants; import org.libreccm.core.CoreConstants;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.modules.CcmModule; import org.libreccm.modules.CcmModule;
import org.libreccm.modules.Module; import org.libreccm.modules.Module;
import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.AuthorizationRequired;
@ -301,7 +300,7 @@ public class PageModelManager {
try { try {
liveModel = clazz.newInstance(); liveModel = clazz.newInstance();
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
liveModel.setModelUuid(draftModel.getModelUuid()); liveModel.setModelUuid(draftModel.getModelUuid());
@ -310,7 +309,7 @@ public class PageModelManager {
try { try {
beanInfo = Introspector.getBeanInfo(clazz); beanInfo = Introspector.getBeanInfo(clazz);
} catch (IntrospectionException ex) { } catch (IntrospectionException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
for (final PropertyDescriptor propertyDescriptor : beanInfo. for (final PropertyDescriptor propertyDescriptor : beanInfo.
@ -338,7 +337,7 @@ public class PageModelManager {
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
target.addAll(source); target.addAll(source);
@ -354,7 +353,7 @@ public class PageModelManager {
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
source.forEach((key, value) -> target.put(key, value)); source.forEach((key, value) -> target.put(key, value));
@ -371,7 +370,7 @@ public class PageModelManager {
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
target.addAll(source); target.addAll(source);
@ -383,7 +382,7 @@ public class PageModelManager {
} catch (IllegalAccessException } catch (IllegalAccessException
| IllegalArgumentException | IllegalArgumentException
| InvocationTargetException ex) { | InvocationTargetException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
} }
} }

View File

@ -35,9 +35,8 @@ import java.util.List;
/** /**
* Abstract class responsible for ex- and importing entity-objects to several * Abstract class responsible for ex- and importing entity-objects to several
* file-formats. Every entity-class (e.g. DocRepo.File) needs to have its own * file-formats. Every entity-class (e.g. DocRepo.File) needs to have its own
* extension of this class to override the abstract methods, making it * extension of this class to override the abstract methods, making it possible
* possible to ex- or import that extending entity-class (e.g. DocRepo * to ex- or import that extending entity-class (e.g. DocRepo .FileMarshal).
* .FileMarshal).
* *
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a> * @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created the 2/10/16 * @version created the 2/10/16
@ -45,8 +44,8 @@ import java.util.List;
*/ */
public abstract class AbstractMarshaller<P extends Portable> { public abstract class AbstractMarshaller<P extends Portable> {
private static final Logger LOGGER = LogManager.getLogger(AbstractMarshaller private static final Logger LOGGER = LogManager.getLogger(
.class); AbstractMarshaller.class);
private Format format; private Format format;
private String filename; private String filename;
@ -55,13 +54,13 @@ public abstract class AbstractMarshaller<P extends Portable> {
ObjectMapper xmlMapper; ObjectMapper xmlMapper;
/** /**
* Prepares import and export routine. Sets the format in which the ex- * Prepares import and export routine. Sets the format in which the ex- or
* or import will take place and sets the name of the file exported to or * import will take place and sets the name of the file exported to or
* imported from. Furthermore it is possible to decide for or against * imported from. Furthermore it is possible to decide for or against
* indentation in the output file. * indentation in the output file.
* *
* @param format The format of the ex-/import * @param format The format of the ex-/import
* @param filename The filename of the file exported to or imported from * @param filename The filename of the file exported to or imported from
* @param indentation whether or not indentation * @param indentation whether or not indentation
*/ */
public void prepare(final Format format, public void prepare(final Format format,
@ -83,20 +82,19 @@ public abstract class AbstractMarshaller<P extends Portable> {
break; break;
default: default:
break; break;
} }
} }
/** /**
* Same as {@code prepare}-methode above. Adds distinction between path * Same as {@code prepare}-methode above. Adds distinction between path and
* and filename. * filename.
* *
* @param format The format of the ex-/import * @param format The format of the ex-/import
* @param folderPath The folderPath of the file exported to or imported * @param folderPath The folderPath of the file exported to or imported
* from * from
* @param filename The filename of the file exported to or imported from * @param filename The filename of the file exported to or imported from
* @param indentation whether or not indentation * @param indentation whether or not indentation
*/ */
public void prepare(final Format format, public void prepare(final Format format,
@ -108,7 +106,6 @@ public abstract class AbstractMarshaller<P extends Portable> {
} }
} }
/** /**
* Export routine for lists with the same object type {@code P}. Creates a * Export routine for lists with the same object type {@code P}. Creates a
* new file with the prepared filename and starts, depending on the set * new file with the prepared filename and starts, depending on the set
@ -123,8 +120,8 @@ public abstract class AbstractMarshaller<P extends Portable> {
try { try {
fileWriter = new FileWriter(file); fileWriter = new FileWriter(file);
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Unable to open a fileWriter for the file" + LOGGER.error("Unable to open a fileWriter for the file"
" with the name {}.", file.getName()); + " with the name {}.", file.getName());
LOGGER.error(e); LOGGER.error(e);
} }
if (fileWriter != null) { if (fileWriter != null) {
@ -137,9 +134,9 @@ public abstract class AbstractMarshaller<P extends Portable> {
line = xmlMapper.writeValueAsString(object); line = xmlMapper.writeValueAsString(object);
//LOGGER.info(line); //LOGGER.info(line);
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Unable to write objetct " + LOGGER.error("Unable to write objetct "
"of class {} as XML string with name {}.", + "of class {} as XML string with name {}.",
object.getClass(), file.getName()); object.getClass(), file.getName());
LOGGER.error(e); LOGGER.error(e);
} }
break; break;
@ -152,8 +149,8 @@ public abstract class AbstractMarshaller<P extends Portable> {
fileWriter.write(line); fileWriter.write(line);
fileWriter.write(System.getProperty("line.separator")); fileWriter.write(System.getProperty("line.separator"));
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Unable to write to file with" + LOGGER.error("Unable to write to file with"
" the name {}.", file.getName()); + " the name {}.", file.getName());
LOGGER.error(e); LOGGER.error(e);
} }
} }
@ -161,8 +158,8 @@ public abstract class AbstractMarshaller<P extends Portable> {
try { try {
fileWriter.close(); fileWriter.close();
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Unable to close a fileWriter for the" + LOGGER.error("Unable to close a fileWriter for the"
" file with the name {}.", file.getName()); + " file with the name {}.", file.getName());
LOGGER.error(e); LOGGER.error(e);
} }
} }
@ -170,8 +167,8 @@ public abstract class AbstractMarshaller<P extends Portable> {
/** /**
* Import routine for files containing objects of the same type {@code P}. * Import routine for files containing objects of the same type {@code P}.
* Creates a new list of strings to read the file line by line. Each line * Creates a new list of strings to read the file line by line. Each line of
* of the list represents an object of the file. Then retrieves each object * the list represents an object of the file. Then retrieves each object
* from the corresponding string in the list. * from the corresponding string in the list.
* *
* @return If error occurs true, otherwise false. * @return If error occurs true, otherwise false.
@ -184,8 +181,8 @@ public abstract class AbstractMarshaller<P extends Portable> {
try { try {
lines = Files.readAllLines(file.toPath()); lines = Files.readAllLines(file.toPath());
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Unable to read lines of the file with " + LOGGER.error("Unable to read lines of the file with " + "name {}.",
"name {}.", file.getName()); file.getName());
LOGGER.error(e); LOGGER.error(e);
error = true; error = true;
} }
@ -200,8 +197,8 @@ public abstract class AbstractMarshaller<P extends Portable> {
try { try {
object = xmlMapper.readValue(line, getObjectClass()); object = xmlMapper.readValue(line, getObjectClass());
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Unable to read objects " + LOGGER.error("Unable to read objects "
"from XML line:\n \"{}\"", line); + "from XML line:\n \"{}\"", line);
LOGGER.error(e); LOGGER.error(e);
error = true; error = true;
} }
@ -215,7 +212,7 @@ public abstract class AbstractMarshaller<P extends Portable> {
insertIntoDb(object); insertIntoDb(object);
objects.add(object); objects.add(object);
} else { } else {
emptyObjects+=1; emptyObjects += 1;
LOGGER.info("Count of empty objects: {}", emptyObjects); LOGGER.info("Count of empty objects: {}", emptyObjects);
error = true; error = true;
} }
@ -237,4 +234,5 @@ public abstract class AbstractMarshaller<P extends Portable> {
* @param portableObject An object of type {@code P} * @param portableObject An object of type {@code P}
*/ */
protected abstract void insertIntoDb(P portableObject); protected abstract void insertIntoDb(P portableObject);
} }

View File

@ -18,7 +18,6 @@
*/ */
package org.libreccm.security; package org.libreccm.security;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.List; import java.util.List;
@ -29,6 +28,7 @@ import javax.persistence.TypedQuery;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.core.CoreConstants; import org.libreccm.core.CoreConstants;
import org.libreccm.core.UnexpectedErrorException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -241,7 +241,7 @@ public class PermissionManager {
try { try {
value = field.get(owner); value = field.get(owner);
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
throw new UncheckedWrapperException(ex); throw new UnexpectedErrorException(ex);
} }
if (value == null) { if (value == null) {

View File

@ -45,10 +45,15 @@ public class RoleMembershipMarshaller extends AbstractMarshaller<RoleMembership>
@Override @Override
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
protected void insertIntoDb(RoleMembership portableObject) { protected void insertIntoDb(RoleMembership portableObject) {
// if (portableObject.getMembershipId() == 0) { // if (portableObject.getMembershipId() == 0) {
entityManager.persist(portableObject); // portableObject.setMembershipId(0);
portableObject.setMembershipId(portableObject.getMembershipId() * -1);
// entityManager.persist(portableObject);
entityManager.merge(portableObject);
// } else { // } else {
// entityManager.merge(portableObject); // entityManager.merge(portableObject);
// } // }
} }
} }

View File

@ -119,7 +119,6 @@ public class CcmObjectRepositoryTest {
.addPackage(org.libreccm.web.CcmApplication.class.getPackage()) .addPackage(org.libreccm.web.CcmApplication.class.getPackage())
.addPackage(org.libreccm.workflow.Workflow.class.getPackage()) .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addClass(com.arsdigita.util.UncheckedWrapperException.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",
"META-INF/persistence.xml") "META-INF/persistence.xml")

View File

@ -108,8 +108,6 @@ public class CoreDataImportTest {
.class.getPackage()) .class.getPackage())
.addPackage(org.libreccm.jpa.EntityManagerProducer .addPackage(org.libreccm.jpa.EntityManagerProducer
.class.getPackage()) .class.getPackage())
.addClass(com.arsdigita.util.UncheckedWrapperException
.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",
"META-INF/persistence.xml") "META-INF/persistence.xml")

View File

@ -55,7 +55,7 @@ import javax.inject.Inject;
*/ */
@RequestScoped @RequestScoped
class ImportHelper { class ImportHelper {
private String repoPath = "/home/tosmers/Svn/libreccm/"; private String repoPath = "/home/jensp/pwi/libreccm/ccm/";
//private String repoPath = ""; //private String repoPath = "";
private String projectPath = "ccm_ng/ccm-core/src/test/resources/" + private String projectPath = "ccm_ng/ccm-core/src/test/resources/" +
"portation/trunk-iaw-exports"; "portation/trunk-iaw-exports";

View File

@ -121,8 +121,6 @@ public class AuthorizationInterceptorTest {
.getPackage()) .getPackage())
.addPackage(com.arsdigita.runtime.CCMResourceManager.class .addPackage(com.arsdigita.runtime.CCMResourceManager.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage())
.addPackage(com.arsdigita.web.CCMApplicationContextListener.class .addPackage(com.arsdigita.web.CCMApplicationContextListener.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.xml.XML.class.getPackage()) .addPackage(com.arsdigita.xml.XML.class.getPackage())
@ -130,6 +128,7 @@ public class AuthorizationInterceptorTest {
.getPackage()) .getPackage())
.addClass(com.arsdigita.kernel.KernelConfig.class) .addClass(com.arsdigita.kernel.KernelConfig.class)
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addClass(com.arsdigita.util.UncheckedWrapperException.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",
"META-INF/persistence.xml") "META-INF/persistence.xml")

View File

@ -118,8 +118,6 @@ public class GroupManagerTest {
.addPackage(org.libreccm.workflow.Workflow.class.getPackage()) .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addPackage(com.arsdigita.kernel.security.SecurityConfig.class .addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage())
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage()) .addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
.addClass(com.arsdigita.kernel.KernelConfig.class) .addClass(com.arsdigita.kernel.KernelConfig.class)
.addClass(com.arsdigita.kernel.security.SecurityConfig.class) .addClass(com.arsdigita.kernel.security.SecurityConfig.class)

View File

@ -122,7 +122,6 @@ public class GroupRepositoryTest {
.addPackage(org.libreccm.tests.categories.IntegrationTest.class .addPackage(org.libreccm.tests.categories.IntegrationTest.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addClass(com.arsdigita.util.UncheckedWrapperException.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("configs/shiro.ini", "shiro.ini") .addAsResource("configs/shiro.ini", "shiro.ini")
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",

View File

@ -129,8 +129,6 @@ public class PermissionCheckerTest {
.getPackage()) .getPackage())
.addPackage(com.arsdigita.kernel.security.SecurityConfig.class .addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",

View File

@ -129,8 +129,6 @@ public class PermissionManagerTest {
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()). .addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()).
addPackage(com.arsdigita.kernel.security.SecurityConfig.class addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage())
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage()) .addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())

View File

@ -117,8 +117,6 @@ public class RoleManagerTest {
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()) .addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage())
.addPackage(com.arsdigita.kernel.security.SecurityConfig.class .addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage())
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage()) .addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())

View File

@ -128,7 +128,6 @@ public class RoleRepositoryTest {
.addPackage(org.libreccm.tests.categories.IntegrationTest.class .addPackage(org.libreccm.tests.categories.IntegrationTest.class
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addClass(com.arsdigita.util.UncheckedWrapperException.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("configs/shiro.ini", "shiro.ini") .addAsResource("configs/shiro.ini", "shiro.ini")
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",

View File

@ -145,8 +145,6 @@ public class SecuredCollectionTest {
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()) .addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage())
.addPackage(com.arsdigita.kernel.security.SecurityConfig.class .addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",

View File

@ -147,8 +147,6 @@ public class SecuredIteratorTest {
.addPackage(com.arsdigita.kernel.security.SecurityConfig.class .addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()) .addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",

View File

@ -121,7 +121,6 @@ public class ShiroTest {
.getPackage()) .getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addClass(org.libreccm.security.authorization.LabBean.class) .addClass(org.libreccm.security.authorization.LabBean.class)
.addClass(com.arsdigita.util.UncheckedWrapperException.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",
"META-INF/persistence.xml") "META-INF/persistence.xml")

View File

@ -120,8 +120,6 @@ public class UserManagerTest {
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()) .addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage())
.addPackage(com.arsdigita.kernel.security.SecurityConfig.class .addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage())
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage()) .addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())