Skip to content

Feature 10542 #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ kmelia.RightsSpecificEnable=Cliquez ici pour d\u00e9finir des droits sp\u00e9cif
kmelia.PubInBasket=Cette publication est actuellement dans la corbeille
Description=Description
kmelia.SupervisorNotifSubject=Nouvelle publication en ligne
ConfirmFlushTrashBean=Etes-vous sur de vouloir supprimer toutes les publications de la corbeille ?
ConfirmFlushTrashBean=\u00cates-vous s\u00fbr de vouloir supprimer le contenu de la corbeille ?
PubCreer=Cr\u00e9er une publication
kmelia.RightsSpecificDisable=Cliquez ici pour ne plus utiliser les droits sp\u00e9cifiques...
kmelia.ProcessDuration=Temps de traitement \:
@@ -245,8 +245,8 @@ ContainsTooLargeText=ne doit pas exc\u00e9der
PubGererChemins=Emplacements
DateDesc=Dates de modification d\u00e9croissantes
Model=Contenu
PublicationAddToTopic3=existe d\u00e9j\u00e0 dans le dossier courant \!
PublicationAddToTopic2=a \u00e9t\u00e9 ajout\u00e9 au dossier courant \!
PublicationAddToTopic3=existe d\u00e9j\u00e0 dans le dossier courant !
PublicationAddToTopic2=a \u00e9t\u00e9 ajout\u00e9 au dossier courant !
PublicationAddToTopic1=La publication
ConfirmDeletePath=Etes-vous s\u00fbr de vouloir supprimer l'emplacement ?
Home=Accueil
@@ -262,7 +262,7 @@ Error=erreur
TopicPath=Emplacement
Page=Page
PubDeclass=Publication d\u00e9class\u00e9e
kmelia.CopyPublicationLink=Pour copier le lien vers cette publication \: Clique droit puis 'Copier le raccourci'
kmelia.CopyPublicationLink=Pour copier le lien vers cette publication : Clique droit puis 'Copier le raccourci'
PubDeMemeSujet=M\u00eame sujet
kmelia.LastModification=Derni\u00e8re modification
kmelia.FolderAddLink=Cr\u00e9er un dossier li\u00e9 \u00e0 un r\u00e9pertoire r\u00e9seau
@@ -460,3 +460,4 @@ kmelia.publications.batch.update.fail = {0} publications n'ont pas pu \u00eatre
kmelia.publications.batch.update = Vous \u00eates sur le point de modifier le contenu de <b>{0} publications</b>... Seuls les champs renseign\u00e9s seront appliqu\u00e9s \u00e0 ces publications.
kmelia.ExportPDFApplication=Fusionner tous les PDF de l'application
kmelia.sort.manual.reset.confirm=Etes-vous s\u00fbr(e) de vouloir supprimer d\u00e9finitivement l'ordre manuel et revenir \u00e0 l'ordre par d\u00e9faut ?
kmelia.folder.trash.confirm=<p>Etes-vous s\u00fbr de vouloir placer le dossier dans la corbeille ?</p><p>(Tous droits sp\u00e9cifiques du dossier seront retir\u00e9s.)</p>
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ ConfirmDeletePath = Sind Sie sicher, den Speicherort l\u00f6schen zu wollen?
UnknownAuthor = Ersteller unbekannt
PubDeclass = Deklassifizierte Ver\u00f6ffentlichung
NPubDeclass = Referenzierte Ver\u00f6ffentlichungen.
ConfirmFlushTrashBean = Sind Sie sicher, alle Ver\u00f6ffentlichungen des Papierkorbes l\u00f6schen zu wollen ?
ConfirmFlushTrashBean=M\u00f6chten Sie den M\u00fclleimer wirklich leeren?
EmptyBasket = Papierkorb leeren
kmelia.AddFile=Datei hinzuf\u00fcgen

@@ -512,3 +512,4 @@ kmelia.publications.batch.update = Sie sind dabei, den Inhalt von <b> {0} Publik
kmelia.ExportPDFApplication=Merge all PDF of the application
kmelia.LocalPathMandatory=Ein lokaler Standort ist ein Muss!
kmelia.sort.manual.reset.confirm=Sind Sie sicher, dass Sie das manuelle Ranking dauerhaft entfernen und zum Standardranking zur\u00fcckkehren m\u00f6chten?
kmelia.folder.trash.confirm=<p>Do you really want to put the folder in the trash?</p><p>(All the specific rights of the folder will be removed.)</p>
Original file line number Diff line number Diff line change
@@ -117,8 +117,7 @@ UnknownAuthor = Unknown author

