agave-apps/clients/ProfileService.java
/**
	 * Updates an internal user. Note that usernames cannot be changed. 
	 * 
	 * @param user
	 * @return
	 * @throws AuthenticationException
	 * @throws ProfileException
	 */
Updates an internal user. Note that usernames cannot be changed.

@param user
@return
@throws AuthenticationException
@throws ProfileException
Updates an internal user . Note that usernames cannot be changed . @param user @return @throws AuthenticationException @throws ProfileException
public InternalUser updateInternalUser(InternalUser user) 
	throws AuthenticationException, ProfileException
	{
		if (user == null) {
			throw new ProfileException("No internal user profile provided.");
		} else if (StringUtils.isEmpty(user.getUsername())) {
			throw new ProfileException("Unique username must be provided for internal users.");
		} else if (!ClientUtils.isValidEmailAddress(user.getEmail())) {
			throw new ProfileException("Unique username must be provided for internal users.");
		} 
		APIResponse response = null;
		try 
		{
			List <NameValuePair> nvps = new ArrayList<NameValuePair>();
			ObjectMapper mapper = new ObjectMapper();
			JsonFactory factory = mapper.getFactory();
			JsonParser jp = factory.createJsonParser(mapper.writeValueAsString(user));
			JsonNode node = mapper.readTree(jp);
			Iterator<String> fieldNames = node.fieldNames();
			while(fieldNames.hasNext()) {
				String fieldName = fieldNames.next();
				nvps.add(new BasicNameValuePair(fieldName, node.get(fieldName).asText()));
			}
			String endpoint = Settings.SERVICE_BASE_URL + "profile-v1/internal/" + user.getUsername();
			response = post( endpoint , token, nvps );
		} 
		catch (APIClientException e) {
			throw new ProfileException("Error querying service.", e);
		}
		catch (JsonParseException e)
		{
			throw new ProfileException("Failed to create new user from the given internal user.", e);
		}
		catch (JsonProcessingException e)
		{
			throw new ProfileException("Failed to create new user from the given internal user.", e);
		}
		catch (IOException e)
		{
			throw new ProfileException("Failed to create new user from the given internal user.", e);
		}
		if (response.isSuccess()) {
			List<InternalUser> users = parseInternalUsers(response.getResult());
			return users.get(0);
		} else {
			throw new ProfileException(response.getMessage());
		}
	}
public InternalUser updateInternalUser ( InternalUser user ) throws AuthenticationException , ProfileException { if ( user == null ) { throw new ProfileException ( "No internal user profile provided." ) ; } else if ( StringUtils . isEmpty ( user . getUsername ( ) ) ) { throw new ProfileException ( "Unique username must be provided for internal users." ) ; } else if ( ! ClientUtils . isValidEmailAddress ( user . getEmail ( ) ) ) { throw new ProfileException ( "Unique username must be provided for internal users." ) ; } APIResponse response = null ; try { List < NameValuePair > nvps = new ArrayList < NameValuePair > ( ) ; ObjectMapper mapper = new ObjectMapper ( ) ; JsonFactory factory = mapper . getFactory ( ) ; JsonParser jp = factory . createJsonParser ( mapper . writeValueAsString ( user ) ) ; JsonNode node = mapper . readTree ( jp ) ; Iterator < String > fieldNames = node . fieldNames ( ) ; while ( fieldNames . hasNext ( ) ) { String fieldName = fieldNames . next ( ) ; nvps . add ( new BasicNameValuePair ( fieldName , node . get ( fieldName ) . asText ( ) ) ) ; } String endpoint = Settings . SERVICE_BASE_URL + "profile-v1/internal/" + user . getUsername ( ) ; response = post ( endpoint , token , nvps ) ; } catch ( APIClientException e ) { throw new ProfileException ( "Error querying service." , e ) ; } catch ( JsonParseException e ) { throw new ProfileException ( "Failed to create new user from the given internal user." , e ) ; } catch ( JsonProcessingException e ) { throw new ProfileException ( "Failed to create new user from the given internal user." , e ) ; } catch ( IOException e ) { throw new ProfileException ( "Failed to create new user from the given internal user." , e ) ; } if ( response . isSuccess ( ) ) { List < InternalUser > users = parseInternalUsers ( response . getResult ( ) ) ; return users . get ( 0 ) ; } else { throw new ProfileException ( response . getMessage ( ) ) ; } }
Updates an internal user.
Updates an internal user .