cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

AccessControlHelper to check 'Download' Access permission

rbhosale
1-Visitor

AccessControlHelper to check 'Download' Access permission

Hello,

I want to check if particular windchill user has 'download' access permission to WTDocument on Windchill 9.1 M040 instance. I am using following Windchill API. But it is always returning 'true' value even if user has download access 'false'. Windchill UI behaves correctly. But API seems to fail. Can anyone help me out please.

QueryResult result;
wt.query.QuerySpec spec;
WTDocumentMaster doc = null;
WTUser user = null;
spec = new QuerySpec(WTDocumentMaster.class);
spec.appendWhere(new SearchCondition(WTDocumentMaster.class, "name", "=", "New Text Document"), 0);
spec.appendAnd();
spec.appendWhere(new SearchCondition(WTDocumentMaster.class, "number", "=", "0000000061"), 0);
result = PersistenceHelper.manager.find(spec);
while(result.hasMoreElements())
{
doc = (WTDocumentMaster)result.nextElement();
}
spec = new QuerySpec(WTUser.class);
spec.appendWhere(new SearchCondition(WTUser.class, "name", "=", "demo"), 0);
result = PersistenceHelper.manager.find(spec);
while(result.hasMoreElements())
{
user = (WTUser)result.nextElement();
}
boolean hasAccess = AccessControlHelper.manager.hasAccess(user, doc, AccessPermission.DOWNLOAD);
System.out.println("hasAccess:"+hasAccess);

Value of 'hasAccess' is always 'true'. Can anyone help please.

Thanks and Best Regards,

Rekha Bhosale

-------------------------------------

1 REPLY 1

A little late, but I thoguht it would be good to answer the question anyway since no one else did answer.

This is your problem line:

doc = (WTDocumentMaster)result.nextElement();

You are passing in the Master and not a specific Version of the WTDocument.

WTDocument implements AccessControlled interface.

David DeMay

Announcements


Top Tags