tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
private boolean isCertAvailableInMetadata(JsonObject jsonObject, String token) {
		    
		    boolean isMetadataAvailable = true;
		    String endPoint = jsonObject.get(SSLCertificateConstants.COMMON_NAME).getAsString();
			String metaDataPath = (jsonObject.get(SSLCertificateConstants.CERT_TYPE).getAsString().equalsIgnoreCase(SSLCertificateConstants.INTERNAL))?
		            SSLCertificateConstants.SSL_CERT_PATH + "/" + endPoint :SSLCertificateConstants.SSL_EXTERNAL_CERT_PATH + "/" + endPoint;
			Response response = new Response();
			try {		
					response = reqProcessor.process("/read", "{\"path\":\"" + metaDataPath + "\"}", token);		
			} catch (Exception e) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, SSLCertificateConstants.ONBOARD_SSL_CERTIFICATE)
						.put(LogMessage.MESSAGE, String.format("\"[%s]  - Skipping Onboard flow -  Error occured while checking certificate "
								+ "is available in metadata.Exception = [%s] =  Message [%s]", 
								endPoint,Arrays.toString(e.getStackTrace()), response.getResponse()))
						.build()));
				 isMetadataAvailable = false;
			}
			if (!HttpStatus.OK.equals(response.getHttpstatus())) {
				log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
							put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
							put(LogMessage.ACTION, SSLCertificateConstants.ONBOARD_SSL_CERTIFICATE).
							put(LogMessage.MESSAGE, String.format("[%s] - Metadata is not available.",endPoint)).
							put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
							build()));
				isMetadataAvailable = false;
			}else if (HttpStatus.OK.equals(response.getHttpstatus())) {
				log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
						put(LogMessage.ACTION, "isCertAvailableInMetadata").
						put(LogMessage.MESSAGE, String.format("[%s]  - Skipping Onboard flow -  Certificate already available in metadata. ",endPoint)).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
						build()));
			}
			return isMetadataAvailable;
		    }
/**
		    * To check if metadata is already created for the given certificate. If yes, skip the certificate
		    * @param jsonObject
		    * @param token
		    * @return
		    */
To check if metadata is already created for the given certificate. If yes, skip the certificate
@param jsonObject
@param token
@return
To check if metadata is already created for the given certificate . If yes skip the certificate @param jsonObject @param token @return
private boolean isCertAvailableInMetadata(JsonObject jsonObject, String token) {
		    boolean isMetadataAvailable = true;
		    String endPoint = jsonObject.get(SSLCertificateConstants.COMMON_NAME).getAsString();
			String metaDataPath = (jsonObject.get(SSLCertificateConstants.CERT_TYPE).getAsString().equalsIgnoreCase(SSLCertificateConstants.INTERNAL))?
		            SSLCertificateConstants.SSL_CERT_PATH + "/" + endPoint :SSLCertificateConstants.SSL_EXTERNAL_CERT_PATH + "/" + endPoint;
			Response response = new Response();
			try {		
					response = reqProcessor.process("/read", "{\"path\":\"" + metaDataPath + "\"}", token);		
			} catch (Exception e) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, SSLCertificateConstants.ONBOARD_SSL_CERTIFICATE)
						.put(LogMessage.MESSAGE, String.format("\"[%s]  - Skipping Onboard flow -  Error occured while checking certificate "
								+ "is available in metadata.Exception = [%s] =  Message [%s]", 
								endPoint,Arrays.toString(e.getStackTrace()), response.getResponse()))
						.build()));
				 isMetadataAvailable = false;
			}
			if (!HttpStatus.OK.equals(response.getHttpstatus())) {
				log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
							put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
							put(LogMessage.ACTION, SSLCertificateConstants.ONBOARD_SSL_CERTIFICATE).
							put(LogMessage.MESSAGE, String.format("[%s] - Metadata is not available.",endPoint)).
							put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
							build()));
				isMetadataAvailable = false;
			}else if (HttpStatus.OK.equals(response.getHttpstatus())) {
				log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
						put(LogMessage.ACTION, "isCertAvailableInMetadata").
						put(LogMessage.MESSAGE, String.format("[%s]  - Skipping Onboard flow -  Certificate already available in metadata. ",endPoint)).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
						build()));
			}
			return isMetadataAvailable;
		    }
private boolean isCertAvailableInMetadata ( JsonObject jsonObject , String token ) { boolean isMetadataAvailable = true ; String endPoint = jsonObject . get ( SSLCertificateConstants . COMMON_NAME ) . getAsString ( ) ; String metaDataPath = ( jsonObject . get ( SSLCertificateConstants . CERT_TYPE ) . getAsString ( ) . equalsIgnoreCase ( SSLCertificateConstants . INTERNAL ) ) ? SSLCertificateConstants . SSL_CERT_PATH + "/" + endPoint : SSLCertificateConstants . SSL_EXTERNAL_CERT_PATH + "/" + endPoint ; Response response = new Response ( ) ; try { response = reqProcessor . process ( "/read" , "{\"path\":\"" + metaDataPath + "\"}" , token ) ; } catch ( Exception e ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . ONBOARD_SSL_CERTIFICATE ) . put ( LogMessage . MESSAGE , String . format ( "\"[%s]  - Skipping Onboard flow -  Error occured while checking certificate " + "is available in metadata.Exception = [%s] =  Message [%s]" , endPoint , Arrays . toString ( e . getStackTrace ( ) ) , response . getResponse ( ) ) ) . build ( ) ) ) ; isMetadataAvailable = false ; } if ( ! HttpStatus . OK . equals ( response . getHttpstatus ( ) ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . ONBOARD_SSL_CERTIFICATE ) . put ( LogMessage . MESSAGE , String . format ( "[%s] - Metadata is not available." , endPoint ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; isMetadataAvailable = false ; } else if ( HttpStatus . OK . equals ( response . getHttpstatus ( ) ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , "isCertAvailableInMetadata" ) . put ( LogMessage . MESSAGE , String . format ( "[%s]  - Skipping Onboard flow -  Certificate already available in metadata. " , endPoint ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; } return isMetadataAvailable ; }
To check if metadata is already created for the given certificate.
To check if metadata is already created for the given certificate .