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


Java ProtectionElement.setProtectionGroups方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:NCIP,项目名称:caintegrator,代码行数:19,代码来源:SecurityManagerImpl.java

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

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

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

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


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