use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class JcrRepositoryFileDao method unlockFile.
/**
* {@inheritDoc}
*/
@Override
public void unlockFile(final Serializable fileId) {
if (isKioskEnabled()) {
// $NON-NLS-1$
throw new RuntimeException(Messages.getInstance().getString("JcrRepositoryFileDao.ERROR_0006_ACCESS_DENIED"));
}
Assert.notNull(fileId);
jcrTemplate.execute(new JcrCallback() {
@Override
public Object doInJcr(final Session session) throws RepositoryException, IOException {
PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session);
lockHelper.unlockFile(session, pentahoJcrConstants, fileId);
return null;
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class JcrRepositoryFileDao method setLocalePropertiesForFile.
@Override
public void setLocalePropertiesForFile(final RepositoryFile repositoryFile, final String locale, final Properties properties) {
if (isKioskEnabled()) {
// $NON-NLS-1$
throw new RuntimeException(Messages.getInstance().getString("JcrRepositoryFileDao.ERROR_0006_ACCESS_DENIED"));
}
Assert.notNull(repositoryFile);
Assert.notNull(locale);
Assert.notNull(properties);
jcrTemplate.execute(new JcrCallback() {
@Override
public Object doInJcr(final Session session) throws RepositoryException, IOException {
PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session);
String versionMessage = Messages.getInstance().getString("JcrRepositoryFileDao.LOCALE_0001_UPDATE_PROPERTIES", repositoryFile.getId());
lockHelper.addLockTokenToSessionIfNecessary(session, pentahoJcrConstants, repositoryFile.getId());
JcrRepositoryFileUtils.checkoutNearestVersionableFileIfNecessary(session, pentahoJcrConstants, repositoryFile.getId());
JcrRepositoryFileUtils.updateFileLocaleProperties(session, repositoryFile.getId(), locale, properties);
session.save();
JcrRepositoryFileUtils.checkinNearestVersionableFileIfNecessary(session, pentahoJcrConstants, repositoryFile.getId(), versionMessage);
lockHelper.removeLockTokenFromSessionIfNecessary(session, pentahoJcrConstants, repositoryFile.getId());
return null;
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class JcrRepositoryFileDao method lockFile.
/**
* {@inheritDoc}
*/
@Override
public void lockFile(final Serializable fileId, final String message) {
if (isKioskEnabled()) {
// $NON-NLS-1$
throw new RuntimeException(Messages.getInstance().getString("JcrRepositoryFileDao.ERROR_0006_ACCESS_DENIED"));
}
Assert.notNull(fileId);
jcrTemplate.execute(new JcrCallback() {
@Override
public Object doInJcr(final Session session) throws RepositoryException, IOException {
PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session);
lockHelper.lockFile(session, pentahoJcrConstants, fileId, message);
return null;
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class SimpleJcrTestUtils method getNodeId.
public static String getNodeId(final JcrTemplate jcrTemplate, final String absPath) {
return (String) jcrTemplate.execute(new JcrCallback() {
public Object doInJcr(final Session session) throws RepositoryException {
Item item;
try {
item = session.getItem(absPath);
} catch (PathNotFoundException e) {
return null;
}
Assert.isTrue(item.isNode());
return ((Node) item).getUUID();
}
});
}
use of org.springframework.extensions.jcr.JcrCallback in project pentaho-platform by pentaho.
the class SimpleJcrTestUtils method getDate.
public static Date getDate(final JcrTemplate jcrTemplate, final String absPath) {
return (Date) jcrTemplate.execute(new JcrCallback() {
public Object doInJcr(final Session session) throws RepositoryException {
Item item = session.getItem(absPath);
Assert.isTrue(!item.isNode());
return ((Property) item).getDate().getTime();
}
});
}
Aggregations