public long createExperimenter( Experimenter experimenter, ExperimenterGroup defaultGroup, ExperimenterGroup[] otherGroups) {   Experimenter e = copyUser( experimenter );  if ( defaultGroup == null || defaultGroup.getId() == null ) { throw new ApiUsageException("Default group may not be null."); }
public long createExperimenter(Experimenter experimenter, ExperimenterGroup defaultGroup, ExperimenterGroup[] otherGroups) {
    public long createExperimenter(    		Experimenter experimenter,     		ExperimenterGroup defaultGroup,     		ExperimenterGroup[] otherGroups)    {//    	 TODO check that no other group is default	    	Experimenter e = copyUser( experimenter );    	    	    	if ( defaultGroup == null || defaultGroup.getId() == null )    	{    		throw new ApiUsageException("Default group may not be null.");    	}     	SecureAction action = new SecureAction(){    		public <T extends IObject> T updateObject(T obj) {    			return iUpdate.saveAndReturnObject( obj );    		}    	};    	    	e = getSecuritySystem().doAction(e, action);    	    	final GroupExperimenterMap defaultGroupMap = new GroupExperimenterMap();		defaultGroupMap.link( groupProxy(defaultGroup.getId()), userProxy(e.getId()));		defaultGroupMap.setDefaultGroupLink(Boolean.TRUE);		defaultGroupMap.setDetails( getSecuritySystem().transientDetails( defaultGroupMap ));		getSecuritySystem().doAction(defaultGroupMap,action);		    	if ( null != otherGroups )    	{    		for (ExperimenterGroup group : otherGroups) {    			if ( group == null ) continue;    			if ( group.getId() == null)    			{    				throw new ApiUsageException(    						"Groups must be previously saved during " +    						"Experimenter creation.");    			}    			GroupExperimenterMap groupMap = new GroupExperimenterMap();    			groupMap.link( groupProxy(group.getId()), userProxy(e.getId()));    			groupMap.setDefaultGroupLink(Boolean.FALSE);    			groupMap.setDetails( getSecuritySystem().transientDetails( groupMap ));    			getSecuritySystem().doAction(groupMap, action);    		}    	}    	    	changeUserPassword(e.getOmeName()," ");    	return e.getId();    }