use of org.springframework.extensions.jcr.JcrCallback in project pentaho-kettle by pentaho.
the class PurRepositoryTestingUtils method setAclManagementCallback.
/**
* Create a {@linkplain JcrCallback} for setting up ACL management in test repository
*
* @return acl management callback
*/
static JcrCallback setAclManagementCallback() {
return new JcrCallback() {
@Override
public Object doInJcr(Session session) throws IOException, RepositoryException {
PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session);
Workspace workspace = session.getWorkspace();
PrivilegeManager privilegeManager = ((JackrabbitWorkspace) workspace).getPrivilegeManager();
try {
privilegeManager.getPrivilege(pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE());
} catch (AccessControlException ace) {
privilegeManager.registerPrivilege(pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE(), false, new String[0]);
}
session.save();
return null;
}
};
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class SimpleJcrTestUtils method isLocked.
public static boolean isLocked(final JcrTemplate jcrTemplate, final String absPath) {
return (Boolean) jcrTemplate.execute(new JcrCallback() {
public Object doInJcr(final Session session) throws RepositoryException {
Item item = session.getItem(absPath);
Assert.isTrue(item.isNode());
return ((Node) item).isLocked();
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class SimpleJcrTestUtils method addNode.
public static String addNode(final JcrTemplate jcrTemplate, final String parentAbsPath, final String name, final String primaryNodeTypeName) {
return (String) jcrTemplate.execute(new JcrCallback() {
public String doInJcr(final Session session) throws RepositoryException {
PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session);
Node newNode;
try {
Item item = session.getItem(parentAbsPath);
Assert.isTrue(item.isNode());
Node parentNode = (Node) item;
newNode = parentNode.addNode(name, primaryNodeTypeName);
newNode.addMixin(pentahoJcrConstants.getMIX_REFERENCEABLE());
} catch (PathNotFoundException e) {
return null;
}
session.save();
return newNode.getUUID();
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class SimpleJcrTestUtils method getVersionCount.
public static int getVersionCount(final JcrTemplate jcrTemplate, final String absPath) {
return (Integer) jcrTemplate.execute(new JcrCallback() {
public Object doInJcr(final Session session) throws RepositoryException {
Node fileNode = (Node) session.getItem(absPath);
VersionHistory versionHistory = fileNode.getVersionHistory();
VersionIterator versionIterator = versionHistory.getAllVersions();
int versionCount = 0;
while (versionIterator.hasNext()) {
versionIterator.nextVersion();
versionCount++;
}
return versionCount;
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class SimpleJcrTestUtils method getString.
public static String getString(final JcrTemplate jcrTemplate, final String absPath) {
return (String) jcrTemplate.execute(new JcrCallback() {
public Object doInJcr(final Session session) throws RepositoryException {
Item item = session.getItem(absPath);
Assert.isTrue(!item.isNode());
return ((Property) item).getString();
}
});
}
Aggregations