solved bug on session from cached node
This commit is contained in:
parent
76639ed5f1
commit
994608da26
|
@ -5,7 +5,6 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
|
||||
import javax.jcr.RepositoryException;
|
||||
import javax.jcr.Session;
|
||||
|
||||
import org.apache.jackrabbit.api.JackrabbitSession;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
|
|
@ -55,7 +55,7 @@ public class DataHandler {
|
|||
|
||||
List<GroupData> groupsData = new ArrayList<GroupData>(groups.size());
|
||||
for (String group : groups) {
|
||||
logger.debug("serching for group {}",group);
|
||||
logger.debug("searching for group {}",group);
|
||||
Item vreFolderItem = vreManager.getVreFolderItemByGroupName(session, group, null).getVreFolder();
|
||||
String owner = vreFolderItem.getOwner();
|
||||
List<ACL> acls = aclHandler.get(vreFolderItem, session);
|
||||
|
|
|
@ -120,6 +120,7 @@ public class ScriptManager {
|
|||
return status;
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("export")
|
||||
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE})
|
||||
|
@ -134,29 +135,33 @@ public class ScriptManager {
|
|||
String serverHost = appContext.container().configuration().hostname();
|
||||
final ScriptStatus status = new ScriptStatus(runningId, null, serverHost);
|
||||
scriptStatusMap.put(runningId, status);
|
||||
Runnable execution = () -> {
|
||||
|
||||
JackrabbitSession session = null;
|
||||
try {
|
||||
session = (JackrabbitSession) repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
DumpData dd = dataHandler.exportData(session);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
status.setSuccess(om.writeValueAsString(dd));
|
||||
log.info("""
|
||||
export finished with result
|
||||
---------------------------
|
||||
{}
|
||||
---------------------------
|
||||
""", status.getResult());
|
||||
} catch (Throwable t) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw, true);
|
||||
t.printStackTrace(pw);
|
||||
status.setFailed(sw.toString());
|
||||
log.warn("export failed", t);
|
||||
} finally {
|
||||
if (session!=null)
|
||||
session.logout();
|
||||
Runnable execution = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JackrabbitSession session = null;
|
||||
try {
|
||||
session = (JackrabbitSession) repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
DumpData dd = dataHandler.exportData(session);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
status.setSuccess(om.writeValueAsString(dd));
|
||||
log.info("""
|
||||
export finished with result
|
||||
---------------------------
|
||||
{}
|
||||
---------------------------
|
||||
""", status.getResult());
|
||||
} catch (Throwable t) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw, true);
|
||||
t.printStackTrace(pw);
|
||||
status.setFailed(sw.toString());
|
||||
log.warn("export failed", t);
|
||||
} finally {
|
||||
if (session!=null)
|
||||
session.logout();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -43,8 +43,10 @@ public class ACLManagerDelegate implements ACLManagerInterface {
|
|||
Node toRetrieve = (Node) item.getRelatedNode();
|
||||
if (!(item instanceof SharedFolder))
|
||||
toRetrieve = retrieveSharedFolderParent(toRetrieve, session);
|
||||
|
||||
JackrabbitAccessControlList accessControlList = AccessControlUtils.getAccessControlList(session, toRetrieve.getPath());
|
||||
|
||||
String path = item.getPath();
|
||||
|
||||
JackrabbitAccessControlList accessControlList = AccessControlUtils.getAccessControlList(session, path );
|
||||
for (AccessControlEntry aclEntry : accessControlList.getAccessControlEntries()) {
|
||||
ACL acl = new ACL();
|
||||
acl.setPricipal(aclEntry.getPrincipal().getName());
|
||||
|
|
Loading…
Reference in New Issue