Query regarding Adobe AEM - java

How can I access the history of a Workflow instance using the Adobe AEM api for java?
Say I've created one workflow which contains 3 workitems. I want to access the details associated with all the workitems for that workflow (E.g.Status,Title,User,StartTime,EndTime,Action,Comment).

Take a look at the following classes.
com.day.cq.workflow.WorkflowSession
https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/workflow/WorkflowService.html
and
com.day.cq.workflow.WorkflowSession
https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/workflow/WorkflowSession.html
If you want to see a code example on how to filter on a particular workflow instance, you can find a lot of documents in the following file of your AEM instance:
/crx/de/index.jsp#/libs/cq/workflow/components/console/archive/json.jsp
In summary, you will need to create a workflow service and fetch the model to iterate over it's instances to apply relevant filters.
Alternatively, you can write a query to get data from /var/eventing/jobs node which is essentially a workflow instance data store.

This might work for you
List<HistoryItem> history = workflowSession.getHistory(workItem.getWorkflow());
HistoryItem current;
if (history.size() > 0) {
HistoryItem current = history.get(history.size() - 1);
do {
current = current.getPreviousHistoryItem();
} while (current != null);
}

Related

How to list Streams owned by a Project Area using Jazz RTC Java API

I am working an automation for IBM Rational Team Concert (IBM aka Jazz RTC).
How may one list all streams owned by a specific project area?
Which are the required API calls?
I could not find any getters in the IProjectArea instance, nor service or client instances with such methods. And I could not figure out how to use search criteria for this purpose.
The streams owned by a project area may be queried using IWorkspaceSearchCriteria. Because streams are, actually, workspaces of type 'stream'. The API is not quite clear how to specify the owning project area.
Get the IWorkspaceManager from the ITeamRepository, which contains the findWorkspaces method.
You don't need IProjectAreaHandle. Only the project area name.
Create a IWorkspaceSearchCriteria and set kind to IWorkspaceSearchCriteria.STREAMS and set exactOwnerName to the string containing the project area name.
Call IWorkspaceManager.findWorkspaces(...) to get a list of IWorkspaceHandles. The first parameter is the search criteria. Se second parameter is the maximum number of results (which I set to IWorkspaceManager.MAX_QUERY_SIZE, which is 512. The third parameter is the progress monitor, which may be null.
If you need to get stream name, description or other attributes, then you need to call IItemManager.fetchCompleteItems(...) fetch the full IWorkspace instances.
Here is an example in Groovy:
Lit<IComponentHandle> listComponents(String projectAreaName) {
final manager = repositoty.getClientLibrary(IWorkspaceManager) as IWorkspaceManager;
final criteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
criteria.setKind(IWorkspaceSearchCriteria.STREAMS);
criteria.setExactOwnerName(projectAreaName)
final itemManager = repositoty.itemManager()
return itemManager.fetchCompleteItems(handles, IItemManager.DEFAULT, null) as List<IWorkspace>
}

SailPoint reporting limit user view

We have 5 custom reports for our 94 districts. A capability grants access to these custom reports.
The issue is that each district should not see the report results from another district.
Currently, the only alternative is to create 5 * 94 = 470 custom reports, granting a set of 5 to each district. However, this is cumbersome when a report needs to be updated.
TaskDefinitions (Reports) create TaskResult objects (the result of a report). In addition, to the TaskResult object, a JasperReport object is created. Neither the TaskResult/JasperResult object "re-executes" BeanShell when you open the task result.
Is there a way to only have 5 reports and scope the results so that only users in that district can see them?
I have an example of how this might be achieved when based on this code below which will look at the scope(s) of the one who is running the report. It will only return identities that are in the same scope as the one that is running the report
// Retrieve Scope of Executor then filter all Identities on that Scope only
import org.apache.commons.logging.Log;
import sailpoint.object.Filter;
import sailpoint.object.Identity;
import sailpoint.object.Scope;
Identity identity = context.getObjectByName(Identity.class, arguments.get("launcher"));
if (identity != null) {
String scopeName = identity.getAssignedScope().getDisplayableName();
List roleFilters = new ArrayList();
if (scopeName!= null) {
roleFilters.add(Filter.eq("identity.assignedScope.name", scopeName));
}
if (!roleFilters.isEmpty()) {
queryOptions.addFilter(Filter.or(roleFilters));
}
} else {
// When Saving with Preview or Execute the Launcher is empty so all results would be shown.
// This filter will prevent that (creates empty report, it works when executed from the My Reports
queryOptions.addFilter(Filter.eq("identity.name", "xxx"));
}
return queryOptions;
The problem with the code sample above:
This will create the report intended for Group A, however Group B, and C will also be able to view it.
So the end goal is to have one report that anyone can run, however only the data that is associated with that scope is visible no matter what user group is involved (scope). So Group B would only be able to view Group B even if Group A ran it.
I think you don't have good options here.
What comes to my mind is to create these reports programatically (writing some script to generate the XML artifact for the TaskDefinition and importing/exporting using IIQDA for example) and maintain them in the same way, so everytime you need to change each one of these hundreds of artifacts, you can just re-generate them via code.
The only thing I'd do in a different way is to use 94 scopes for each 5-set report instead of using capabilities.

How to get all OpenText Content Server categories in one call?

I'm currently on a project that involves OpenText Content Server 10.5 SP1 Update 2015-03.
I'm trying to find out if is possible to get all categories from the System Category Volume with one call using Java SOAP web services or REST.
On the web services side I found a couple of methods exposed by the DocumentManagement WSDL GetCategoryDefinition and GetCategoryDefinitions which require categoryIDs as argument.
On the REST side I managed to obtain access to categories but after a quite long trip:
call to otcs/cs.exe?func=search.GetCategoryVolume gives as a response an URL for the subsequent call
call to otcs/cs.exe?func=ll&ObjID=2005&objAction=XMLExport&scope=1 gives the id of the system category volume along with category IDs
call to otcs/cs.exe?func=ll&ObjID=21361&objAction=XMLExport&scope=1 gives the required info about the category.
I would like to have a single call returning all information about categories I need.
Is it possible to achieve that?
It's possible.
What you need to do:
1.) Find all IDs of the Categories, you want the definitions for
2.) call DocumentManagementWS.getCategoryDefinitions(IDs)
example
In my project we store all Categories in Folders, and not in the CategoryVolume of Content server.
// INFO: variable dm is an instance of the documentManagement-Webservice
// 1.) read the folder of the Categories
Node categoryRoot = dm.getNodeByPath(configRoot.getID(), Arrays.asList("Categories"));
// 2.) find all Ids of the categories
List<Node> categories = dm.listNodes(categoryRoot.getID(), false);
if (categories != null) {
for (Node category : categories) {
if (category.getType().equals("Category")) {
categoryIds.add(category.getID());
}
}
}
// 3.) Read all defintitions of the categories
List<AttributeGroupDefinition> categoryDefinitions = dm.getCategoryDefinitions(categoryIds);
Maybe not exactly program oriented but you know about the handler "cs.exe?func=attributes.dump" ? This is the UI version of what you are asking.

