Joining a user group to a group

	
	// BO necessary util classes and defining instances for each class
	IInfoStore boInfoStore = null;
	IInfoStore boInfoStore2 = null;
	IInfoObject boIInfoObject = null;
	IInfoObject boIInfoObject2 = null;
	IInfoObjects boInfoObjects = null;
	IInfoObjects boInfoObjects2 = null;
	SDKException sdkException = null;
	IEnterpriseSession boEnterpriseSession = null;
	IPluginMgr boPluginMgr;
	IPluginInfo boPluginInfo;
	IUser boCurUser = null;
	IUserGroup boGroup = null;
	IUserAliases allias = null;

boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(
					USERNAME, PASSWORD, SERVER, AUTHTYPE);
			boInfoStore = (IInfoStore) boEnterpriseSession.getService("",
					"InfoStore");
	boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(
					USERNAME, PASSWORD, SERVER, AUTHTYPE);
			boInfoStore = (IInfoStore) boEnterpriseSession.getService("",
					"InfoStore");


		public void joinGroupToGroup(String groupName, String targetGroup) {
		logger.debug("joinGroupToGroup " + groupName + targetGroup);
		Integer targetGroupID = acquireGroupID(targetGroup);
		Integer groupID = acquireGroupID(groupName);

		try {
			boInfoStore = (IInfoStore) boEnterpriseSession.getService("",
					"InfoStore");

			// Retrieve groups
			boInfoObjects = boInfoStore
					.query("SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_PROGID='CrystalEnterprise.UserGroup' AND SI_ID = '"
							+ targetGroupID + "'");

			boGroup = (IUserGroup) boInfoObjects.get(0);

			if (boInfoObjects.size() > 0) {
				// remove from parent group
				boGroup.getSubGroups().add(groupID);
			}

			// commit changes
			boInfoStore.commit(boInfoObjects);

		} catch (SDKException e) {
			logger.error("Exception to join group to group " + groupName
					+ targetGroup + e);
			System.out.println("Exception to join universe " + groupName
					+ " to " + targetGroup + e);
		}
	}

Leave a Reply

Your email address will not be published. Required fields are marked *