tvaultapi/src/main/java/com/tmobile/cso/vault/api/controller/ControllerUtil.java
public static Response updateMetadataOnSvcUpdate(String path, ServiceAccount serviceAccount, String token) {
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
				put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()).
				put(LogMessage.ACTION, "updateMetadataOnSvcUpdate").
				put(LogMessage.MESSAGE, "Trying to update metadata on AD service account update.").
				put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()).
				build()));
		String _path = METADATASTR + path;
		ObjectMapper objMapper = new ObjectMapper();
		String pathjson =PATHSTR+_path+"\"}";

		Response metadataResponse = reqProcessor.process(READSTR,pathjson,token);
		Map<String,Object> _metadataMap = null;
		if(HttpStatus.OK.equals(metadataResponse.getHttpstatus())){
			try {
				_metadataMap = objMapper.readValue(metadataResponse.getResponse(), new TypeReference<Map<String,Object>>() {});
			} catch (IOException e) {
				log.error(e);
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()).
						put(LogMessage.ACTION, UPDATEMETADATASTR).
						put(LogMessage.MESSAGE, String.format ("Error creating _metadataMap for type service account update, name [%s], and path [%s] message [%s]", serviceAccount.getName(), _path, e.getMessage())).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()).
						build()));
			}

			@SuppressWarnings("unchecked")
			Map<String,Object> metadataMap = (Map<String,Object>) _metadataMap.get("data");

			metadataMap.put("adGroup", serviceAccount.getAdGroup());
			metadataMap.put("appName", serviceAccount.getAppName());
			metadataMap.put("appID", serviceAccount.getAppID());
			metadataMap.put("appTag", serviceAccount.getAppTag());
			if (serviceAccount.getOwner() != null && !serviceAccount.getOwner().equals(TVaultConstants.EMPTY) && !metadataMap.get("managedBy").equals(serviceAccount.getOwner())) {
				metadataMap.put("managedBy", serviceAccount.getOwner());
			}
			String metadataJson = "";
			try {
				metadataJson = objMapper.writeValueAsString(metadataMap);
			} catch (JsonProcessingException e) {
				log.error(e);
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()).
						put(LogMessage.ACTION, UPDATEMETADATASTR).
						put(LogMessage.MESSAGE, String.format ("Error creating _metadataMap for type service account update, name [%s], and path [%s] message [%s]", serviceAccount.getName(), _path, e.getMessage())).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()).
						build()));
			}

			String writeJson =  PATHSTR+_path+DATASTR+ metadataJson +"}";
			metadataResponse = reqProcessor.process(WRITESTR,writeJson,token);
			return metadataResponse;
		}
		return null;

	}
/**
	 * Update metadata on service account update
	 * @param params
	 * @param token
	 * @return
	 */
Update metadata on service account update
@param params
@param token
@return
Update metadata on service account update @param params @param token @return
public static Response updateMetadataOnSvcUpdate(String path, ServiceAccount serviceAccount, String token) {
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
				put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()).
				put(LogMessage.ACTION, "updateMetadataOnSvcUpdate").
				put(LogMessage.MESSAGE, "Trying to update metadata on AD service account update.").
				put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()).
				build()));
		String _path = METADATASTR + path;
		ObjectMapper objMapper = new ObjectMapper();
		String pathjson =PATHSTR+_path+"\"}";
		Response metadataResponse = reqProcessor.process(READSTR,pathjson,token);
		Map<String,Object> _metadataMap = null;
		if(HttpStatus.OK.equals(metadataResponse.getHttpstatus())){
			try {
				_metadataMap = objMapper.readValue(metadataResponse.getResponse(), new TypeReference<Map<String,Object>>() {});
			} catch (IOException e) {
				log.error(e);
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()).
						put(LogMessage.ACTION, UPDATEMETADATASTR).
						put(LogMessage.MESSAGE, String.format ("Error creating _metadataMap for type service account update, name [%s], and path [%s] message [%s]", serviceAccount.getName(), _path, e.getMessage())).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()).
						build()));
			}
			@SuppressWarnings("unchecked")
			Map<String,Object> metadataMap = (Map<String,Object>) _metadataMap.get("data");
			metadataMap.put("adGroup", serviceAccount.getAdGroup());
			metadataMap.put("appName", serviceAccount.getAppName());
			metadataMap.put("appID", serviceAccount.getAppID());
			metadataMap.put("appTag", serviceAccount.getAppTag());
			if (serviceAccount.getOwner() != null && !serviceAccount.getOwner().equals(TVaultConstants.EMPTY) && !metadataMap.get("managedBy").equals(serviceAccount.getOwner())) {
				metadataMap.put("managedBy", serviceAccount.getOwner());
			}
			String metadataJson = "";
			try {
				metadataJson = objMapper.writeValueAsString(metadataMap);
			} catch (JsonProcessingException e) {
				log.error(e);
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()).
						put(LogMessage.ACTION, UPDATEMETADATASTR).
						put(LogMessage.MESSAGE, String.format ("Error creating _metadataMap for type service account update, name [%s], and path [%s] message [%s]", serviceAccount.getName(), _path, e.getMessage())).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()).
						build()));
			}
			String writeJson =  PATHSTR+_path+DATASTR+ metadataJson +"}";
			metadataResponse = reqProcessor.process(WRITESTR,writeJson,token);
			return metadataResponse;
		}
		return null;
	}