PubDeclass = Unclassified publication
NPubDeclass = Associated publication(s)

ConfirmFlushTrashBean = Do you really want to delete ALL trashcan's publication ?
ConfirmFlushTrashBean=Do you really want to empty the trash can?
EmptyBasket = Empty trashcan
kmelia.AddFile = Add a file

@@ -505,11 +504,12 @@ kmelia.publications.batch.update.none=No publication has been modified
kmelia.publications.batch.update.success = {0} publications modified successfully
kmelia.publications.batch.update.fail = {0} publications could not be modified
kmelia.publications.batch.update = You are about to modify the content of <b>{0} publications</b> ... Only the fields filled in will be applied to these publications.
kmelia.ExportPDFApplication=Alle PDFs der Bewerbung zusammenf�hren
kmelia.ExportPDFApplication=Alle PDFs der Bewerbung zusammenf\u00fchren
kmelia.LocalPathMandatory=A local place is mandatory!
kmax.ExportPublicationsFound=Export found publications
kmelia.RightsSpecificEnable=Click here to set specific access rights...
kmelia.RightsSpecificDisable=Click here to unset specific access rights...
ConfirmDeleteCoordinate=Are you sure to delete the classification
kmelia.FolderAddLink=Create a topic linked to a network folder
kmelia.sort.manual.reset.confirm=Are you sure to permanently remove the manual ordering and revert to the default ordering?
kmelia.folder.trash.confirm=<p>M\u00f6chten Sie den Ordner wirklich in den Papierkorb legen?</p><p>(Dabei werden s\u00e4mtliche spezifischen Rechte des Ordners entfernt.)</p>
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ kmelia.RightsSpecificEnable=Cliquez ici pour d\u00e9finir des droits sp\u00e9cif
kmelia.PubInBasket=Cette publication est actuellement dans la corbeille
Description=Description
kmelia.SupervisorNotifSubject=Nouvelle publication en ligne
ConfirmFlushTrashBean=Etes-vous sur de vouloir supprimer toutes les publications de la corbeille ?
ConfirmFlushTrashBean=\u00cates-vous s\u00fbr de vouloir supprimer le contenu de la corbeille ?
PubCreer=Cr\u00e9er une publication
kmelia.RightsSpecificDisable=Cliquez ici pour ne plus utiliser les droits sp\u00e9cifiques...
kmelia.ProcessDuration=Temps de traitement \:
@@ -460,3 +460,4 @@ kmelia.publications.batch.update.none=Aucune publication n'a \u00e9t\u00e9 modif
kmelia.publications.batch.update.success = {0} publications modifi\u00e9es avec succ\u00e8s
kmelia.publications.batch.update.fail = {0} publications n'ont pas pu \u00eatre modifi\u00e9es
kmelia.publications.batch.update = Vous \u00eates sur le point de modifier le contenu de <b>{0} publications</b>... Seuls les champs renseign\u00e9s seront appliqu\u00e9s \u00e0 ces publications.
kmelia.folder.trash.confirm=<p>Etes-vous s\u00fbr de vouloir placer le dossier dans la corbeille ?</p><p>(Tous droits sp\u00e9cifiques du dossier seront retir\u00e9s.)</p>
Original file line number Diff line number Diff line change
@@ -114,6 +114,7 @@
import org.silverpeas.core.util.annotation.TargetPK;
import org.silverpeas.core.util.file.FileRepositoryManager;
import org.silverpeas.core.util.file.FileUtil;
import org.silverpeas.kernel.annotation.NonNull;
import org.silverpeas.kernel.bundle.LocalizationBundle;
import org.silverpeas.kernel.bundle.ResourceLocator;
import org.silverpeas.kernel.bundle.SettingBundle;
@@ -322,9 +323,10 @@ public List<KmeliaPublication> getLatestAuthorizedPublications(String instanceId
.limitTo(limit));
return asKmeliaPublication(pubDetails);
});
String count = result == null ? "" : String.valueOf(result.size());
SilverLogger.getLogger(this)
.debug(() -> format("getting {0} latest authorized publications of instance {1} in {2}",
result.size(), instanceId, formatDurationHMS(System.currentTimeMillis() - start)));
count, instanceId, formatDurationHMS(System.currentTimeMillis() - start)));
return result;
}

