本文整理汇总了Java中gov.nih.nci.security.authorization.domainobjects.ProtectionElement.setProtectionGroups方法的典型用法代码示例。如果您正苦于以下问题:Java ProtectionElement.setProtectionGroups方法的具体用法?Java ProtectionElement.setProtectionGroups怎么用?Java ProtectionElement.setProtectionGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gov.nih.nci.security.authorization.domainobjects.ProtectionElement
的用法示例。
在下文中一共展示了ProtectionElement.setProtectionGroups方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProtectionElement
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void createProtectionElement(StudyConfiguration studyConfiguration) throws CSException {
if (doesUserExist(studyConfiguration.getUserWorkspace().getUsername())) {
User user = retrieveCsmUser(studyConfiguration.getUserWorkspace().getUsername());
String userId = String.valueOf(user.getUserId());
ProtectionElement element = createProtectionElementInstance(studyConfiguration);
element.setProtectionElementName(studyConfiguration.getStudy().getShortTitleText());
Set<User> owners = new HashSet<User>();
owners.add(user);
element.setOwners(owners);
element.setProtectionGroups(retrieveProtectionGroups(userId, STUDY_MANAGER_ROLE));
getAuthorizationManager().createProtectionElement(element);
}
}
示例2: assignToProtectionGroups
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void assignToProtectionGroups(String protectionElementId,
String[] protectionGroupIds) throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
s = HibernateSessionFactoryHelper.getAuditSession(sf);
ProtectionElement protectionElement = (ProtectionElement) this
.getObjectByPrimaryKey(s, ProtectionElement.class,
new Long(protectionElementId));
s.close();
Set newSet = new HashSet();
for (int k = 0; k < protectionGroupIds.length; k++) {
log.debug("The new list:" + protectionGroupIds[k]);
ProtectionGroup pg = (ProtectionGroup) this
.getObjectByPrimaryKey(ProtectionGroup.class,
protectionGroupIds[k]);
if (pg != null) {
newSet.add(pg);
}
}
protectionElement.setProtectionGroups(newSet);
s = HibernateSessionFactoryHelper.getAuditSession(sf);
t = s.beginTransaction();
s.update(protectionElement);
t.commit();
s.flush();
auditLog.info("Assigning Protection Groups to Protection Element with Object Id " + protectionElement.getObjectId() + " and Attribute " + protectionElement.getAttribute());
} catch (Exception ex) {
log.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (log.isDebugEnabled())
log
.debug("Authorization|||assignToProtectionGroups|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||assignToProtectionGroups|Failure|Error in assigning Protection Groups "
+ StringUtilities
.stringArrayToString(protectionGroupIds)
+ " to protection element id "
+ protectionElementId + "|" + ex.getMessage());
throw new CSTransactionException(
"An error occurred in assigning Protection Groups to the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||assignToProtectionGroups|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||assignToProtectionGroups|Success|Successful in assigning Protection Groups Back Transaction"
+ StringUtilities
.stringArrayToString(protectionGroupIds)
+ " to protection element id "
+ protectionElementId + "|");
}
示例3: addToProtectionGroups
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void addToProtectionGroups(String protectionElementId,
String[] protectionGroupIds) throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
s = HibernateSessionFactoryHelper.getAuditSession(sf);
ProtectionElement protectionElement = (ProtectionElement) s.load(ProtectionElement.class,new Long(protectionElementId));
if(protectionElement==null)
throw new CSTransactionException("Authorization|||addToProtectionGroups|| Unable to retrieve Protection Element with ProtectionElementId :"+protectionElementId);
Set<ProtectionGroup> protectionGroups = protectionElement.getProtectionGroups();
if(protectionGroups==null)
protectionGroups = new HashSet();
for (int k = 0; k < protectionGroupIds.length; k++) {
boolean assigned = false;
if(protectionGroupIds[k]!=null && protectionGroupIds[k].length()>0){
ProtectionGroup pr = (ProtectionGroup) s.load(ProtectionGroup.class,new Long(protectionGroupIds[k]));
if (pr != null) {
Iterator it=protectionGroups.iterator();
while(it.hasNext()){
ProtectionGroup p = (ProtectionGroup)it.next();
if(p.equals(pr)) assigned=true;
}
if(!assigned) protectionGroups.add(pr);
}
}
}
protectionElement.setProtectionGroups(protectionGroups);
t = s.beginTransaction();
s.update(protectionElement);
t.commit();
s.flush();
auditLog.info("Adding Protection Groups to Protection Element with Object Id " + protectionElement.getObjectId() + " and Attribute " + protectionElement.getAttribute());
} catch (Exception ex) {
log.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (log.isDebugEnabled())
log
.debug("Authorization|||addToProtectionGroups|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||addToProtectionGroups|Failure|Error in assigning Protection Groups "
+ StringUtilities
.stringArrayToString(protectionGroupIds)
+ " to protection element id "
+ protectionElementId + "|" + ex.getMessage());
throw new CSTransactionException(
"An error occurred in adding Protection Groups to the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||addToProtectionGroups|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||addToProtectionGroups|Success|Successful in adding Protection Groups"
+ StringUtilities
.stringArrayToString(protectionGroupIds)
+ " to protection element id "
+ protectionElementId + "|");
}
示例4: addToProtectionGroups
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void addToProtectionGroups(String protectionElementId,
String[] protectionGroupIds) throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
s = HibernateSessionFactoryHelper.getAuditSession(sf);
ProtectionElement protectionElement = (ProtectionElement) s.load(ProtectionElement.class,new Long(protectionElementId));
if(protectionElement==null)
throw new CSTransactionException("Authorization|||addToProtectionGroups|| Unable to retrieve Protection Element with ProtectionElementId :"+protectionElementId);
Set<ProtectionGroup> protectionGroups = protectionElement.getProtectionGroups();
if(protectionGroups==null)
protectionGroups = new HashSet();
for (int k = 0; k < protectionGroupIds.length; k++) {
boolean assigned = false;
if(protectionGroupIds[k]!=null && protectionGroupIds[k].length()>0){
ProtectionGroup pr = (ProtectionGroup) s.load(ProtectionGroup.class,new Long(protectionGroupIds[k]));
if (pr != null) {
Iterator it=protectionGroups.iterator();
while(it.hasNext()){
ProtectionGroup p = (ProtectionGroup)it.next();
if(p.equals(pr)) assigned=true;
}
if(!assigned) protectionGroups.add(pr);
}
}
}
protectionElement.setProtectionGroups(protectionGroups);
t = s.beginTransaction();
s.update(protectionElement);
t.commit();
s.flush();
auditLog.info("Adding Protection Groups to Protection Element with Object Id " + protectionElement.getObjectId() + " and Attribute " + protectionElement.getAttribute());
} catch (Exception ex) {
log.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (log.isDebugEnabled())
log
.debug("Authorization|||addToProtectionGroups|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||addToProtectionGroups|Failure|Error in assigning Protection Groups "
+ StringUtilities
.stringArrayToString(protectionGroupIds)
+ " to protection element id "
+ protectionElementId + "|" + ex.getMessage());
throw new CSTransactionException(
"An error occurred in adding Protection Groups to the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||addToProtectionGroups|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||addToProtectionGroups|Success|Successful in adding Protection Groups"
+ StringUtilities
.stringArrayToString(protectionGroupIds)
+ " to protection element id "
+ protectionElementId + "|");
}
示例5: assignToProtectionGroups
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void assignToProtectionGroups(String protectionElementId,
String[] protectionGroupIds) throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
s = HibernateSessionFactoryHelper.getAuditSession(sf);
ProtectionElement protectionElement = (ProtectionElement) this
.getObjectByPrimaryKey(s, ProtectionElement.class,
new Long(protectionElementId));
s.close();
Set newSet = new HashSet();
for (int k = 0; k < protectionGroupIds.length; k++) {
log.debug("The new list:" + protectionGroupIds[k]);
ProtectionGroup pg = (ProtectionGroup) this
.getObjectByPrimaryKey(ProtectionGroup.class,
protectionGroupIds[k]);
if (pg != null) {
newSet.add(pg);
}
}
protectionElement.setProtectionGroups(newSet);
s = HibernateSessionFactoryHelper.getAuditSession(sf);
t = s.beginTransaction();
s.update(protectionElement);
t.commit();
s.flush();
auditLog.info("Assigning Protection Groups to Protection Element with Object Id " + protectionElement.getObjectId() + " and Attribute " + protectionElement.getAttribute());
} catch (Exception ex) {
log.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (log.isDebugEnabled())
log
.debug("Authorization|||assignToProtectionGroups|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||assignToProtectionGroups|Failure|Error in assigning Protection Groups "
+ StringUtilities
.stringArrayToString(protectionGroupIds)
+ " to protection element id "
+ protectionElementId + "|" + ex.getMessage());
throw new CSTransactionException(
"An error occurred in assigning Protection Groups to the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||assignToProtectionGroups|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||assignToProtectionGroups|Success|Successful in assigning Protection Groups Back Transaction"
+ StringUtilities
.stringArrayToString(protectionGroupIds)
+ " to protection element id "
+ protectionElementId + "|");
}