public static Response updateMetadataOnSvcUpdate ( String path , ServiceAccount serviceAccount , String token ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) . toString ( ) ) . put ( LogMessage . ACTION , "updateMetadataOnSvcUpdate" ) . put ( LogMessage . MESSAGE , "Trying to update metadata on AD service account update." ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) . toString ( ) ) . build ( ) ) ) ; String _path = METADATASTR + path ; ObjectMapper objMapper = new ObjectMapper ( ) ; String pathjson = PATHSTR + _path + "\"}" ; Response metadataResponse = reqProcessor . process ( READSTR , pathjson , token ) ; Map < String , Object > _metadataMap = null ; if ( HttpStatus . OK . equals ( metadataResponse . getHttpstatus ( ) ) ) { try { _metadataMap = objMapper . readValue ( metadataResponse . getResponse ( ) , new TypeReference < Map < String , Object > > ( ) { } ) ; } catch ( IOException e ) { log . error ( e ) ; log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) . toString ( ) ) . put ( LogMessage . ACTION , UPDATEMETADATASTR ) . put ( LogMessage . MESSAGE , String . format ( "Error creating _metadataMap for type service account update, name [%s], and path [%s] message [%s]" , serviceAccount . getName ( ) , _path , e . getMessage ( ) ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) . toString ( ) ) . build ( ) ) ) ; } @ SuppressWarnings ( "unchecked" ) Map < String , Object > metadataMap = ( Map < String , Object > ) _metadataMap . get ( "data" ) ; metadataMap . put ( "adGroup" , serviceAccount . getAdGroup ( ) ) ; metadataMap . put ( "appName" , serviceAccount . getAppName ( ) ) ; metadataMap . put ( "appID" , serviceAccount . getAppID ( ) ) ; metadataMap . put ( "appTag" , serviceAccount . getAppTag ( ) ) ; if ( serviceAccount . getOwner ( ) != null && ! serviceAccount . getOwner ( ) . equals ( TVaultConstants . EMPTY ) && ! metadataMap . get ( "managedBy" ) . equals ( serviceAccount . getOwner ( ) ) ) { metadataMap . put ( "managedBy" , serviceAccount . getOwner ( ) ) ; } String metadataJson = "" ; try { metadataJson = objMapper . writeValueAsString ( metadataMap ) ; } catch ( JsonProcessingException e ) { log . error ( e ) ; log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) . toString ( ) ) . put ( LogMessage . ACTION , UPDATEMETADATASTR ) . put ( LogMessage . MESSAGE , String . format ( "Error creating _metadataMap for type service account update, name [%s], and path [%s] message [%s]" , serviceAccount . getName ( ) , _path , e . getMessage ( ) ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) . toString ( ) ) . build ( ) ) ) ; } String writeJson = PATHSTR + _path + DATASTR + metadataJson + "}" ; metadataResponse = reqProcessor . process ( WRITESTR , writeJson , token ) ; return metadataResponse ; } return null ; }
Update metadata on service account update
 @param params
 @param token
 @return
Update metadata on service account update @param params @param token @return