Register/re-register/update a group instance

@param service group to add
@throws Exception errors
498174
@Override
    public void registerService(ServiceInstance<T> service) throws Exception
    {
        Entry<T> newEntry = new Entry<T>(service);
        Entry<T> oldEntry = services.putIfAbsent(service.getId(), newEntry);
        Entry<T> useEntry = (oldEntry != null) ? oldEntry : newEntry;
        synchronized(useEntry)
        {
            if ( useEntry == newEntry ) // i.e. is new
            {
                useEntry.cache = makeNodeCache(service);
            }
            internalRegisterService(service);
        }
    }
1059428
public void register(DescribeService service, String describeService) throws POIProxyException {
		serviceManager.registerServiceConfiguration(service.getId(), describeService, service);
	}
1287331
public static base_responses update(nitro_service client, servicegroup resources[]) throws Exception {
		base_responses result = null;
		if (resources != null && resources.length > 0) {
			servicegroup updateresources[] = new servicegroup[resources.length];
			for (int i=0;i<resources.length;i++){
				updateresources[i] = new servicegroup();
				updateresources[i].servicegroupname = resources[i].servicegroupname;
				updateresources[i].servername = resources[i].servername;
				updateresources[i].port = resources[i].port;
				updateresources[i].weight = resources[i].weight;
				updateresources[i].customserverid = resources[i].customserverid;
				updateresources[i].serverid = resources[i].serverid;
				updateresources[i].hashid = resources[i].hashid;
				updateresources[i].monitor_name_svc = resources[i].monitor_name_svc;
				updateresources[i].dup_weight = resources[i].dup_weight;
				updateresources[i].maxclient = resources[i].maxclient;
				updateresources[i].maxreq = resources[i].maxreq;
				updateresources[i].healthmonitor = resources[i].healthmonitor;
				updateresources[i].cacheable = resources[i].cacheable;
				updateresources[i].cip = resources[i].cip;
				updateresources[i].cipheader = resources[i].cipheader;
				updateresources[i].usip = resources[i].usip;
				updateresources[i].pathmonitor = resources[i].pathmonitor;
				updateresources[i].pathmonitorindv = resources[i].pathmonitorindv;
				updateresources[i].useproxyport = resources[i].useproxyport;
				updateresources[i].sc = resources[i].sc;
				updateresources[i].sp = resources[i].sp;
				updateresources[i].rtspsessionidremap = resources[i].rtspsessionidremap;
				updateresources[i].clttimeout = resources[i].clttimeout;
				updateresources[i].svrtimeout = resources[i].svrtimeout;
				updateresources[i].cka = resources[i].cka;
				updateresources[i].tcpb = resources[i].tcpb;
				updateresources[i].cmp = resources[i].cmp;
				updateresources[i].maxbandwidth = resources[i].maxbandwidth;
				updateresources[i].monthreshold = resources[i].monthreshold;
				updateresources[i].downstateflush = resources[i].downstateflush;
				updateresources[i].tcpprofilename = resources[i].tcpprofilename;
				updateresources[i].httpprofilename = resources[i].httpprofilename;
				updateresources[i].comment = resources[i].comment;
				updateresources[i].appflowlog = resources[i].appflowlog;
				updateresources[i].netprofile = resources[i].netprofile;
			}
			result = update_bulk_request(client, updateresources);
		}
		return result;
	}
