Skip to content

Instantly share code, notes, and snippets.

@maheshakya
Created May 7, 2014 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maheshakya/aa2f135077ae558a5f3d to your computer and use it in GitHub Desktop.
Save maheshakya/aa2f135077ae558a5f3d to your computer and use it in GitHub Desktop.
This code snippet shows how to retrieve values of check list items, states, lifecycle names, paths of resources in the WSO2 Governance Registry
import org.wso2.carbon.governance.api.exception.GovernanceException;
import org.wso2.carbon.registry.core.Resource;
import java.util.Enumeration;
class SomeClass(){
private final String REGISTRY_LC_NAME = "registry.LC.name";
private final String REGISTRY_LIFECYCLE = "registry.lifecycle.";
private final String REGISTRY_CUSTOM_LIFECYCLE_CHECKLIST = "registry.custom_lifecycle.checklist.option.";
private final String REGISTRY_CUSTOM_LIFECYCLE_VOTE = "registry.custom_lifecycle.votes.option." ;
private final String REGISTRY_ASPECTS = "registry.Aspects";
public String[] getCheckListItemsList(Resource resource){
String[] checkListItemsList = null;
Enumeration en = resource.getProperties().propertyNames();
String str;
int checkItems = 0;
while(en.hasMoreElements()){
str = (String) en.nextElement();
if (str.startsWith(REGISTRY_CUSTOM_LIFECYCLE_CHECKLIST)){
checkItems++;
}
}
checkItems = checkItems/2;
if(checkItems>0){
checkListItemsList = new String[checkItems];
String ITEM_VALUE;
for(int i=0;i<checkItems;i++){
ITEM_VALUE=resource.getPropertyValues(REGISTRY_CUSTOM_LIFECYCLE_CHECKLIST +i +".item").get(3);
checkListItemsList[i] = ITEM_VALUE.substring(6);
}
}
return checkListItemsList;
}
public String getResourceLCName(Resource resource){
String resourceLCName = resource.getProperty(REGISTRY_LC_NAME);
return resourceLCName;
}
public String getResourcePath(Resource resource){
String resourcePath = resource.getPath();
return resourcePath;
}
public String getResourceState(Resource resource){
String resourceLCName = resource.getProperty(REGISTRY_LC_NAME);
String stateProperty = REGISTRY_LIFECYCLE + resourceLCName + ".state";
resourceCurrentState = resource.getProperty(stateProperty);
return resourceCurrentState;
}
}
@maheshakya
Copy link
Author

You can use a similar method to getCheckListItemsList, if you want to get vote items list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment