Item permissisons were not copied when publishing an item.
parent
4f48eb9354
commit
5bafec04a3
|
|
@ -40,6 +40,7 @@ import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
|
|||
import org.libreccm.core.UnexpectedErrorException;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.libreccm.security.Permission;
|
||||
import org.libreccm.security.RequiresPrivilege;
|
||||
import org.libreccm.workflow.Workflow;
|
||||
import org.libreccm.workflow.WorkflowManager;
|
||||
|
|
@ -945,8 +946,14 @@ public class ContentItemManager {
|
|||
liveItem = getLiveVersion(item, ContentItem.class).get();
|
||||
} else {
|
||||
try {
|
||||
liveItem = draftItem.getClass().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException ex) {
|
||||
liveItem = draftItem
|
||||
.getClass()
|
||||
.getDeclaredConstructor()
|
||||
.newInstance();
|
||||
} catch (IllegalAccessException
|
||||
| InstantiationException
|
||||
| InvocationTargetException
|
||||
| NoSuchMethodException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -1149,9 +1156,15 @@ public class ContentItemManager {
|
|||
targetAsset = sourceAttachment.getAsset();
|
||||
} else {
|
||||
try {
|
||||
targetAsset = sourceAttachment.getAsset().getClass()
|
||||
targetAsset = sourceAttachment
|
||||
.getAsset()
|
||||
.getClass()
|
||||
.getDeclaredConstructor()
|
||||
.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException ex) {
|
||||
} catch (IllegalAccessException
|
||||
| InstantiationException
|
||||
| InvocationTargetException
|
||||
| NoSuchMethodException ex) {
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
copyAsset(sourceAsset, targetAsset);
|
||||
|
|
@ -1172,6 +1185,48 @@ public class ContentItemManager {
|
|||
}
|
||||
}
|
||||
|
||||
final List<Permission> permissionsOnDraftItem = draftItem
|
||||
.getPermissions();
|
||||
final List<Permission> grantOnLiveItem = permissionsOnDraftItem
|
||||
.stream()
|
||||
.filter(
|
||||
permission -> !permissionChecker
|
||||
.isPermitted(
|
||||
permission.getGrantedPrivilege(),
|
||||
liveItem,
|
||||
permission.getGrantee()
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final List<Permission> revokeFromLiveItem = liveItem
|
||||
.getPermissions()
|
||||
.stream()
|
||||
.filter(
|
||||
permission -> !permissionChecker
|
||||
.isPermitted(
|
||||
permission.getGrantedPrivilege(),
|
||||
draftItem,
|
||||
permission.getGrantee()
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (final Permission permission : grantOnLiveItem) {
|
||||
permissionManager.grantPrivilege(
|
||||
permission.getGrantedPrivilege(),
|
||||
permission.getGrantee(),
|
||||
liveItem
|
||||
);
|
||||
}
|
||||
for (final Permission permission : revokeFromLiveItem) {
|
||||
permissionManager.revokePrivilege(
|
||||
permission.getGrantedPrivilege(),
|
||||
permission.getGrantee(),
|
||||
liveItem
|
||||
);
|
||||
}
|
||||
|
||||
return liveItem;
|
||||
}
|
||||
|
||||
|
|
@ -1256,12 +1311,13 @@ public class ContentItemManager {
|
|||
|
||||
entityManager.remove(liveItem);
|
||||
}
|
||||
|
||||
|
||||
private void unpublishAttachmentList(final AttachmentList attachmentList) {
|
||||
for(final ItemAttachment<?> attachment : attachmentList.getAttachments()) {
|
||||
for (final ItemAttachment<?> attachment : attachmentList
|
||||
.getAttachments()) {
|
||||
unpublishAttachment(attachment);
|
||||
}
|
||||
|
||||
|
||||
final ContentItem item = attachmentList.getItem();
|
||||
attachmentList.setItem(null);
|
||||
item.removeAttachmentList(attachmentList);
|
||||
|
|
|
|||
|
|
@ -44,8 +44,10 @@ public abstract class AbstractContentItemListItemModelBuilder<T extends ContentI
|
|||
contentItem.getDescription()
|
||||
)
|
||||
);
|
||||
globalizationHelper.getValueFromLocalizedString(
|
||||
contentItem.getName()
|
||||
model.setName(
|
||||
globalizationHelper.getValueFromLocalizedString(
|
||||
contentItem.getName()
|
||||
)
|
||||
);
|
||||
model.setDisplayName(contentItem.getDisplayName());
|
||||
model.setTitle(
|
||||
|
|
@ -56,12 +58,12 @@ public abstract class AbstractContentItemListItemModelBuilder<T extends ContentI
|
|||
model.setUuid(contentItem.getUuid());
|
||||
|
||||
addProperties((T) contentItem, model);
|
||||
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
protected abstract M buildModel();
|
||||
|
||||
|
||||
protected void addProperties(final T contentItem, final M model) {
|
||||
// Nothing in the default implementation.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ public class ItemListModel {
|
|||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<? extends AbstractContentItemListItemModel> getItems() {
|
||||
if (itemList == null) {
|
||||
// if (itemList == null) {
|
||||
buildList(
|
||||
buildLimitToType(limitToType),
|
||||
collectCategories(
|
||||
|
|
@ -182,7 +182,7 @@ public class ItemListModel {
|
|||
listOrder,
|
||||
pageSize
|
||||
);
|
||||
}
|
||||
// }
|
||||
|
||||
return Collections.unmodifiableList(itemList);
|
||||
}
|
||||
|
|
@ -196,8 +196,7 @@ public class ItemListModel {
|
|||
final CriteriaBuilder criteriaBuilder = entityManager
|
||||
.getCriteriaBuilder();
|
||||
final CriteriaQuery<? extends ContentItem> criteriaQuery
|
||||
= criteriaBuilder
|
||||
.createQuery(limitToType);
|
||||
= criteriaBuilder.createQuery(limitToType);
|
||||
final Root<? extends ContentItem> from = criteriaQuery
|
||||
.from(limitToType);
|
||||
final Join<? extends ContentItem, Categorization> catJoin = from
|
||||
|
|
@ -211,7 +210,7 @@ public class ItemListModel {
|
|||
criteriaBuilder.and(
|
||||
catJoin.get("category").in(categories),
|
||||
criteriaBuilder.equal(catJoin.get("indexObject"), false),
|
||||
criteriaBuilder.equal(catJoin.get("type"), ""),
|
||||
criteriaBuilder.isNull(catJoin.get("type")),
|
||||
criteriaBuilder.equal(
|
||||
from.get("version"), ContentItemVersion.LIVE
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue