tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
private boolean certificateMetadataForApplicationDetails(String sslCertificateJson, String token, String method) {
		 TMOAppMetadataDetails tmoAppMetadataDetails = new TMOAppMetadataDetails();
			JsonParser jsonParser = new JsonParser();
			
			JsonObject object = ((JsonObject) jsonParser.parse(sslCertificateJson)).getAsJsonObject("data");
			String appName = object.get("applicationName").getAsString();
			String certType = object.get("certType").getAsString();
			String certPath =  TVaultConstants.TMO_APP_METADATA_PATH + "/" + appName;
			List<String> certList = new ArrayList<>();
			
			boolean isAppDetailsAvailable = true;
			boolean isCertDataUpdated = false;
			isAppDetailsAvailable = checkAppDetailsAvailable( appName, token);
			
			
				tmoAppMetadataDetails.setApplicationName(object.get("applicationName").getAsString());
				tmoAppMetadataDetails.setApplicationTag(object.get("applicationTag").getAsString());
				tmoAppMetadataDetails.setApplicationOwnerEmailId(object.get("applicationOwnerEmailId")==null?null:object.get("applicationOwnerEmailId").getAsString());
				tmoAppMetadataDetails.setProjectLeadEmailId(object.get("projectLeadEmailId")!=null?object.get("projectLeadEmailId").getAsString():null);
				tmoAppMetadataDetails.setUpdateFlag(Boolean.TRUE);
				certList.add(object.get("certificateName").getAsString());
				if(!isAppDetailsAvailable) {
				if(certType.equalsIgnoreCase(SSLCertificateConstants.EXTERNAL)) {
					tmoAppMetadataDetails.setExternalCertificateList(certList);
				}else {
					tmoAppMetadataDetails.setInternalCertificateList(certList);
				}			
				}
				else {
					if(!method.equalsIgnoreCase("create")) {
						boolean isDataMismatch= checkApplicationMismatch(tmoAppMetadataDetails, token);
						tmoAppMetadataDetails.setUpdateFlag(isDataMismatch);
		                log.info(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
		                        put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
		                        put(LogMessage.ACTION, SSLCertificateConstants.POLICY_CREATION_TITLE).
		                        put(LogMessage.MESSAGE, String.format("Application details mismatch for application [%s]", tmoAppMetadataDetails.getApplicationName())).
		                        put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
		                        build()));
						
					}
					
					tmoAppMetadataDetails = addCertToAppList(tmoAppMetadataDetails,appName,certType,object.get("certificateName").getAsString(),
							 token);
				}
			TMOAppMetadata sslCertMetadata = new TMOAppMetadata(certPath, tmoAppMetadataDetails);
	        String jsonStr = JSONUtil.getJSON(sslCertMetadata);
	        Map<String, Object> rqstParams = ControllerUtil.parseJson(jsonStr);
	        rqstParams.put("path", certPath);
	        String certDataJson = ControllerUtil.convetToJson(rqstParams);
			Response response = reqProcessor.process("/write", certDataJson, token);			

			if(response.getHttpstatus().equals(HttpStatus.NO_CONTENT)){
				 log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
		                    put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
		                    put(LogMessage.ACTION, SSLCertificateConstants.POLICY_CREATION_TITLE).
		                    put(LogMessage.MESSAGE, "SSL certificate metadata creation is success for application details creation ").
		                    put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
		                    build()));
				 isCertDataUpdated = true;
			}else {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
						put(LogMessage.ACTION, SSLCertificateConstants.POLICY_CREATION_TITLE).
						put(LogMessage.MESSAGE, "SSL certificate metadata creation failed for application details creation").
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
						build()));
			}
			
						
			
			return isCertDataUpdated;
		}
/**
     * Application metadata creation
     * @param sslCertificateJson
     * @param token
     * @return
     */
