*/
public static void buildObr(final ObrMetadataSource source, final RepositoryItemUid uid, final Repository target,
final Walker walker)
throws StorageException
{
final ObrResourceWriter writer = source.getWriter(uid);
try {
final AbstractFileWalkerProcessor obrProcessor = new AbstractFileWalkerProcessor()
{
@Override
protected void processFileItem(final WalkerContext context, final StorageFileItem item)
throws IOException
{
final Resource resource = source.buildResource(item);
if (null != resource) {
writer.append(resource);
}
}
};
final ResourceStoreRequest request = new ResourceStoreRequest("/");
final DefaultWalkerContext ctx = new DefaultWalkerContext(target, request, new ObrWalkerFilter());
ctx.getProcessors().add(obrProcessor);
walker.walk(ctx);
writer.complete(); // the OBR is only updated once the stream is complete and closed
}
catch (final WalkerException e) {
writer.complete();
}
finally {
IOUtils.closeQuietly(writer);
}
}