|
|
|
@ -7,6 +7,7 @@ import java.io.OutputStream;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.security.MessageDigest;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Deque;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
@ -24,6 +25,7 @@ import javax.jcr.RepositoryException;
|
|
|
|
|
import javax.jcr.Session;
|
|
|
|
|
import javax.jcr.lock.Lock;
|
|
|
|
|
import javax.jcr.lock.LockException;
|
|
|
|
|
import javax.jcr.nodetype.NodeType;
|
|
|
|
|
import javax.jcr.query.Query;
|
|
|
|
|
import javax.jcr.version.Version;
|
|
|
|
|
|
|
|
|
@ -57,6 +59,8 @@ import org.gcube.data.access.storagehub.handlers.items.Node2ItemConverter;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import net.bull.javamelody.internal.common.LOG;
|
|
|
|
|
|
|
|
|
|
public class Utils {
|
|
|
|
|
|
|
|
|
|
public final static String SERVICE_NAME = "home-library";
|
|
|
|
@ -299,7 +303,18 @@ public class Utils {
|
|
|
|
|
|
|
|
|
|
public static void getAllContentIds(Session ses, Set<String> idsToDelete, Item itemToDelete, VersionHandler versionHandler) throws Exception{
|
|
|
|
|
if (itemToDelete instanceof AbstractFileItem) {
|
|
|
|
|
List<Version> versions = versionHandler.getContentVersionHistory(ses.getNodeByIdentifier(itemToDelete.getId()), ses);
|
|
|
|
|
Node currentNode = ses.getNodeByIdentifier(itemToDelete.getId());
|
|
|
|
|
List<NodeType> ntList = Arrays.asList(currentNode.getMixinNodeTypes());
|
|
|
|
|
boolean isVersioned = false;
|
|
|
|
|
logger.debug("mixin node type are {}",ntList);
|
|
|
|
|
for (NodeType nt: ntList)
|
|
|
|
|
if(nt.getName().equals("mix:versionable")) {
|
|
|
|
|
isVersioned = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isVersioned) {
|
|
|
|
|
List<Version> versions = versionHandler.getContentVersionHistory(currentNode, ses);
|
|
|
|
|
|
|
|
|
|
versions.forEach(v -> {
|
|
|
|
|
try {
|
|
|
|
@ -311,6 +326,9 @@ public class Utils {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
logger.info("not versionable node type found of type {}", currentNode.getPrimaryNodeType().toString());
|
|
|
|
|
|
|
|
|
|
idsToDelete.add(((AbstractFileItem) itemToDelete).getContent().getStorageId());
|
|
|
|
|
}else if (itemToDelete instanceof FolderItem) {
|
|
|
|
|
List<Item> items = Utils.getItemList(ses.getNodeByIdentifier(itemToDelete.getId()), Excludes.GET_ONLY_CONTENT , null, true, null);
|
|
|
|
|