public final Page create(final ResourceResolver resourceResolver, String bucketSegment,
final String name, final String... paths) throws WCMException,
RepositoryException {
final Session session = resourceResolver.adaptTo(Session.class);
final PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
String bucketPath = "/etc/workflow/packages";
if (StringUtils.isNotBlank(bucketSegment)) {
bucketPath += "/" + bucketSegment;
}
final Node shardNode = JcrUtils.getOrCreateByPath(bucketPath,
NT_SLING_FOLDER, NT_SLING_FOLDER, session, false);
final Page page = pageManager.create(shardNode.getPath(), JcrUtil.createValidName(name),
WORKFLOW_PACKAGE_TEMPLATE, name, false);
final Resource contentResource = page.getContentResource();
Node node = JcrUtil.createPath(contentResource.getPath() + "/vlt:definition", NT_VLT_DEFINITION, session);
node = JcrUtil.createPath(node.getPath() + "/filter", JcrConstants.NT_UNSTRUCTURED, session);