本文整理汇总了Java中gov.nih.nci.security.authorization.domainobjects.Role.getPrivileges方法的典型用法代码示例。如果您正苦于以下问题:Java Role.getPrivileges方法的具体用法?Java Role.getPrivileges怎么用?Java Role.getPrivileges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gov.nih.nci.security.authorization.domainobjects.Role
的用法示例。
在下文中一共展示了Role.getPrivileges方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrivileges
import gov.nih.nci.security.authorization.domainobjects.Role; //导入方法依赖的package包/类
public Set getPrivileges(String roleId) throws CSObjectNotFoundException {
Session s = null;
Set result = new HashSet();
try {
s = HibernateSessionFactoryHelper.getAuditSession(sf);
Role role = (Role) this.getObjectByPrimaryKey(s, Role.class,
new Long(roleId));
result = role.getPrivileges();
List list = new ArrayList();
Iterator toSortIterator = result.iterator();
while(toSortIterator.hasNext()){ list.add(toSortIterator.next()); }
Collections.sort(list);
result.clear();
result.addAll(list);
log.debug("The result size is: " + result.size());
} catch (Exception ex) {
if (log.isDebugEnabled())
log
.debug("Authorization|||getPrivileges|Failure|Error obtaining Associated Privileges for Role id "
+ roleId + "|" + ex.getMessage());
throw new CSObjectNotFoundException(
"An error occured in obtaining associated Privileges for the given Role\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||assignGroupRoleToProtectionGroup|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||getPrivileges|Success|Successful in obtaining Associated Privileges for Role id "
+ roleId + "|");
return result;
}
示例2: addPrivilegesToRole
import gov.nih.nci.security.authorization.domainobjects.Role; //导入方法依赖的package包/类
public void addPrivilegesToRole(String roleId, String[] privilegeIds)
throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
s = HibernateSessionFactoryHelper.getAuditSession(sf);
Role role = (Role) s.load(Role.class,new Long(roleId));
if(role==null) throw new CSTransactionException("Authorization|||addPrivilegesToRole|| Unable to retrieve Role with Id :"+roleId);
Set<Privilege> privs = role.getPrivileges();
for (int k = 0; k < privilegeIds.length; k++) {
boolean assigned = false;
if(privilegeIds[k]!=null && privilegeIds[k].length()>0){
Privilege pr = (Privilege) s.load(Privilege.class,new Long(privilegeIds[k]));
if (pr != null) {
Iterator it=privs.iterator();
while(it.hasNext()){
Privilege p = (Privilege)it.next();
if(p.equals(pr)) assigned=true;
}
if(!assigned) privs.add(pr);
}
}
}
role.setPrivileges(privs);
t = s.beginTransaction();
s.update(role);
t.commit();
s.flush();
auditLog.info("Adding Privileges to Role " + role.getName());
} catch (Exception ex) {
log.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (log.isDebugEnabled())
log
.debug("Authorization|||addPrivilegesToRole|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||addPrivilegesToRole|Failure|Error Occured in assigning Privilege "
+ StringUtilities
.stringArrayToString(privilegeIds)
+ " to Role " + roleId + "|" + ex.getMessage());
throw new CSTransactionException(
"An error occurred in adding Privileges to Role\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||addPrivilegesToRole|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||addPrivilegesToRole|Success|Success in assigning Privilege "
+ StringUtilities.stringArrayToString(privilegeIds)
+ " to Role " + roleId + "|");
}
示例3: addPrivilegesToRole
import gov.nih.nci.security.authorization.domainobjects.Role; //导入方法依赖的package包/类
public void addPrivilegesToRole(String roleId, String[] privilegeIds)
throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
s = HibernateSessionFactoryHelper.getAuditSession(sf);
Role role = (Role) s.load(Role.class,new Long(roleId));
if(role==null) throw new CSTransactionException("Authorization|||addPrivilegesToRole|| Unable to retrieve Role with Id :"+roleId);
Set<Privilege> privs = role.getPrivileges();
for (int k = 0; k < privilegeIds.length; k++) {
boolean assigned = false;
if(privilegeIds[k]!=null && privilegeIds[k].length()>0){
Privilege pr = (Privilege) s.load(Privilege.class,new Long(privilegeIds[k]));
if (pr != null) {
Iterator it=privs.iterator();
while(it.hasNext()){
Privilege p = (Privilege)it.next();
if(p.equals(pr)) assigned=true;
}
if(!assigned) privs.add(pr);
}
}
}
role.setPrivileges(privs);
t = s.beginTransaction();
s.update(role);
t.commit();
s.flush();
auditLog.info("Adding Privileges to Role " + role.getName());
} catch (Exception ex) {
log.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (log.isDebugEnabled())
log
.debug("Authorization|||addPrivilegesToRole|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||addPrivilegesToRole|Failure|Error Occured in assigning Privilege "
+ StringUtilities
.stringArrayToString(privilegeIds)
+ " to Role " + roleId + "|" + ex.getMessage());
throw new CSTransactionException(
"An error occurred in adding Privileges to Role\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||addPrivilegesToRole|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||addPrivilegesToRole|Success|Success in assigning Privilege "
+ StringUtilities.stringArrayToString(privilegeIds)
+ " to Role " + roleId + "|");
}
示例4: getPrivileges
import gov.nih.nci.security.authorization.domainobjects.Role; //导入方法依赖的package包/类
public Set getPrivileges(String roleId) throws CSObjectNotFoundException {
Session s = null;
Set result = new HashSet();
try {
s = HibernateSessionFactoryHelper.getAuditSession(sf);
Role role = (Role) this.getObjectByPrimaryKey(s, Role.class,
new Long(roleId));
result = role.getPrivileges();
List list = new ArrayList();
Iterator toSortIterator = result.iterator();
while(toSortIterator.hasNext()){ list.add(toSortIterator.next()); }
Collections.sort(list);
result.clear();
result.addAll(list);
log.debug("The result size is: " + result.size());
} catch (Exception ex) {
if (log.isDebugEnabled())
log
.debug("Authorization|||getPrivileges|Failure|Error obtaining Associated Privileges for Role id "
+ roleId + "|" + ex.getMessage());
throw new CSObjectNotFoundException(
"An error occured in obtaining associated Privileges for the given Role\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||assignGroupRoleToProtectionGroup|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||getPrivileges|Success|Successful in obtaining Associated Privileges for Role id "
+ roleId + "|");
return result;
}