Skip to content

Commit 1032860

Browse files
committed
Bug #14391
In Kmelia: when updating a folder within which the local rights are enabled, the admin specific rights of the folder are then initialized with the admin rights inherited from the parent folder. This behavior is then coherent with the creation of a new folder with specific rights.
1 parent 5545434 commit 1032860

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

kmelia/kmelia-war/src/main/java/org/silverpeas/components/kmelia/control/KmeliaSessionController.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,27 @@ public synchronized void flushTrashCan() {
741741
indexOfFirstPubToDisplay = 0;
742742
}
743743

744+
/**
745+
* Update the specified topic. If the local rights of the topic are enabled, then from the
746+
* inherited rights, only the admin ones are kept.
747+
* @param topic the topic to update with the updated data
748+
* @param alertType the type of notification: notify all the users ("All"), only the publishers
749+
* ("publisher"), or nobody ("None").
750+
*/
751+
public synchronized void updateTopic(NodeDetail topic, String alertType) {
752+
NodeDetail previousTopic = getNodeHeader(topic.getId());
753+
updateTopicHeader(topic, alertType);
754+
if (!previousTopic.haveLocalRights() && topic.haveLocalRights()) {
755+
initTopicSpecificAdminProfiles(topic.getNodePK(), topic.getFatherPK());
756+
}
757+
}
758+
759+
/**
760+
* Update only header information about the specified topic.
761+
* @param nd the topic to update with the updated data
762+
* @param alertType the type of notification: notify all the users ("All"), only the publishers
763+
* ("publisher"), or nobody ("None").
764+
*/
744765
public synchronized void updateTopicHeader(NodeDetail nd, String alertType) {
745766
nd.getNodePK().setSpace(getSpaceId());
746767
nd.getNodePK().setComponentName(getComponentId());
@@ -763,12 +784,19 @@ public synchronized NodePK addSubTopic(NodeDetail nd, String alertType, String p
763784
nd.getNodePK().setSpace(getSpaceId());
764785
nd.getNodePK().setComponentName(getComponentId());
765786
nd.setCreatorId(getUserId());
766-
NodePK pk = getKmeliaService().addSubTopic(getNodePK(parentId), nd, alertType);
787+
NodePK parentPk = getNodePK(parentId);
788+
NodePK pk = getKmeliaService().addSubTopic(parentPk, nd, alertType);
789+
initTopicSpecificAdminProfiles(pk, parentPk);
790+
791+
return pk;
792+
}
767793

794+
private void initTopicSpecificAdminProfiles(NodePK pk, NodePK parentPk) {
768795
// by default, sets father's admin rights in the case of specific rights
769796
// to prevent no access to users having some rights with the father topic
770-
NodeDetail created = getNodeHeader(pk.getId());
771-
if (created.haveLocalRights()) {
797+
NodeDetail node = getNodeHeader(pk.getId());
798+
String parentId = parentPk.getId();
799+
if (node.haveLocalRights()) {
772800
ProfileInst parentProfile;
773801
String profileAdmin = SilverpeasRole.ADMIN.getName();
774802
if (NodePK.ROOT_NODE_ID.equals(parentId)) {
@@ -782,8 +810,6 @@ public synchronized NodePK addSubTopic(NodeDetail nd, String alertType, String p
782810
parentProfile.getAllUsers().toArray(new String[0]));
783811
}
784812
}
785-
786-
return pk;
787813
}
788814

789815
public synchronized String deleteTopic(String topicId) {

kmelia/kmelia-war/src/main/java/org/silverpeas/components/kmelia/servlets/KmeliaRequestRouter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public String getDestination(String function, KmeliaSessionController kmelia,
135135
boolean kmaxMode = false;
136136
boolean toolboxMode;
137137
SilverpeasRole highestSilverpeasUserRoleOnCurrentTopic =
138-
getHighestSilverpeasUserRoleOnCurrentTopic(kmelia, function);
138+
getHighestSilverpeasUserRoleOnCurrentTopic(kmelia);
139139
try {
140140
if ("kmax".equals(kmelia.getComponentRootName())) {
141141
kmaxMode = true;
@@ -503,7 +503,7 @@ public String getDestination(String function, KmeliaSessionController kmelia,
503503
goToProfilesDefinition = true;
504504
}
505505
}
506-
kmelia.updateTopicHeader(topic, alertType);
506+
kmelia.updateTopic(topic, alertType);
507507

508508
if (goToProfilesDefinition) {
509509
request.setAttribute("NodeId", id);
@@ -1487,7 +1487,7 @@ else if (function.equals("KmaxMain")) {
14871487

14881488
@NonNull
14891489
private static SilverpeasRole getHighestSilverpeasUserRoleOnCurrentTopic(
1490-
KmeliaSessionController kmelia, String function) {
1490+
KmeliaSessionController kmelia) {
14911491
return SilverpeasRole.fromString(kmelia.getUserTopicProfile(kmelia.getCurrentFolderId()));
14921492
}
14931493

0 commit comments

Comments
 (0)