392061
def vserver_servicegroup_add(v_name, sg_name, **connection_args):
    '''
    
    '''
    ret = True
    if vserver_servicegroup_exists(v_name, sg_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    vsg = NSLBVServerServiceGroupBinding()
    vsg.set_name(v_name)
    vsg.set_servicegroupname(sg_name)
    try:
        NSLBVServerServiceGroupBinding.add(nitro, vsg)
    except NSNitroError as error:
        log.debug('netscaler module error - NSLBVServerServiceGroupBinding.add() failed: %s', error)
        ret = False
    _disconnect(nitro)
    return ret
1160428
public void registerService(ProvidedServiceInstance serviceInstance,
            OperationalStatus status) {

        serviceInstance.setStatus(status);
        registerService(serviceInstance);
    }
513961
public synchronized void register() throws Exception {
        if (mbeanName != null) {
            throw new Exception("Agent already registered");
        }
        mbeanName = new ObjectName(getClass().getPackage().getName() + ":type=" + getClass().getSimpleName());
        logger.info("Registering JMX agent " + mbeanName);
        ManagementFactory.getPlatformMBeanServer().registerMBean(this, mbeanName);
        logger.info("JMX agent " + mbeanName + " registered");
    }
1287968
public void selfRegister() {
        LocalUnitsManager.unitMap(unitMap -> {
            unitMap.forEach((groupName, unitsIgnored) -> {
                try {
                    ServiceInstance<GroupProxy> serviceInstance = ZkServiceInstanceAdaptor.thisCuratorServiceInstance(groupName);
                    serviceDiscovery.registerService(serviceInstance);
                } catch (Exception e) {
                    LOG.error(e);
                    //the registration should not be interrupted due to one error.
                }
            });
        });
    }
959169
@Override
    public IComponentGroupService newGroupService(ComponentGroupServiceDescriptor svcDescriptor)
            throws GroupsException {
        try {
            return new ReferenceIndividualGroupService(svcDescriptor);
        } catch (GroupsException ge) {
            log.error(ge.getMessage(), ge);
            throw new GroupsException(ge);
        }
    }
864404
public void registerService(Object service)
    {
    	this.setService(service);
    	String serviceClass = getInterfaceClassName(); 

    	if (service != null)
    		serviceRegistration = context.registerService(serviceClass, this.service, properties);
    }
809822
private <T extends OrchidService> void initializeService(Class<T> serviceClass, T service) {
        services.put(serviceClass, service);
    }
54232
public void setGroupLocalService(
		com.liferay.portal.kernel.service.GroupLocalService groupLocalService) {
		this.groupLocalService = groupLocalService;
	}
1180687
public void doAdd(@FormGroup("channelInfo") Group channelInfo,
                      @FormGroup("channelParameterInfo") Group channelParameterInfo,
                      @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav)
                                                                                                                   throws Exception {
        Channel channel = new Channel();
        ChannelParameter parameter = new ChannelParameter();
        channelInfo.setProperties(channel);
        channelParameterInfo.setProperties(parameter);
        // 新建Channel默认关闭该状态
        channel.setStatus(ChannelStatus.STOP);
        channel.setParameters(parameter);
        try {
            channelService.create(channel);
        } catch (RepeatConfigureException rce) {
            err.setMessage("invalidChannelName");
            return;
        }
        nav.redirectTo(WebConstant.CHANNEL_LIST_LINK);
    }
1013136
void migrateGroup(Node oldGroupNode) throws Exception
   {
      String groupName = oldGroupNode.getName();
      String desc = utils.readString(oldGroupNode, GroupProperties.JOS_DESCRIPTION);
      String label = utils.readString(oldGroupNode, GroupProperties.JOS_LABEL);
      String parentId = utils.readString(oldGroupNode, MigrationTool.JOS_PARENT_ID);

      GroupImpl group = new GroupImpl(groupName, parentId);
      group.setDescription(desc);
      group.setLabel(label);

      Group parentGroup = findGroupById(group.getParentId());

      if (findGroupById(group.getId()) != null)
      {
         removeGroup(group, false);
      }

      addChild(parentGroup, group, false);
   }
497655
@SuppressWarnings("unchecked")
    protected void handleGroupPrincipalCallback(GroupPrincipalCallback callback) throws CustomRegistryException, EntryNotFoundException, RemoteException {
        Subject clientSubject = callback.getSubject();
        Hashtable<String, Object> credData = null;
        if (clientSubject != null) {
            String[] groupsFromCallback = callback.getGroups();
            if (groupsFromCallback != null && groupsFromCallback.length > 0) {
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "Group names in Callback: ", Arrays.asList(groupsFromCallback));
                }
                credData = getSubjectCustomData(clientSubject);
                List<String> groupsFromSubject = (List<String>) credData.get(AttributeNameConstants.WSCREDENTIAL_GROUPS);
                if (groupsFromSubject == null) {
                    groupsFromSubject = new ArrayList<String>();
                    credData.put(AttributeNameConstants.WSCREDENTIAL_GROUPS, groupsFromSubject);
                }

                for (int i = 0; i < groupsFromCallback.length; i++) {
                    String groupFromCallback = groupsFromCallback[i];
                    if (groupFromCallback == null || groupFromCallback.isEmpty()) {
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, "Group is null or an empty string, it has been ignored.");
                        }
                        continue;
                    }

                    String group = mapGroup(groupFromCallback);

                    if (!groupsFromSubject.contains(group)) {
                        groupsFromSubject.add(group);
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, "Added groupId: " + group);
                        }
                    } else {
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, group + " already exists in custom credential data, avoid duplicates.");
                        }
                    }
                }
            } else {
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "Callback has no groups.");
                }
            }
        }
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "handleGroupPrincipalCallback", credData);
        }
    }
582088
def register_service(self, service):
        
        if service not in self.services:
            self.services.append(service)
1331055
public void updateGroupMembers(GroupForm groupForm, IPerson updater) {

        if (!canEditGroup(updater, groupForm.getKey())) {
            throw new RuntimeAuthorizationException(
                    updater, IPermission.EDIT_GROUP_ACTIVITY, groupForm.getKey());
        }

        if (log.isDebugEnabled()) {
            log.debug("Updating group members for group form [" + groupForm.toString() + "]");
        }

        // find the current version of this group entity
        IEntityGroup group = GroupService.findGroup(groupForm.getKey());

        // clear the current group membership list
        for (IGroupMember child : group.getChildren()) {
            group.removeChild(child);
        }

        // add all the group membership information from the group form
        // to the group
        for (JsonEntityBean child : groupForm.getMembers()) {
            EntityEnum type = EntityEnum.getEntityEnum(child.getEntityTypeAsString());
            if (type.isGroup()) {
                IEntityGroup member = GroupService.findGroup(child.getId());
                group.addChild(member);
            } else {
                IGroupMember member = GroupService.getGroupMember(child.getId(), type.getClazz());
                group.addChild(member);
            }
        }

        // save the group, updating both its basic information and group
        // membership
        group.updateMembers();
    }
940237
@Override
    public void updateMembers(IEntityGroup eg) throws GroupsException {
        Connection conn = null;
        EntityGroupImpl egi = (EntityGroupImpl) eg;
        if (egi.isDirty())
            try {
                conn = RDBMServices.getConnection();
                setAutoCommit(conn, false);

                try {
                    primUpdateMembers(egi, conn);
                    commit(conn);
                } catch (SQLException sqle) {
                    rollback(conn);
                    throw new GroupsException("Problem updating memberships for " + egi, sqle);
                }
            } catch (SQLException sqlex) {
                throw new GroupsException(sqlex);
            } finally {
                if (conn != null) {
                    try {
                        setAutoCommit(conn, true);
                    } catch (SQLException sqle) {
                        throw new GroupsException(sqle);
                    } finally {
                        RDBMServices.releaseConnection(conn);
                    }
                }
            }
    }