Application metadata creation
@param sslCertificateJson
@param token
@return
Application metadata creation @param sslCertificateJson @param token @return
private boolean certificateMetadataForApplicationDetails(String sslCertificateJson, String token, String method) {
		 TMOAppMetadataDetails tmoAppMetadataDetails = new TMOAppMetadataDetails();
			JsonParser jsonParser = new JsonParser();
			JsonObject object = ((JsonObject) jsonParser.parse(sslCertificateJson)).getAsJsonObject("data");
			String appName = object.get("applicationName").getAsString();
			String certType = object.get("certType").getAsString();
			String certPath =  TVaultConstants.TMO_APP_METADATA_PATH + "/" + appName;
			List<String> certList = new ArrayList<>();
			boolean isAppDetailsAvailable = true;
			boolean isCertDataUpdated = false;
			isAppDetailsAvailable = checkAppDetailsAvailable( appName, token);
				tmoAppMetadataDetails.setApplicationName(object.get("applicationName").getAsString());
				tmoAppMetadataDetails.setApplicationTag(object.get("applicationTag").getAsString());
				tmoAppMetadataDetails.setApplicationOwnerEmailId(object.get("applicationOwnerEmailId")==null?null:object.get("applicationOwnerEmailId").getAsString());
				tmoAppMetadataDetails.setProjectLeadEmailId(object.get("projectLeadEmailId")!=null?object.get("projectLeadEmailId").getAsString():null);
				tmoAppMetadataDetails.setUpdateFlag(Boolean.TRUE);
				certList.add(object.get("certificateName").getAsString());
				if(!isAppDetailsAvailable) {
				if(certType.equalsIgnoreCase(SSLCertificateConstants.EXTERNAL)) {
					tmoAppMetadataDetails.setExternalCertificateList(certList);
				}else {
					tmoAppMetadataDetails.setInternalCertificateList(certList);
				}			
				}
				else {
					if(!method.equalsIgnoreCase("create")) {
						boolean isDataMismatch= checkApplicationMismatch(tmoAppMetadataDetails, token);
						tmoAppMetadataDetails.setUpdateFlag(isDataMismatch);
		                log.info(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
		                        put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
		                        put(LogMessage.ACTION, SSLCertificateConstants.POLICY_CREATION_TITLE).
		                        put(LogMessage.MESSAGE, String.format("Application details mismatch for application [%s]", tmoAppMetadataDetails.getApplicationName())).
		                        put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
		                        build()));
					}
					tmoAppMetadataDetails = addCertToAppList(tmoAppMetadataDetails,appName,certType,object.get("certificateName").getAsString(),
							 token);
				}
			TMOAppMetadata sslCertMetadata = new TMOAppMetadata(certPath, tmoAppMetadataDetails);
	        String jsonStr = JSONUtil.getJSON(sslCertMetadata);
	        Map<String, Object> rqstParams = ControllerUtil.parseJson(jsonStr);
	        rqstParams.put("path", certPath);
	        String certDataJson = ControllerUtil.convetToJson(rqstParams);
			Response response = reqProcessor.process("/write", certDataJson, token);			
			if(response.getHttpstatus().equals(HttpStatus.NO_CONTENT)){
				 log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
		                    put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
		                    put(LogMessage.ACTION, SSLCertificateConstants.POLICY_CREATION_TITLE).
		                    put(LogMessage.MESSAGE, "SSL certificate metadata creation is success for application details creation ").
		                    put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
		                    build()));
				 isCertDataUpdated = true;
			}else {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
						put(LogMessage.ACTION, SSLCertificateConstants.POLICY_CREATION_TITLE).
						put(LogMessage.MESSAGE, "SSL certificate metadata creation failed for application details creation").
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
						build()));
			}
			return isCertDataUpdated;
		}
private boolean certificateMetadataForApplicationDetails ( String sslCertificateJson , String token , String method ) { TMOAppMetadataDetails tmoAppMetadataDetails = new TMOAppMetadataDetails ( ) ; JsonParser jsonParser = new JsonParser ( ) ; JsonObject object = ( ( JsonObject ) jsonParser . parse ( sslCertificateJson ) ) . getAsJsonObject ( "data" ) ; String appName = object . get ( "applicationName" ) . getAsString ( ) ; String certType = object . get ( "certType" ) . getAsString ( ) ; String certPath = TVaultConstants . TMO_APP_METADATA_PATH + "/" + appName ; List < String > certList = new ArrayList < > ( ) ; boolean isAppDetailsAvailable = true ; boolean isCertDataUpdated = false ; isAppDetailsAvailable = checkAppDetailsAvailable ( appName , token ) ; tmoAppMetadataDetails . setApplicationName ( object . get ( "applicationName" ) . getAsString ( ) ) ; tmoAppMetadataDetails . setApplicationTag ( object . get ( "applicationTag" ) . getAsString ( ) ) ; tmoAppMetadataDetails . setApplicationOwnerEmailId ( object . get ( "applicationOwnerEmailId" ) == null ? null : object . get ( "applicationOwnerEmailId" ) . getAsString ( ) ) ; tmoAppMetadataDetails . setProjectLeadEmailId ( object . get ( "projectLeadEmailId" ) != null ? object . get ( "projectLeadEmailId" ) . getAsString ( ) : null ) ; tmoAppMetadataDetails . setUpdateFlag ( Boolean . TRUE ) ; certList . add ( object . get ( "certificateName" ) . getAsString ( ) ) ; if ( ! isAppDetailsAvailable ) { if ( certType . equalsIgnoreCase ( SSLCertificateConstants . EXTERNAL ) ) { tmoAppMetadataDetails . setExternalCertificateList ( certList ) ; } else { tmoAppMetadataDetails . setInternalCertificateList ( certList ) ; } } else { if ( ! method . equalsIgnoreCase ( "create" ) ) { boolean isDataMismatch = checkApplicationMismatch ( tmoAppMetadataDetails , token ) ; tmoAppMetadataDetails . setUpdateFlag ( isDataMismatch ) ; log . info ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . POLICY_CREATION_TITLE ) . put ( LogMessage . MESSAGE , String . format ( "Application details mismatch for application [%s]" , tmoAppMetadataDetails . getApplicationName ( ) ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; } tmoAppMetadataDetails = addCertToAppList ( tmoAppMetadataDetails , appName , certType , object . get ( "certificateName" ) . getAsString ( ) , token ) ; } TMOAppMetadata sslCertMetadata = new TMOAppMetadata ( certPath , tmoAppMetadataDetails ) ; String jsonStr = JSONUtil . getJSON ( sslCertMetadata ) ; Map < String , Object > rqstParams = ControllerUtil . parseJson ( jsonStr ) ; rqstParams . put ( "path" , certPath ) ; String certDataJson = ControllerUtil . convetToJson ( rqstParams ) ; Response response = reqProcessor . process ( "/write" , certDataJson , token ) ; if ( response . getHttpstatus ( ) . equals ( HttpStatus . NO_CONTENT ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . POLICY_CREATION_TITLE ) . put ( LogMessage . MESSAGE , "SSL certificate metadata creation is success for application details creation " ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; isCertDataUpdated = true ; } else { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . POLICY_CREATION_TITLE ) . put ( LogMessage . MESSAGE , "SSL certificate metadata creation failed for application details creation" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; } return isCertDataUpdated ; }
Application metadata creation
 @param sslCertificateJson
 @param token
 @return
Application metadata creation @param sslCertificateJson @param token @return