当前位置: 首页>>代码示例>>Java>>正文


Java ProtectionElement.getOwners方法代码示例

本文整理汇总了Java中gov.nih.nci.security.authorization.domainobjects.ProtectionElement.getOwners方法的典型用法代码示例。如果您正苦于以下问题:Java ProtectionElement.getOwners方法的具体用法?Java ProtectionElement.getOwners怎么用?Java ProtectionElement.getOwners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gov.nih.nci.security.authorization.domainobjects.ProtectionElement的用法示例。


在下文中一共展示了ProtectionElement.getOwners方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOwners

import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
/**
 * Returns the owner for the given protectable.
 * 
 * @param p the protectable to get the owner for
 * @return the User who owns the given Protectable instance
 */
@SuppressWarnings("unchecked")
public static Set<User> getOwners(Protectable p) {
    final ProtectionGroup pg = getProtectionGroup(p);
    final ProtectionElement pe = (ProtectionElement) pg.getProtectionElements().iterator().next();
    return new HashSet<User>(pe.getOwners());
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:13,代码来源:SecurityUtils.java

示例2: getOwners

import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public Set getOwners(String protectionElementId)
		throws CSObjectNotFoundException {

	Session s = null;

	Set result = new TreeSet();
	
	try {
		s = HibernateSessionFactoryHelper.getAuditSession(sf);
		ProtectionElement protectionElement = (ProtectionElement) this
				.getObjectByPrimaryKey(s, ProtectionElement.class,
						new Long(protectionElementId));

		Set reresult = protectionElement.getOwners();
		
		List list = new ArrayList();
		Iterator toSortIterator = reresult.iterator();
		while(toSortIterator.hasNext()){ list.add(toSortIterator.next()); }
		
		Collections.sort(list);
		result.addAll(list);
		
		
		log.debug("The result size is: " + result.size());

	} catch (Exception ex) {
		if (log.isDebugEnabled())
			log
					.debug("Authorization|||getOwners|Failure|An Error occured in retrieving the Owners for the Protection Element Id "
							+ protectionElementId + "|" + ex.getMessage());
		throw new CSObjectNotFoundException(
				"An error occured in retrieving the Owners for the Protection Element\n"
						+ ex.getMessage(), ex);
	} finally {
		try {
			s.close();
		} catch (Exception ex2) {
			if (log.isDebugEnabled())
				log
						.debug("Authorization|||getOwners|Failure|Error in Closing Session |"
								+ ex2.getMessage());
		}
	}
	if (log.isDebugEnabled())
		log
				.debug("Authorization|||getOwners|Success|Successful in retrieving the Owners for the Protection Element Id "
						+ protectionElementId + "|");
	return result;
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:50,代码来源:AuthorizationDAOImpl.java

示例3: addOwners

import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void addOwners(String protectionElementId, String[] userIds) throws CSTransactionException{

		Session s = null;
		Transaction t = null;
		
		try {
			
			s = HibernateSessionFactoryHelper.getAuditSession(sf);
			ProtectionElement protectionElement = (ProtectionElement) s.load(ProtectionElement.class,Long.parseLong(protectionElementId));
			if(protectionElement==null) throw new CSTransactionException("Authorization|||addOwners|| Unable to retrieve ProtectionElement with Id :"+protectionElementId);
			Set userSet = protectionElement.getOwners();
			if(userSet==null) userSet=new HashSet();
			
			for (int i = 0; i < userIds.length; i++) {
				boolean assigned= false;
				Iterator iterator = userSet.iterator();
				while(iterator.hasNext()){
					User us =(User)iterator.next();
					if(userIds[i].equalsIgnoreCase(us.getUserId().toString()));
					assigned=true;
				}
				if(!assigned){
					User user = (User) s.load(User.class, Long.parseLong(userIds[i]));
					if(user!=null)
						userSet.add(user);
				}
			}
			
			t = s.beginTransaction();
			s.update(protectionElement);
			t.commit();
			s.flush();
			auditLog.info("Adding Users as Owner of 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|||addOwners|Failure|Error in Rolling Back Transaction|"
									+ ex3.getMessage());
			}
			if (log.isDebugEnabled())
				log
						.debug("Authorization|||addOwners|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|||addOwners|Failure|Error in Closing Session |"
									+ ex2.getMessage());
			}
		}
		if (log.isDebugEnabled())
			log
					.debug("Authorization|||addOwners|Success|Successful in adding the Owners to Protection Element"
							+ StringUtilities.stringArrayToString(userIds)
							+ "for the Protection Element Id "
							+ protectionElementId + "|");
	}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:71,代码来源:AuthorizationDAOImpl.java

