It's all about the answers!

Ask a question

Can not save Work Item due to permission issue


cheng yingying (324) | asked Dec 05 '14, 3:30 a.m.
edited Dec 07 '14, 8:57 p.m.
I'm trying to use RTC Plain JAVA API to create a defect.
  
I have the permission to create a defect from UI.
But I've got following error when I have set values and save a defect work item.  

Does the following error mean I don't have the permission to create a defect by API? Thanks.

com.ibm.team.process.common.advice.TeamOperationCanceledException : CRJAZ6053E The 'Save Work Item' operation cannot be completed. Permission is required to complete the operation.
      at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.advise( OperationAdviceManager.java:387 )
...
 
Name: Save Work Item
      ID: com.ibm.team.workitem.operation.workItemSave
      Severity: ERROR
            Name: Required Properties
            ID: com.ibm.team.workitem.advisor.requiredProperties
            Severity: OK
            Name: Required Approvals
            ID: com.ibm.team.workitem.advisor.requiredApprovals
            Severity: OK
            Name: All Children Resolved
            ID: com.ibm.team.workitem.advisor.allChildrenClosed
            Severity: OK
            Name: Save Project Area
            ID: com.ibm.team.process.server.saveProjectArea
            Severity: ERROR
                  Summary: Permission Denied
                  Description: You don't have permission to perform the following actions:
  Modify the process specification (modify/specification)
                  Severity: ERROR
                  Name: Avoid saving private roles
                  ID: com.ibm.ics.scm.rtc.privateroles.project
                  Severity: OK

sam detweiler replied me in another question.

Looks like you are trying to save the project area.. not just the workitem 

ID: com.ibm.team.process.server.saveProjectArea 

But I believe I'm saving a work item(defect), don't know why it triggered the saveProjectArea. Following is the related code. And I have used the similar code to save a work item(task) successfully. Confused.

Any tips? Thanks a lot.
private static class WorkItemInitialization extends WorkItemOperation {
private String fSummary;
private ICategoryHandle fCategory;
private IIterationHandle fIteration;
HashMap<iattribute, Object=""> fAttributes;
public WorkItemInitialization(String summary, ICategoryHandle category, IIterationHandle iteration, HashMap attributes) {
super("Initializing Work Item");
fSummary= summary;
fCategory= category;
fAttributes = attributes;
fIteration = iteration;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy, IProgressMonitor monitor) throws TeamRepositoryException {
IWorkItem workItem= workingCopy.getWorkItem();
workItem.setHTMLSummary(XMLString.createFromPlainText(fSummary));
workItem.setCategory(fCategory);

workItem.setTarget(fIteration); 
Iterator keys = fAttributes.keySet().iterator();
while(keys.hasNext()){
IAttribute key = (IAttribute)keys.next();
Object value = fAttributes.get(key);
workItem.setValue(key, value);
}
}
}
.....


String repositoryURI= "https://xxx.ibm.com:8001/jazz/";
String userId= "XXXX";
String password= "YYYY";
String projectAreaName= "Lotus Connections";
String typeIdentifier= "defect";

String summary = "Post install bvt";
String categoryName= "Web/Cross Functional/Automation";//args[6];//filedAgainst
String plannedFor = "Main development/Release Backlog/2014 Development";//required by task, defect
String foundIn = "Automated BVT";//required by defect
String qaTeam = "Functional (FVT)";//required by defect
String phaseFound = "Functional (FVT)";//required by defect
...
 
IWorkItemType workItemType= workItemClient.findWorkItemType(projectArea, typeIdentifier, null);
if (workItemType == null) {
System.out.println("Work item type not found.");
return false;
}
....

IAttribute phaseAttribute = workItemClient.findAttribute(projectArea, "howfound", null);
Identifier literalID_phase = null;
IEnumeration enumeration_phase =workItemClient.resolveEnumeration(phaseAttribute, null);
List literals_phase = enumeration_phase.getEnumerationLiterals();
for (Iterator iterator = literals.iterator(); iterator.hasNext();) {
ILiteral iLiteral = (ILiteral) iterator.next();
if (iLiteral.getName().equals(phaseFound)) {
literalID_phase = iLiteral.getIdentifier2();
System.out.println("You found phase!!");
break;
}
}
if(literalID_phase==null){
System.out.println("not found phase");
return false;
}
attributes.put(foundInAttribute, foundIN);
attributes.put(qaAttribute, literalID);
attributes.put(phaseAttribute, literalID_phase);
...

WorkItemInitialization operation= new WorkItemInitialization(summary, category, cih, attributes);
IWorkItemHandle handle= operation.run(workItemType, null);
IWorkItem workItem= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null);
System.out.println("Created work item " + workItem.getId() + ".");

2 answers



permanent link
Ralph Schoon (63.5k33646) | answered Dec 05 '14, 5:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I agree with Sam but I am not sure why it happens either.

My suggestion would be to create your own test system where you can modify the permissions, get your code to work and then try it a gain on the current project area and find out what the difference is.

permanent link
Brian Fleming (1.6k11928) | answered Dec 05 '14, 1:29 p.m.
I suspect its the Planned For value.  I have seen a similar error when importing workitems that have a Planned For value that does not yet exist in the Project Area.  The work item creation is attempting to add the Planned For value you specify to the project area but is failing because you don't have a role with permission to do that.  Note that children iterations of the out of the box "Main Development" timeline should start with "development/..." not "Main development/..." as you have.
Try
String plannedFor = "development/Release Backlog/2014 Development";//required by task, defect
instead.   

Comments
sam detweiler commented Dec 05 '14, 2:53 p.m.

good catch... I had this problem on import (the extra iterations and categories were created)..  I had admin so no error.

see the actual label string for the iterations.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.