use of javax.jcr.Repository in project jackrabbit by apache.
the class TestHelper method checkVersionStoreConsistency.
/**
* Runs a consistency check on the versioning store used by the specified session.
*
* @param session the Session accessing the workspace to be checked
* @param runFix whether to attempt fixup
* @param lostNFoundId node to which to attach orphaned nodes (or <code>null</code>)
* @throws RepositoryException
* @throws NotExecutableException if the {@link PersistenceManager} does
* not implement {@link ConsistencyChecker}, or if the associated
* {@link Repository} is not a {@link RepositoryImpl}.
*/
public static ConsistencyReport checkVersionStoreConsistency(Session session, boolean runFix, String lostNFoundId) throws NotExecutableException, RepositoryException {
Repository r = session.getRepository();
if (!(r instanceof RepositoryImpl)) {
throw new NotExecutableException();
} else {
RepositoryImpl ri = (RepositoryImpl) r;
PersistenceManager pm = ri.getRepositoryContext().getInternalVersionManager().getPersistenceManager();
if (!(pm instanceof ConsistencyChecker)) {
throw new NotExecutableException();
} else {
return ((ConsistencyChecker) pm).check(null, true, runFix, lostNFoundId, null);
}
}
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class AbstractRepositoryTest method testLogin.
/**
* Tests the {@link AbstractRepository#login()} method.
*
* @throws RepositoryException if an error occurs
*/
public void testLogin() throws RepositoryException {
Repository repository = (Repository) record(AbstractRepository.class);
repository.login(null, null);
replay();
repository.login();
verify();
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class AbstractRepositoryTest method testLoginWithNullCredentials.
/**
* Tests the {@link AbstractRepository#login(Credentials)} method with
* <code>null</code> credentials.
*
* @throws RepositoryException if an error occurs
*/
public void testLoginWithNullCredentials() throws RepositoryException {
Repository repository = (Repository) record(AbstractRepository.class);
repository.login(null, null);
replay();
repository.login((Credentials) null);
verify();
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class AbstractRepositoryTest method testLoginWithWorkspace.
/**
* Tests the {@link AbstractRepository#login(String)} method.
*
* @throws RepositoryException if an error occurs
*/
public void testLoginWithWorkspace() throws RepositoryException {
Repository repository = (Repository) record(AbstractRepository.class);
repository.login(null, "workspace");
replay();
repository.login("workspace");
verify();
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class DirListingExportHandler method exportContent.
/**
* @see IOHandler#exportContent(ExportContext, boolean)
*/
public boolean exportContent(ExportContext context, boolean isCollection) throws IOException {
if (!canExport(context, isCollection)) {
throw new IOException(getName() + ": Cannot export " + context.getExportRoot());
}
// properties (content length undefined)
context.setModificationTime(new Date().getTime());
context.setContentType("text/html", "UTF-8");
context.setETag("");
// data
if (context.hasStream()) {
PrintWriter writer = new PrintWriter(new OutputStreamWriter(context.getOutputStream(), "utf8"));
try {
Item item = context.getExportRoot();
Repository rep = item.getSession().getRepository();
String repName = rep.getDescriptor(Repository.REP_NAME_DESC);
String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);
String repVersion = rep.getDescriptor(Repository.REP_VERSION_DESC);
writer.print("<html><head><title>");
writer.print(Text.encodeIllegalHTMLCharacters(repName));
writer.print(" ");
writer.print(Text.encodeIllegalHTMLCharacters(repVersion));
writer.print(" ");
writer.print(Text.encodeIllegalHTMLCharacters(item.getPath()));
writer.print("</title></head>");
writer.print("<body><h2>");
writer.print(Text.encodeIllegalHTMLCharacters(item.getPath()));
writer.print("</h2><ul>");
writer.print("<li><a href=\"..\">..</a></li>");
if (item.isNode()) {
NodeIterator iter = ((Node) item).getNodes();
while (iter.hasNext()) {
Node child = iter.nextNode();
String label = Text.getName(child.getPath());
writer.print("<li><a href=\"");
writer.print(Text.encodeIllegalHTMLCharacters(Text.escape(label)));
if (child.isNode()) {
writer.print("/");
}
writer.print("\">");
writer.print(Text.encodeIllegalHTMLCharacters(label));
writer.print("</a></li>");
}
}
writer.print("</ul><hr size=\"1\"><em>Powered by <a href=\"");
writer.print(Text.encodeIllegalHTMLCharacters(repURL));
writer.print("\">");
writer.print(Text.encodeIllegalHTMLCharacters(repName));
writer.print("</a> version ");
writer.print(Text.encodeIllegalHTMLCharacters(repVersion));
writer.print("</em></body></html>");
} catch (RepositoryException e) {
// should not occur
log.debug(e.getMessage());
}
writer.close();
}
return true;
}
Aggregations