use of org.apache.jackrabbit.vault.fs.api.VaultFile in project sling by apache.
the class VltSerializationManager method main.
public static void main(String[] args) throws RepositoryException, URISyntaxException, IOException {
RepositoryAddress address = new RepositoryAddress("http://localhost:8080/server/root");
Repository repo = new RepositoryProvider().getRepository(address);
Session session = repo.login(new SimpleCredentials("admin", "admin".toCharArray()));
VaultFileSystem fs = Mounter.mount(null, null, address, "/", session);
String[] attempts = new String[] { "/rep:policy", "/var" };
for (String attempt : attempts) {
VaultFile vaultFile = fs.getFile(attempt);
System.out.println(attempt + " -> " + vaultFile);
}
for (String attempt : attempts) {
attempt = PlatformNameFormat.getPlatformPath(attempt) + EXTENSION_XML;
VaultFile vaultFile = fs.getFile(attempt);
System.out.println(attempt + " -> " + vaultFile);
}
}
use of org.apache.jackrabbit.vault.fs.api.VaultFile in project sling by apache.
the class VltSerializationDataBuilder method findAggregateChain.
/**
* Returns the aggregates for a specific resource
*
* <p>
* In the simplest case, a single element is returned in the chain, signalling that the aggregate is a top-level
* one.
* </p>
*
* <p>
* For leaf aggregates, the list contains the top-most aggregates first and ends up with the leaf-most ones.
* </p>
*
* @param resource the resource to find the aggregate chain for
* @return a list of aggregates
* @throws IOException
* @throws RepositoryException
*/
private List<Aggregate> findAggregateChain(ResourceProxy resource) throws IOException, RepositoryException {
VaultFile vaultFile = fs.getFile(PlatformNameFormat.getPlatformPath(resource.getPath()));
if (vaultFile == null || vaultFile.getAggregate() == null) {
// this file might be a leaf aggregate of a vaultfile higher in the resource path ; so look for a
// parent higher
String parentPath = Text.getRelativeParent(resource.getPath(), 1);
while (!parentPath.equals("/")) {
VaultFile parentFile = fs.getFile(PlatformNameFormat.getPlatformPath(parentPath));
if (parentFile != null) {
Aggregate parentAggregate = parentFile.getAggregate();
ArrayList<Aggregate> parents = new ArrayList<>();
parents.add(parentAggregate);
List<Aggregate> chain = lookForAggregateInLeaves(resource, parentAggregate, parents);
if (chain != null) {
return chain;
}
}
parentPath = Text.getRelativeParent(parentPath, 1);
}
return null;
}
return Collections.singletonList(vaultFile.getAggregate());
}
Aggregations