use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class SimpleJcrTestUtils method getVersionHistoryNodePath.
public static String getVersionHistoryNodePath(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());
Node node = ((Node) item);
return node.getVersionHistory().getPath();
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class SimpleJcrTestUtils method isCheckedOut.
public static boolean isCheckedOut(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).isCheckedOut();
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class JcrRepositoryFileDaoTest method setUp.
@Before
public void setUp() throws RepositoryException {
Node node = mock(Node.class);
Node nodeParent = mock(Node.class);
when(node.getIdentifier()).thenReturn("");
when(nodeParent.getIdentifier()).thenReturn("");
when(node.getParent()).thenReturn(nodeParent);
when(node.isNodeType("null:pentahoFile")).thenReturn(true);
when(node.isNodeType("null:pentahoVersionable")).thenReturn(true);
VersionManagerImpl versionManager = mock(VersionManagerImpl.class);
Workspace workspace = mock(Workspace.class);
when(workspace.getVersionManager()).thenReturn(versionManager);
Session session = mock(Session.class);
when(session.getWorkspace()).thenReturn(workspace);
when(session.getNodeByIdentifier(anyString())).thenReturn(node);
when(session.getItem(anyString())).thenReturn(node);
pentahoSession = mock(IPentahoSession.class);
PentahoSessionHolder.setSession(pentahoSession);
IRepositoryVersionManager repositoryVersionManager = mock(IRepositoryVersionManager.class);
when(repositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
PentahoSystem.registerObject(repositoryVersionManager);
JcrTemplate jcrTemplate = new JcrTemplate() {
@Override
public Object execute(JcrCallback callback) throws DataAccessException {
try {
return callback.doInJcr(session);
} catch (Exception e) {
// wrapping exception to comply overriding rules
throw new RuntimeException(e);
}
}
};
List<ITransformer<IRepositoryFileData>> transformerList = Collections.emptyList();
IPathConversionHelper pathConversionHelper = new DefaultPathConversionHelper();
IRepositoryFileAclDao aclDao = mock(IRepositoryFileAclDao.class);
accessVoterManager = mock(IRepositoryAccessVoterManager.class);
JcrRepositoryFileDao jcrDao = new JcrRepositoryFileDao(jcrTemplate, transformerList, null, null, pathConversionHelper, aclDao, null, accessVoterManager);
dao = spy(jcrDao);
}
Aggregations