How to get the id of commit using JavaGit library?

I use this code from the JavaGit example:
File repositoryDirectory = new File("Library\\build\\jar\\");
DotGit dotGit = DotGit.getInstance(repositoryDirectory);
// Print commit messages of the current branch
for (Commit c : dotGit.getLog()) {
System.out.println(c.getMessage());
}
How could I get the id of commit this way?
Or it might be more appropriate library to interact with git?
According to the documentation (I don't know very much this library), you should invoke the getCommitName() method and use the returned Ref object to get the information you want (I think the SHA1 hash or the tag).

Getting Lotus Notes data from Document

I am using a local database in my version of Lotus notes(8.5.2), and I am trying to get the data for two things:
The highlighted document/item in a NotesUIView
The document selected in a NotesUIDocument
However, all I get are the Notes URLs and I don't know what I should do with those. Can anyone help me out/throw me a breadcrumb?
P.S. Yes I am using the Java API for Eclipse.
Here is a code sample of what I do:
NotesUIWorkspace workSpace = new NotesUIWorkspace();
NotesUIElement currentElement = workSpace.getCurrentElement();
if (currentElement instanceof NotesUIView) {
NotesUIView currentView = (NotesUIView) currentElement;
NotesUIViewEntryCollection collection = currentView
.getActionableEntries();
Iterator docIterator = collection.documentIterator();
while (docIterator.hasNext()) {
NotesUIDocumentEntry entry = (NotesUIDocumentEntry) docIterator.next();
//I can't seem to get to the NoesUIDocument case like I can below... I want fields!
}
}
if(currentElement instanceof NotesUIDocument){
NotesUIDocument document = (NotesUIDocument) currentElement;
//Seem to be able to get the correct data fields only in this case!
document.getFields();
}
Fetching the "current" document is usually done via the NotesAgentContext.UnprocessedDocuments. In a view, that might return a collection of documents if the user as ticked several.
If you already have an NotesUIView, NotesUIView.getActionableEntries will give you the selected document(s).
When you have a NotesDocumentData instance, NotesUIWorkspace.openDocument can be used to open it up in edit mode. Then NotesUIWorkspace.getCurrentDocument can be used to get hold of the UI Document.
Notice that if you only want to read values from the document, it is more convenient to use the back-end classes like Document.
Have you got a URL as an example? If it includes the UUID of the document in question then you should be able to reference it directly with a getDocument(). Otherwise, the URL should include a view reference and a lookup key for that view in question.

Categories

Resources