Skip to content

Commit 368ac48

Browse files
committed
Merge branch 'master' into feature-2815-3146
Conflicts: kmelia/kmelia-ejb/src/main/java/com/stratelia/webactiv/kmelia/control/ejb/KmeliaBmEJB.java kmelia/kmelia-war/src/main/webapp/kmelia/jsp/simpleListOfPublications.jsp
2 parents e4e5c69 + aecadc6 commit 368ac48

File tree

19 files changed

+343
-305
lines changed

19 files changed

+343
-305
lines changed

gallery/gallery-ejb/src/main/java/com/silverpeas/gallery/process/GalleryProcessManagement.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Collection;
2828
import java.util.Date;
2929

30+
import org.apache.commons.fileupload.FileItem;
3031
import org.silverpeas.process.util.ProcessList;
3132

3233
import com.silverpeas.gallery.ImageType;
@@ -47,7 +48,6 @@
4748
import com.silverpeas.gallery.process.photo.GalleryPastePhotoFileProcess;
4849
import com.silverpeas.gallery.process.photo.GalleryUpdatePhotoDataProcess;
4950
import com.silverpeas.gallery.process.photo.GalleryUpdatePhotoFileProcess;
50-
5151
import com.stratelia.webactiv.beans.admin.UserDetail;
5252
import com.stratelia.webactiv.util.DateUtil;
5353
import com.stratelia.webactiv.util.EJBUtilitaire;
@@ -57,8 +57,6 @@
5757
import com.stratelia.webactiv.util.node.model.NodeDetail;
5858
import com.stratelia.webactiv.util.node.model.NodePK;
5959