示例4: getOwners

import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public Set getOwners(String protectionElementId)
		throws CSObjectNotFoundException {

	Session s = null;

	Set result = new TreeSet();

	try {
		s = HibernateSessionFactoryHelper.getAuditSession(sf);
		ProtectionElement protectionElement = (ProtectionElement) this
				.getObjectByPrimaryKey(s, ProtectionElement.class,
						new Long(protectionElementId));

		Set reresult = protectionElement.getOwners();

		List list = new ArrayList();
		Iterator toSortIterator = reresult.iterator();
		while(toSortIterator.hasNext()){ list.add(toSortIterator.next()); }

		Collections.sort(list);
		result.addAll(list);


		log.debug("The result size is: " + result.size());

	} catch (Exception ex) {
		if (log.isDebugEnabled())
			log
					.debug("Authorization|||getOwners|Failure|An Error occured in retrieving the Owners for the Protection Element Id "
							+ protectionElementId + "|" + ex.getMessage());
		throw new CSObjectNotFoundException(
				"An error occured in retrieving the Owners for the Protection Element\n"
						+ ex.getMessage(), ex);
	} finally {
		try {
			s.close();
		} catch (Exception ex2) {
			if (log.isDebugEnabled())
				log
						.debug("Authorization|||getOwners|Failure|Error in Closing Session |"
								+ ex2.getMessage());
		}
	}
	if (log.isDebugEnabled())
		log
				.debug("Authorization|||getOwners|Success|Successful in retrieving the Owners for the Protection Element Id "
						+ protectionElementId + "|");
	return result;
}
 
开发者ID:NCIP,项目名称:common-security-module,代码行数:50,代码来源:AuthorizationDAOImpl.java

示例5: addOwners

import gov.nih.nci.security.authorization.domainobjects.ProtectionElement; //导入方法依赖的package包/类
public void addOwners(String protectionElementId, String[] userIds) throws CSTransactionException{

		Session s = null;
		Transaction t = null;

		try {

			s = HibernateSessionFactoryHelper.getAuditSession(sf);
			ProtectionElement protectionElement = (ProtectionElement) s.load(ProtectionElement.class,Long.parseLong(protectionElementId));
			if(protectionElement==null) throw new CSTransactionException("Authorization|||addOwners|| Unable to retrieve ProtectionElement with Id :"+protectionElementId);
			Set userSet = protectionElement.getOwners();
			if(userSet==null) userSet=new HashSet();

			for (int i = 0; i < userIds.length; i++) {
				boolean assigned= false;
				Iterator iterator = userSet.iterator();
				while(iterator.hasNext()){
					User us =(User)iterator.next();
					if(userIds[i].equalsIgnoreCase(us.getUserId().toString()));
					assigned=true;
				}
				if(!assigned){
					User user = (User) s.load(User.class, Long.parseLong(userIds[i]));
					if(user!=null)
						userSet.add(user);
				}
			}

			t = s.beginTransaction();
			s.update(protectionElement);
			t.commit();
			s.flush();
			auditLog.info("Adding Users as Owner of 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|||addOwners|Failure|Error in Rolling Back Transaction|"
									+ ex3.getMessage());
			}
			if (log.isDebugEnabled())
				log
						.debug("Authorization|||addOwners|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|||addOwners|Failure|Error in Closing Session |"
									+ ex2.getMessage());
			}
		}
		if (log.isDebugEnabled())
			log
					.debug("Authorization|||addOwners|Success|Successful in adding the Owners to Protection Element"
							+ StringUtilities.stringArrayToString(userIds)
							+ "for the Protection Element Id "
							+ protectionElementId + "|");
	}
 
开发者ID:NCIP,项目名称:common-security-module,代码行数:71,代码来源:AuthorizationDAOImpl.java

示例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 + "|");
    }
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:68,代码来源:AuthorizationManagerExtensions.java


注:本文中的gov.nih.nci.security.authorization.domainobjects.ProtectionElement.getOwners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。