Document document = publication.getDocumentBuilder().buildDocument(publication, url);
File configDir = new File(publication.getDirectory(), FileItemManager.PATH);
assertTrue(configDir.exists());
Policy policy = getPolicyManager().getPolicy(getAccreditableManager(), url);
DocumentType type = DocumentTypeBuilder.buildDocumentType(documentTypeName, publication);
String workflowId = type.getWorkflowFileName();
WorkflowFactory factory = WorkflowFactory.newInstance();
String[] emptyRoles = {
};
Situation situation = factory.buildSituation(emptyRoles, "test", "127.0.0.1");
WorkflowFactory.initHistory(document, workflowId, situation);
for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
WorkflowInstance instance = null;
instance = factory.buildInstance(document);
assertNotNull(instance);
System.out.println("Current state: " + instance.getCurrentState());
Identity identity = new Identity();
User user =
getAccreditableManager().getUserManager().getUser(
situations[situationIndex].getUser());
identity.addIdentifiable(user);
Role[] roles = policy.getRoles(identity);
System.out.print("Roles:");
for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
System.out.print(" " + roles[roleIndex]);
}