60-
import org.apache.commons.fileupload.FileItem;
61-
6260
/**
6361
* @author Yohann Chastagnier
6462
*/
@@ -301,7 +299,17 @@ public void addDeleteAlbumProcesses(final NodePK albumPk) throws Exception {
301299
*/
302300
private void addDeletePhotoAlbumProcesses(final NodePK albumPk) throws Exception {
303301
for (final PhotoDetail photo : getGalleryBm().getAllPhoto(albumPk, true)) {
304-
addDeletePhotoProcesses(photo);
302+
Collection<String> albumIds =
303+
getGalleryBm().getPathList(photo.getInstanceId(), photo.getId());
304+
if (albumIds.size() >= 2) {
305+
// the image is in several albums
306+
// delete only the link between it and album to delete
307+
albumIds.remove(albumPk.getId());
308+
getGalleryBm().setPhotoPath(photo.getId(), photo.getInstanceId(),
309+
albumIds.toArray(new String[0]));
310+
} else {
311+
addDeletePhotoProcesses(photo);
312+
}
305313
}
306314
}
307315

kmelia/kmelia-ejb/src/main/java/com/silverpeas/kmelia/notification/AbstractKmeliaPublicationUserNotification.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.silverpeas.notification.model.NotificationResourceData;
2727
import com.silverpeas.util.template.SilverpeasTemplate;
2828
import com.stratelia.silverpeas.notificationManager.constant.NotifAction;
29+
import com.stratelia.webactiv.beans.admin.UserDetail;
2930
import com.stratelia.webactiv.kmelia.control.ejb.KmeliaHelper;
3031
import com.stratelia.webactiv.util.node.model.NodePK;
3132
import com.stratelia.webactiv.util.publication.model.PublicationDetail;
@@ -115,7 +116,11 @@ protected String getSender() {
115116
if (NotifAction.REPORT.equals(action)) {
116117
return null;
117118
} else if (NotifAction.CREATE.equals(action)) {
118-
return getResource().getCreatorId();
119+
String userId = getResource().getCreatorId();
120+
if (UserDetail.getById(userId).isDeletedState()) {
121+
return getResource().getUpdaterId();
122+
}
123+
return userId;
119124
}
120125
return getResource().getUpdaterId();
121126
}

kmelia/kmelia-ejb/src/main/java/com/stratelia/webactiv/kmelia/KmeliaSecurity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ protected boolean isPublicationAvailable(PublicationPK pk, String userId) {
260260
+ pk.getInstanceId() + ")");
261261
objectAvailable = false;
262262
}
263+
} else {
264+
objectAvailable = true;
263265
}
264266
if (objectAvailable) {
265267
break;

kmelia/kmelia-ejb/src/main/java/com/stratelia/webactiv/kmelia/control/ejb/KmeliaBmEJB.java

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,38 @@ private void topicCreationAlert(final NodePK nodePK, final NodePK fatherPK, fina
497497
public NodePK updateTopic(NodeDetail topic, String alertType) {
498498
try {
499499
// Order of the node must be unchanged
500-
NodeDetail node = nodeBm.getHeader(topic.getNodePK());
501-
int order = node.getOrder();
500+
NodeDetail oldNode = nodeBm.getHeader(topic.getNodePK());
501+
int order = oldNode.getOrder();
502502
topic.setOrder(order);
503503
nodeBm.setDetail(topic);
504+
505+
// manage operations relative to folder rights
506+
if (isRightsOnTopicsEnabled(topic.getNodePK().getInstanceId())) {
507+
if (oldNode.getRightsDependsOn() != topic.getRightsDependsOn()) {
508+
// rights dependency have changed
509+
if (!topic.haveRights()) {
510+
511+
NodeDetail father = nodeBm.getHeader(oldNode.getFatherPK());
512+
topic.setRightsDependsOn(father.getRightsDependsOn());
513+
514+
AdminController admin = new AdminController(null);
515+
516+
// Topic profiles must be removed
517+
List<ProfileInst> profiles = admin.getProfilesByObject(topic.getNodePK().getId(),
518+
ObjectType.NODE.getCode(), topic.getNodePK().getInstanceId());
519+
if (profiles != null) {
520+
for (ProfileInst profile : profiles) {
521+
if (profile != null) {
522+
admin.deleteProfileInst(profile.getId());
523+
}
524+
}
525+
}
526+
} else {
527+
topic.setRightsDependsOnMe();
528+
}
529+
nodeBm.updateRightsDependency(topic);
530+
}
531+
}
504532
} catch (Exception e) {
505533
throw new KmeliaRuntimeException("KmeliaBmEJB.updateTopic()", ERROR,
506534
"kmelia.EX_IMPOSSIBLE_DE_MODIFIER_THEME", e);
@@ -1225,8 +1253,7 @@ public String createPublicationIntoTopicWithoutNotifications(PublicationDetail p
12251253
private String getProfile(String userId, NodePK nodePK) {
12261254
String profile;
12271255
OrganisationController orgCtrl = getOrganisationController();
1228-
if (StringUtil.getBooleanValue(
1229-
orgCtrl.getComponentParameterValue(nodePK.getInstanceId(), "rightsOnTopics"))) {
1256+
if (isRightsOnTopicsEnabled(nodePK.getInstanceId())) {
12301257
NodeDetail topic = nodeBm.getHeader(nodePK);
12311258
if (topic.haveRights()) {
12321259
profile = KmeliaHelper.getProfile(orgCtrl.getUserProfiles(userId, nodePK.getInstanceId(),
@@ -2532,7 +2559,7 @@ private boolean isValidationComplete(PublicationPK pubPK, List<String> allValida
25322559
public boolean validatePublication(PublicationPK pubPK, String userId, boolean force) {
25332560
SilverTrace.info("kmelia", "KmeliaBmEJB.validatePublication()", "root.MSG_GEN_ENTER_METHOD");
25342561
boolean validationComplete = false;
2535-
2562+
boolean update = false;
25362563
try {
25372564
CompletePublication currentPub = publicationBm.getCompletePublication(pubPK);
25382565
PublicationDetail currentPubDetail = currentPub.getPublicationDetail();
@@ -2588,6 +2615,7 @@ public boolean validatePublication(PublicationPK pubPK, String userId, boolean f
25882615
removeAllTodosForPublication(pubPK);
25892616
}
25902617
if (currentPubDetail.haveGotClone()) {
2618+
update = currentPubDetail.isValid();
25912619
currentPubDetail = mergeClone(currentPub, userId);
25922620
} else if (currentPubDetail.isValidationRequired()) {
25932621
currentPubDetail.setValidatorId(userId);
@@ -2601,7 +2629,7 @@ public boolean validatePublication(PublicationPK pubPK, String userId, boolean f
26012629
indexExternalElementsOfPublication(currentPubDetail);
26022630
// the publication has been validated
26032631
// we must alert all subscribers of the different topics
2604-
NodePK oneFather = sendSubscriptionsNotification(currentPubDetail, false, false);
2632+
NodePK oneFather = sendSubscriptionsNotification(currentPubDetail, update, false);
26052633

26062634
// we have to alert publication's creator
26072635
sendValidationNotification(oneFather, currentPubDetail, null, userId);
@@ -2905,10 +2933,11 @@ private void sendDefermentNotification(final PublicationDetail pubDetail,
29052933
*/
29062934
@Override
29072935
public void draftOutPublication(PublicationPK pubPK, NodePK topicPK, String userProfile) {
2936+
boolean update = getPublicationDetail(pubPK).isValid();
29082937
PublicationDetail pubDetail = draftOutPublicationWithoutNotifications(pubPK, topicPK,
29092938
userProfile);
29102939
indexExternalElementsOfPublication(pubDetail);
2911-
sendTodosAndNotificationsOnDraftOut(pubDetail, topicPK, userProfile);
2940+
sendTodosAndNotificationsOnDraftOut(pubDetail, topicPK, userProfile, update);
29122941
}
29132942

29142943
/**
@@ -2936,12 +2965,18 @@ private PublicationDetail draftOutPublication(PublicationPK pubPK, NodePK topicP
29362965
SilverTrace.info("kmelia", "KmeliaBmEJB.draftOutPublication()",
29372966
"root.MSG_GEN_ENTER_METHOD", "pubId = " + pubPK.getId());
29382967
try {
2968+
boolean update = false;
29392969
CompletePublication currentPub = publicationBm.getCompletePublication(pubPK);
29402970
PublicationDetail pubDetail = currentPub.getPublicationDetail();
29412971
SilverTrace.info("kmelia", "KmeliaBmEJB.draftOutPublication()",
29422972
"root.MSG_GEN_PARAM_VALUE", "actual status = " + pubDetail.getStatus());
29432973
if (userProfile.equals("publisher") || userProfile.equals("admin")) {
29442974
if (pubDetail.haveGotClone()) {
2975+
// special case when a publication is draft out
2976+
// check public publication status to determine
2977+
// if it's a creation or an update...
2978+
update = pubDetail.isValid();
2979+
29452980
pubDetail = mergeClone(currentPub, null);
29462981
}
29472982

@@ -2970,7 +3005,7 @@ private PublicationDetail draftOutPublication(PublicationPK pubPK, NodePK topicP
29703005
if (!inTransaction) {
29713006
// index all publication's elements
29723007
indexExternalElementsOfPublication(pubDetail);
2973-
sendTodosAndNotificationsOnDraftOut(pubDetail, topicPK, userProfile);
3008+
sendTodosAndNotificationsOnDraftOut(pubDetail, topicPK, userProfile, update);
29743009
}
29753010

29763011
return pubDetail;
@@ -2981,14 +3016,14 @@ private PublicationDetail draftOutPublication(PublicationPK pubPK, NodePK topicP
29813016
}
29823017

29833018
private void sendTodosAndNotificationsOnDraftOut(PublicationDetail pubDetail, NodePK topicPK,
2984-
String userProfile) {
3019+
String userProfile, boolean update) {
29853020
if (SilverpeasRole.writer.isInRole(userProfile)) {
29863021
createTodosForPublication(pubDetail, true);
29873022
}
29883023
// Subscriptions and supervisors are supported by kmelia and filebox only
29893024
if (!KmeliaHelper.isKmax(pubDetail.getInstanceId())) {
29903025
// alert subscribers
2991-
sendSubscriptionsNotification(pubDetail, false, false);
3026+
sendSubscriptionsNotification(pubDetail, update, false);
29923027

29933028
// alert supervisors
29943029
if (topicPK != null) {
@@ -4886,24 +4921,13 @@ public NodeDetail moveNode(@SourcePK NodePK nodePK, @TargetPK NodePK to, String
48864921
}
48874922
}
48884923
}
4889-
4890-
try {
4891-
NodePK fromForeignPK = fromNode.getNodePK();
4892-
List<SimpleDocument> documents = AttachmentServiceFactory.getAttachmentService().
4893-
listAllDocumentsByForeignKey(fromForeignPK, null);
4894-
ForeignPK toForeignPK = new ForeignPK(toNodePK.getId(), to);
4895-
for (SimpleDocument document : documents) {
4896-
AttachmentServiceFactory.getAttachmentService().moveDocument(document, toForeignPK);
4897-
}
4898-
} catch (org.silverpeas.attachment.AttachmentException e) {
4899-
SilverTrace.error("kmelia", "KmeliaSessionController.pastePublication()",
4900-
"root.MSG_GEN_PARAM_VALUE", "kmelia.CANT_MOVE_ATTACHMENTS", e);
4924+
4925+
// move rich description of node
4926+
if (!nodePK.getInstanceId().equals(to.getInstanceId())) {
4927+
WysiwygController.move(fromNode.getNodePK().getInstanceId(), "Node_" + fromNode.getId(), to.getInstanceId(), "Node_" + toNodePK.getId());
49014928
}
4902-
// change images path in wysiwyg
4903-
WysiwygController.wysiwygPlaceHaveChanged(fromNode.getNodePK().getInstanceId(),
4904-
"Node_" + fromNode.getNodePK().getId(), to.getInstanceId(), "Node_" + toNodePK.getId());
49054929

4906-
// move publications of topics
4930+
// move publications of node
49074931
movePublicationsOfTopic(fromNode.getNodePK(), toNodePK, userId);
49084932
}
49094933
}

kmelia/kmelia-war/src/main/java/com/stratelia/webactiv/kmelia/control/KmeliaSessionController.java

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ public class KmeliaSessionController extends AbstractComponentSessionController
206206
private String sortValue = null;
207207
private String defaultSortValue = "2";
208208
private String autoRedirectURL = null;
209-
private int nbPublicationsOnRoot = -1;
210209
private int rang = 0;
211210
private ResourceLocator publicationSettings = null;
212211
public final static String TAB_PREVIEW = "tabpreview";
@@ -230,7 +229,6 @@ public class KmeliaSessionController extends AbstractComponentSessionController
230229
String[] idSelectedUser = null;
231230
// pagination de la liste des publications
232231
private int indexOfFirstPubToDisplay = 0;
233-
private int nbPublicationsPerPage = -1;
234232
// Assistant de publication
235233
private String wizard = "none";
236234
private String wizardRow = "0";
@@ -346,34 +344,24 @@ public ResourceLocator getPublicationSettings() {
346344
}
347345

348346
public int getNbPublicationsOnRoot() {
349-
if (nbPublicationsOnRoot == -1) {
350-
String parameterValue = getComponentParameterValue("nbPubliOnRoot");
351-
if (StringUtil.isDefined(parameterValue)) {
352-
nbPublicationsOnRoot = Integer.parseInt(parameterValue);
353-
} else {
354-
if (KmeliaHelper.isKmelia(getComponentId())) {
355-
// lecture du properties
356-
nbPublicationsOnRoot = getSettings().getInteger("HomeNbPublications", 15);
357-
} else {
358-
nbPublicationsOnRoot = 0;
359-
}
347+
int nbPublicationsOnRoot = 0;
348+
String parameterValue = getComponentParameterValue("nbPubliOnRoot");
349+
if (StringUtil.isDefined(parameterValue)) {
350+
nbPublicationsOnRoot = Integer.parseInt(parameterValue);
351+
} else {
352+
if (KmeliaHelper.isKmelia(getComponentId())) {
353+
// lecture du properties
354+
nbPublicationsOnRoot = getSettings().getInteger("HomeNbPublications", 15);
360355
}
361356
}
362357
return nbPublicationsOnRoot;
363358
}
364359

365360
public int getNbPublicationsPerPage() {
366-
if (nbPublicationsPerPage == -1) {
367-
String parameterValue = this.getComponentParameterValue("nbPubliPerPage");
368-
if (parameterValue == null || parameterValue.length() <= 0) {
369-
nbPublicationsPerPage = getSettings().getInteger("NbPublicationsParPage", 10);
370-
} else {
371-
try {
372-
nbPublicationsPerPage = Integer.parseInt(parameterValue);
373-
} catch (Exception e) {
374-
nbPublicationsPerPage = getSettings().getInteger("NbPublicationsParPage", 10);
375-
}
376-
}
361+
int nbPublicationsPerPage = getSettings().getInteger("NbPublicationsParPage", 10);
362+
String parameterValue = getComponentParameterValue("nbPubliPerPage");
363+
if (StringUtil.isInteger(parameterValue)) {
364+
nbPublicationsPerPage = Integer.parseInt(parameterValue);
377365
}
378366
return nbPublicationsPerPage;
379367
}
@@ -2676,30 +2664,6 @@ public void updateTopicRole(String role, String nodeId) throws RemoteException {
26762664
}
26772665
}
26782666

2679-
public void updateTopicDependency(NodeDetail node, boolean enableIt) throws RemoteException {
2680-
if (!enableIt) {
2681-
NodePK fatherPK = node.getFatherPK();
2682-
NodeDetail father = getNodeBm().getHeader(fatherPK);
2683-
2684-
node.setRightsDependsOn(father.getRightsDependsOn());
2685-
2686-
// Topic profiles must be removed
2687-
List<ProfileInst> profiles = getAdmin().getProfilesByObject(node.getNodePK().getId(),
2688-
ObjectType.NODE.getCode(),
2689-
getComponentId());
2690-
for (int p = 0; profiles != null && p < profiles.size(); p++) {
2691-
ProfileInst profile = profiles.get(p);
2692-
if (profile != null) {
2693-
getAdmin().deleteProfileInst(profile.getId());
2694-
}
2695-
}
2696-
} else {
2697-
node.setRightsDependsOnMe();
2698-
}
2699-
2700-
getNodeBm().updateRightsDependency(node);
2701-
}
2702-
27032667
public ProfileInst getTopicProfile(String role, String topicId) {
27042668
List<ProfileInst> profiles = getAdmin().getProfilesByObject(topicId, ObjectType.NODE.getCode(),
27052669
getComponentId());
@@ -3055,8 +3019,7 @@ public List<Treeview> getComponents(List<Alias> aliases) throws RemoteException
30553019

30563020
if (instanceId.equals(getComponentId())) {
30573021
tree = getKmeliaBm().getTreeview(root, "useless", false, false, getUserId(),
3058-
false, StringUtil.getBooleanValue(getOrganisationController().
3059-
getComponentParameterValue(instanceId, "rightsOnTopics")));
3022+
false, isRightsOnTopicsEnabled());
30603023
}
30613024

30623025
if (!StringUtil.isDefined(path)) {
@@ -3101,8 +3064,7 @@ public List<NodeDetail> getAliasTreeview(String instanceId) throws RemoteExcepti
31013064
NodePK root = new NodePK(NodePK.ROOT_NODE_ID, instanceId);
31023065

31033066
tree = getKmeliaBm().getTreeview(root, "useless", false, false, getUserId(), false,
3104-
StringUtil.getBooleanValue(getOrganisationController().getComponentParameterValue(
3105-
instanceId, "rightsOnTopics")));
3067+
isRightsOnTopicsEnabled());
31063068
}
31073069
return tree;
31083070
}

kmelia/kmelia-war/src/main/java/com/stratelia/webactiv/kmelia/servlets/KmeliaRequestRouter.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -507,23 +507,26 @@ public String getDestination(String function, KmeliaSessionController kmelia,
507507
topic.setType(NodeDetail.FILE_LINK_TYPE);
508508
topic.setPath(path);
509509
}
510-
kmelia.updateTopicHeader(topic, alertType);
510+
boolean goToProfilesDefinition = false;
511511
if (kmelia.isRightsOnTopicsEnabled()) {
512512
int rightsUsed = Integer.parseInt(request.getParameter("RightsUsed"));
513-
topic = kmelia.getNodeHeader(id);
514-
if (topic.getRightsDependsOn() != rightsUsed) {
513+
topic.setRightsDependsOn(rightsUsed);
514+
515+
// process destination
516+
NodeDetail oldTopic = kmelia.getNodeHeader(id);
517+
if (oldTopic.getRightsDependsOn() != rightsUsed) {
515518
// rights dependency have changed
516-
if (rightsUsed == -1) {
517-
kmelia.updateTopicDependency(topic, false);
518-
destination = getDestination("GoToCurrentTopic", kmelia, request);
519-
} else {
520-
kmelia.updateTopicDependency(topic, true);
521-
request.setAttribute("NodeId", id);
522-
destination = getDestination("ViewTopicProfiles", kmelia, request);
519+
if (rightsUsed != -1) {
520+
// folder uses its own rights
521+
goToProfilesDefinition = true;
523522
}
524-
} else {
525-
destination = getDestination("GoToCurrentTopic", kmelia, request);
526523
}
524+
}
525+
kmelia.updateTopicHeader(topic, alertType);
526+
527+
if (goToProfilesDefinition) {
528+
request.setAttribute("NodeId", id);
529+
destination = getDestination("ViewTopicProfiles", kmelia, request);
527530
} else {
528531
destination = getDestination("GoToCurrentTopic", kmelia, request);
529532
}

0 commit comments

Comments
 (0)