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.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.Permission;
|
||||||
import org.libreccm.security.RequiresPrivilege;
|
import org.libreccm.security.RequiresPrivilege;
|
||||||
import org.libreccm.workflow.Workflow;
|
import org.libreccm.workflow.Workflow;
|
||||||
import org.libreccm.workflow.WorkflowManager;
|
import org.libreccm.workflow.WorkflowManager;
|
||||||
|
|
@ -945,8 +946,14 @@ public class ContentItemManager {
|
||||||
liveItem = getLiveVersion(item, ContentItem.class).get();
|
liveItem = getLiveVersion(item, ContentItem.class).get();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
liveItem = draftItem.getClass().newInstance();
|
liveItem = draftItem
|
||||||
} catch (InstantiationException | IllegalAccessException ex) {
|
.getClass()
|
||||||
|
.getDeclaredConstructor()
|
||||||
|
.newInstance();
|
||||||
|
} catch (IllegalAccessException
|
||||||
|
| InstantiationException
|
||||||
|
| InvocationTargetException
|
||||||
|
| NoSuchMethodException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1149,9 +1156,15 @@ public class ContentItemManager {
|
||||||
targetAsset = sourceAttachment.getAsset();
|
targetAsset = sourceAttachment.getAsset();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
targetAsset = sourceAttachment.getAsset().getClass()
|
targetAsset = sourceAttachment
|
||||||
|
.getAsset()
|
||||||
|
.getClass()
|
||||||
|
.getDeclaredConstructor()
|
||||||
.newInstance();
|
.newInstance();
|
||||||
} catch (InstantiationException | IllegalAccessException ex) {
|
} catch (IllegalAccessException
|
||||||
|
| InstantiationException
|
||||||
|
| InvocationTargetException
|
||||||
|
| NoSuchMethodException ex) {
|
||||||
throw new UnexpectedErrorException(ex);
|
throw new UnexpectedErrorException(ex);
|
||||||
}
|
}
|
||||||
copyAsset(sourceAsset, targetAsset);
|
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;
|
return liveItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1258,7 +1313,8 @@ public class ContentItemManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unpublishAttachmentList(final AttachmentList attachmentList) {
|
private void unpublishAttachmentList(final AttachmentList attachmentList) {
|
||||||
for(final ItemAttachment<?> attachment : attachmentList.getAttachments()) {
|
for (final ItemAttachment<?> attachment : attachmentList
|
||||||
|
.getAttachments()) {
|
||||||
unpublishAttachment(attachment);
|
unpublishAttachment(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,10 @@ public abstract class AbstractContentItemListItemModelBuilder<T extends ContentI
|
||||||
contentItem.getDescription()
|
contentItem.getDescription()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
globalizationHelper.getValueFromLocalizedString(
|
model.setName(
|
||||||
contentItem.getName()
|
globalizationHelper.getValueFromLocalizedString(
|
||||||
|
contentItem.getName()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
model.setDisplayName(contentItem.getDisplayName());
|
model.setDisplayName(contentItem.getDisplayName());
|
||||||
model.setTitle(
|
model.setTitle(
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ public class ItemListModel {
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public List<? extends AbstractContentItemListItemModel> getItems() {
|
public List<? extends AbstractContentItemListItemModel> getItems() {
|
||||||
if (itemList == null) {
|
// if (itemList == null) {
|
||||||
buildList(
|
buildList(
|
||||||
buildLimitToType(limitToType),
|
buildLimitToType(limitToType),
|
||||||
collectCategories(
|
collectCategories(
|
||||||
|
|
@ -182,7 +182,7 @@ public class ItemListModel {
|
||||||
listOrder,
|
listOrder,
|
||||||
pageSize
|
pageSize
|
||||||
);
|
);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return Collections.unmodifiableList(itemList);
|
return Collections.unmodifiableList(itemList);
|
||||||
}
|
}
|
||||||
|
|
@ -196,8 +196,7 @@ public class ItemListModel {
|
||||||
final CriteriaBuilder criteriaBuilder = entityManager
|
final CriteriaBuilder criteriaBuilder = entityManager
|
||||||
.getCriteriaBuilder();
|
.getCriteriaBuilder();
|
||||||
final CriteriaQuery<? extends ContentItem> criteriaQuery
|
final CriteriaQuery<? extends ContentItem> criteriaQuery
|
||||||
= criteriaBuilder
|
= criteriaBuilder.createQuery(limitToType);
|
||||||
.createQuery(limitToType);
|
|
||||||
final Root<? extends ContentItem> from = criteriaQuery
|
final Root<? extends ContentItem> from = criteriaQuery
|
||||||
.from(limitToType);
|
.from(limitToType);
|
||||||
final Join<? extends ContentItem, Categorization> catJoin = from
|
final Join<? extends ContentItem, Categorization> catJoin = from
|
||||||
|
|
@ -211,7 +210,7 @@ public class ItemListModel {
|
||||||
criteriaBuilder.and(
|
criteriaBuilder.and(
|
||||||
catJoin.get("category").in(categories),
|
catJoin.get("category").in(categories),
|
||||||
criteriaBuilder.equal(catJoin.get("indexObject"), false),
|
criteriaBuilder.equal(catJoin.get("indexObject"), false),
|
||||||
criteriaBuilder.equal(catJoin.get("type"), ""),
|
criteriaBuilder.isNull(catJoin.get("type")),
|
||||||
criteriaBuilder.equal(
|
criteriaBuilder.equal(
|
||||||
from.get("version"), ContentItemVersion.LIVE
|
from.get("version"), ContentItemVersion.LIVE
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue