本文整理汇总了Java中gov.nih.nci.security.authorization.domainobjects.ProtectionElement.setOwners方法的典型用法代码示例。如果您正苦于以下问题:Java ProtectionElement.setOwners方法的具体用法?Java ProtectionElement.setOwners怎么用?Java ProtectionElement.setOwners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gov.nih.nci.security.authorization.domainobjects.ProtectionElement
的用法示例。
在下文中一共展示了ProtectionElement.setOwners方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setOwnerForProtectionElement
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void setOwnerForProtectionElement(String protectionElementObjectId,
String[] userNames) throws CSTransactionException {
Session s = null;
Transaction t = null;
if (StringUtilities.isBlank(protectionElementObjectId)) {
throw new CSTransactionException("object Id can't be null!");
}
try {
Set users = new HashSet();
for (int i = 0; i < userNames.length; i++) {
User user = this.getUser(userNames[i]);
if (user != null) {
users.add(user);
}
}
ProtectionElement pe = new ProtectionElement();
pe.setObjectId(protectionElementObjectId);
pe.setApplication(application);
SearchCriteria sc = new ProtectionElementSearchCriteria(pe);
List l = this.getObjects(sc);
ProtectionElement protectionElement = (ProtectionElement) l.get(0);
protectionElement.setOwners(users);
s = HibernateSessionFactoryHelper.getAuditSession(sf);
t = s.beginTransaction();
s.update(protectionElement);
t.commit();
s.flush();
auditLog.info("Assigning Users as Owner for 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|||setOwnerForProtectionElement|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwnerForProtectionElement|Failure|Error Setting owner for Protection Element object Name"
+ protectionElementObjectId
+ " for users "
+ StringUtilities
.stringArrayToString(userNames)
+ "|"
+ ex.getMessage());
throw new CSTransactionException(
"An error occured in setting multiple owners for the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwnerForProtectionElement|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwnerForProtectionElement|Success|Successful in Setting owner for Protection Element object Name"
+ protectionElementObjectId
+ " for users "
+ StringUtilities.stringArrayToString(userNames)
+ "|");
}
示例3: assignOwners
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void assignOwners(String protectionElementId, String[] userIds)
throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
Set users = new HashSet();
for (int i = 0; i < userIds.length; i++) {
User user = (User) this.getObjectByPrimaryKey(User.class,
userIds[i]);
users.add(user);
}
ProtectionElement pe = (ProtectionElement) this
.getObjectByPrimaryKey(ProtectionElement.class,
protectionElementId);
pe.setOwners(users);
s = HibernateSessionFactoryHelper.getAuditSession(sf);
t = s.beginTransaction();
s.update(pe);
t.commit();
s.flush();
auditLog.info("Assigning Users as Owner of Protection Element with Object Id " + pe.getObjectId() + " and Attribute " + pe.getAttribute());
} catch (Exception ex) {
log.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwners|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwners|Failure|Error in assigning the Owners "
+ StringUtilities.stringArrayToString(userIds)
+ "for the Protection Element Id "
+ protectionElementId + "|");
throw new CSTransactionException(
"An error occured in assigning Owners to the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwners|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwners|Success|Successful in assigning the Owners "
+ StringUtilities.stringArrayToString(userIds)
+ "for the Protection Element Id "
+ protectionElementId + "|");
}
示例4: setOwnerForProtectionElement
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void setOwnerForProtectionElement(String protectionElementObjectId,
String[] userNames) throws CSTransactionException {
Session s = null;
Transaction t = null;
if (StringUtilities.isBlank(protectionElementObjectId)) {
throw new CSTransactionException("object Id can't be null!");
}
try {
Set users = new HashSet();
for (int i = 0; i < userNames.length; i++) {
User user = this.getUser(userNames[i]);
if (user != null) {
users.add(user);
}
}
ProtectionElement pe = new ProtectionElement();
pe.setObjectId(protectionElementObjectId);
pe.setApplication(application);
SearchCriteria sc = new ProtectionElementSearchCriteria(pe);
List l = this.getObjects(sc);
ProtectionElement protectionElement = (ProtectionElement) l.get(0);
protectionElement.setOwners(users);
s = HibernateSessionFactoryHelper.getAuditSession(sf);
t = s.beginTransaction();
s.update(protectionElement);
t.commit();
s.flush();
auditLog.info("Assigning Users as Owner for 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|||setOwnerForProtectionElement|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwnerForProtectionElement|Failure|Error Setting owner for Protection Element object Name"
+ protectionElementObjectId
+ " for users "
+ StringUtilities
.stringArrayToString(userNames)
+ "|"
+ ex.getMessage());
throw new CSTransactionException(
"An error occured in setting multiple owners for the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwnerForProtectionElement|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwnerForProtectionElement|Success|Successful in Setting owner for Protection Element object Name"
+ protectionElementObjectId
+ " for users "
+ StringUtilities.stringArrayToString(userNames)
+ "|");
}
示例5: assignOwners
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void assignOwners(String protectionElementId, String[] userIds)
throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
Set users = new HashSet();
for (int i = 0; i < userIds.length; i++) {
User user = (User) this.getObjectByPrimaryKey(User.class,
userIds[i]);
users.add(user);
}
ProtectionElement pe = (ProtectionElement) this
.getObjectByPrimaryKey(ProtectionElement.class,
protectionElementId);
pe.setOwners(users);
s = HibernateSessionFactoryHelper.getAuditSession(sf);
t = s.beginTransaction();
s.update(pe);
t.commit();
s.flush();
auditLog.info("Assigning Users as Owner of Protection Element with Object Id " + pe.getObjectId() + " and Attribute " + pe.getAttribute());
} catch (Exception ex) {
log.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwners|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwners|Failure|Error in assigning the Owners "
+ StringUtilities.stringArrayToString(userIds)
+ "for the Protection Element Id "
+ protectionElementId + "|");
throw new CSTransactionException(
"An error occured in assigning Owners to the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwners|Failure|Error in Closing Session |"
+ ex2.getMessage());
}
}
if (log.isDebugEnabled())
log
.debug("Authorization|||setOwners|Success|Successful in assigning the Owners "
+ StringUtilities.stringArrayToString(userIds)
+ "for the Protection Element Id "
+ protectionElementId + "|");
}
示例6: updateOwner
import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
/**
* Add the user with given ID to the set of owners of the protection element with given id or set the user as the
* only owner, depending on the value of <code>addOwnder</code>. If that user was already an owner of that
* protection element, then this method is a no-op.
* @param protectionElementId ID of the protection element to modify
* @param oldOwner current owner
* @param newOwner user to add to the set of owners.
* @param appName application context name
* @param addOwner true if the user should be added to the existing set of owners, false to replace the old owner
* with the new owner
* @throws CSTransactionException if there is an error in performing the operation
*/
@SuppressWarnings("unchecked")
private static void updateOwner(Long protectionElementId, User oldOwner, User newOwner, String appName,
boolean addOwner) throws CSTransactionException {
Session s = null;
Transaction t = null;
try {
s = HibernateSessionFactoryHelper.getAuditSession(ApplicationSessionFactory.getSessionFactory(appName));
t = s.beginTransaction();
ProtectionElement pe = (ProtectionElement) s.load(ProtectionElement.class, protectionElementId);
Set<User> owners = pe.getOwners();
if (owners == null) {
owners = new HashSet<User>();
pe.setOwners(owners);
}
if (addOwner) {
owners.add(newOwner);
} else {
owners.remove(oldOwner);
owners.add(newOwner);
}
s.update(pe);
s.flush();
t.commit();
} catch (Exception ex) {
LOG.error(ex);
try {
t.rollback();
} catch (Exception ex3) {
if (LOG.isDebugEnabled()) {
LOG.debug("Authorization|||updateOwner|Failure|Error in Rolling Back Transaction|"
+ ex3.getMessage());
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Authorization|||updateOwner|Failure|Error in setting " + newOwner.getLoginName()
+ " as the owner for the Protection Element Id " + protectionElementId + "|");
}
throw new CSTransactionException("An error occured in updating owners of the Protection Element\n"
+ ex.getMessage(), ex);
} finally {
try {
s.close();
} catch (Exception ex2) {
if (LOG.isDebugEnabled()) {
LOG.debug("Authorization|||updateOwner|Failure|Error in Closing Session |" + ex2.getMessage());
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Authorization|||updateOwner|Success|Successful in updating " + newOwner
+ " as the owner for the Protection Element Id " + protectionElementId + "|");
}
}