@@ -510,13 +512,6 @@ public NodeDetail getSubTopicDetail(NodePK pk) {
return subTopic;
}

/**
* Delete a topic and all descendants. Delete all links between descendants and publications. This
* publications will be visible in the Declassified zone. Delete All subscriptions and favorites
* on this topics and all descendants
* @param pkToDelete the id of the topic to delete
* @since 1.0
*/
@Override
@Transactional(Transactional.TxType.REQUIRED)
public void deleteTopic(NodePK pkToDelete) {
@@ -532,7 +527,8 @@ public void deleteTopic(NodePK pkToDelete) {
for (PublicationDetail onePubToCheck : pubsToCheck) {
final KmeliaPublication kmeliaPub = fromDetail(onePubToCheck, oneNodeToDelete);
if (!kmeliaPub.isAlias()) {
sendPublicationToBasket(kmeliaPub.getPk());
// delete definitively the publication
deletePublication(kmeliaPub.getPk());
} else {
// remove only the alias
final Collection<Location> aliases = singletonList(kmeliaPub.getLocation());
@@ -1153,7 +1149,7 @@ public void movePublicationInSameApplication(@SourcePK PublicationPK pubPK, @Tar
private void movePublicationInSameApplication(PublicationDetail pub, NodePK to,
KmeliaPasteDetail pasteContext) {
if (to.isTrash()) {
sendPublicationToBasket(pub.getPK());
sendPublicationInBasket(pub.getPK());
} else {
// update parent
publicationService.movePublication(pub.getPK(), to, false);
@@ -1381,12 +1377,6 @@ private boolean isClone(PublicationDetail publication) {
!isDefined(publication.getCloneStatus());
}

/**
* HEAD Delete a publication If this publication is in the basket or in the DZ, it's deleted from
* the database Else it only send to the basket.
* @param pubPK the id of the publication to delete
* @see TopicDetail
*/
@Override
@Transactional(Transactional.TxType.REQUIRED)
public void deletePublication(PublicationPK pubPK) {
@@ -1410,18 +1400,7 @@ public void deletePublication(PublicationPK pubPK) {

}

/**
* Send the publication in the basket topic.
* <p>
* All aliases of the publication are deleted if exist.
* </p>
* @param pubPK the id of the publication
* @param kmaxMode true to indicate a use from kmax application
* @see TopicDetail
* @since 1.0
*/
@Override
public void sendPublicationToBasket(PublicationPK pubPK, boolean kmaxMode) {
private void sendPublicationInBasket(PublicationPK pubPK, boolean kmaxMode) {
KmeliaOperationContext.about(REMOVING);
try {
// remove coordinates for Kmax
@@ -1446,23 +1425,53 @@ public void sendPublicationToBasket(PublicationPK pubPK, boolean kmaxMode) {
// remove all links between this publication and topics
publicationService.removeAllFathers(pubPK);
// add link between this publication and the basket topic
publicationService.addFather(pubPK, new NodePK("1", pubPK));

// remove all the todos attached to the publication
removeAllTodosForPublication(pubPK);
publicationService.addFather(pubPK, new NodePK(NodePK.BIN_NODE_ID, pubPK));

// publication is no more accessible
updateSilverContentVisibility(pubPK);

unIndexExternalElementsOfPublication(pubPK);
cleanUpPublicationsInBasket(pubPK);
} catch (Exception e) {
throw new KmeliaRuntimeException(e);
}
}

@Override
public void sendPublicationToBasket(PublicationPK pubPK) {
sendPublicationToBasket(pubPK, KmeliaHelper.isKmax(pubPK.getInstanceId()));
private void cleanUpPublicationsInBasket(PublicationPK pubPK) {
// remove all the todos attached to the publication
removeAllTodosForPublication(pubPK);

// publication is no more accessible
updateSilverContentVisibility(pubPK);

unIndexExternalElementsOfPublication(pubPK);
}

private void sendPublicationInBasket(PublicationPK pubPK) {
sendPublicationInBasket(pubPK, KmeliaHelper.isKmax(pubPK.getInstanceId()));
}

private void sendTopicInBasket(NodeDetail topic) {
NodePK trash = new NodePK(NodePK.BIN_NODE_ID,
topic.getIdentifier().getComponentInstanceId());

// get all the tree of folders, rooted to the topic, to be sent in the basket with the topic
final Collection<NodeDetail> children = nodeService.getDescendantDetails(topic.getNodePK());
for (final NodeDetail childTopic : children) {
// get all the direct publications in the topic child (including aliases)
final Collection<PublicationDetail> publications =
publicationService.getDetailsByFatherPK(childTopic.getNodePK());
// check each publication: if it is an alias, remove it, otherwise it is moved into the trash
// with its topic
for (PublicationDetail publication : publications) {
final KmeliaPublication kmeliaPublication = fromDetail(publication, childTopic.getNodePK());
if (kmeliaPublication.isAlias()) {
// remove only the alias
final Collection<Location> aliases = singletonList(kmeliaPublication.getLocation());
publicationService.removeAliases(kmeliaPublication.getPk(), aliases);
} else {
cleanUpPublicationsInBasket(publication.getPK());
}
}
}

nodeService.moveNode(topic.getNodePK(), trash);
}

@Override
@@ -3879,28 +3888,28 @@ private NodeDetail find(Collection<NodeDetail> nodes, NodeDetail toFind) {
}

/**
* Removes publications according to given ids. Before a publication is removed, user priviledges
* Removes publications according to given ids. Before a publication is removed, user privileges
* are controlled. If node defines the trash, publications are definitively deleted. Otherwise,
* publications move into trash.
* @param ids the ids of publications to delete
* @param nodePK the node where the publications are
* @param publiIds the ids of publications to delete
* @param topicId the node where the publications are
* @param userId the user who wants to perform deletion
* @return the list of publication ids which has been really deleted
* @
*/
@Override
@Transactional(Transactional.TxType.REQUIRED)
public List<String> deletePublications(List<String> ids, NodePK nodePK, String userId) {
public List<String> deletePublications(List<String> publiIds, NodePK topicId, String userId) {
List<String> removedIds = new ArrayList<>();
String profile = getProfile(userId, nodePK);
for (String id : ids) {
PublicationPK pk = new PublicationPK(id, nodePK);
if (isUserCanDeletePublication(new PublicationPK(id, nodePK), profile, userId)) {
String profile = getProfile(userId, topicId);
for (String id : publiIds) {
PublicationPK pk = new PublicationPK(id, topicId);
if (isUserCanDeletePublication(new PublicationPK(id, topicId), profile, userId)) {
try {
if (nodePK.isTrash() && isPublicationInBasket(pk)) {
if (topicId.isTrash() && isPublicationInBasket(pk)) {
deletePublication(pk);
} else {
sendPublicationToBasket(pk);
sendPublicationInBasket(pk);
}
removedIds.add(id);
} catch (Exception e) {
@@ -3912,6 +3921,28 @@ public List<String> deletePublications(List<String> ids, NodePK nodePK, String u
return removedIds;
}

@Transactional(Transactional.TxType.REQUIRED)
@Override
public void deleteTopic(@NonNull NodePK topic, String userId) {
Objects.requireNonNull(topic);
if (topic.isTrash() || topic.isRoot()) {
return;
}
NodeDetail folder = getNodeHeader(topic);
boolean isInTrash = nodeService.getPath(topic).get(1).getId().equals(NodePK.BIN_NODE_ID);
// check if user is allowed to delete this topic
NodePK root = new NodePK(NodePK.ROOT_NODE_ID, topic.getInstanceId());
if (SilverpeasRole.ADMIN.isInRole(getUserTopicProfile(topic, userId)) ||
SilverpeasRole.ADMIN.isInRole(getUserTopicProfile(root, userId)) ||
SilverpeasRole.ADMIN.isInRole(getUserTopicProfile(folder.getFatherPK(), userId))) {
if (isInTrash) {
deleteTopic(topic);
} else {
sendTopicInBasket(folder);
}
}
}

private boolean isUserCanDeletePublication(PublicationPK pubPK, String profile, String userId) {
User owner = getPublication(pubPK).getCreator();
return KmeliaPublicationHelper.isRemovable(pubPK.getInstanceId(), userId, profile, owner);
Loading
Oops, something went wrong.