tvaultapi/src/main/java/com/tmobile/cso/vault/api/controller/ControllerUtil.java
public static boolean canAddPermission(String path,String token) {
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
			      put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
				  put(LogMessage.ACTION, "canAddPermission").
			      put(LogMessage.MESSAGE, "Start executing canAddPermission.").
			      put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
			      build()));
		String safeType = ControllerUtil.getSafeType(path);
		String safeName = ControllerUtil.getSafeName(path);
		
		List<String> existingSafeNames = getAllExistingSafeNames(safeType, token);
		List<String> duplicateSafeNames = new ArrayList<String>();
		int count=0;
		for (String existingSafeName: existingSafeNames) {
			if (existingSafeName.equalsIgnoreCase(safeName)) {
				count++;
				duplicateSafeNames.add(existingSafeName);
			}
		}
		if (count == 1) {
			// There is one valid safe, Hence permission can be added
			// Exact match
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
				      put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					  put(LogMessage.ACTION, "canAddPermission").
				      put(LogMessage.MESSAGE, "Completed canAddPermission check and there is one valid safe, Hence permission can be added").
				      put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
				      build()));
			return true;
		}
		else {
			// There are no safes or more than one and hence permission can't be added
			return false;
		}
	}
/**
	 * Decides whether a user can be added to a safe or not
	 * @param path
	 * @param token
	 * @return
	 */
Decides whether a user can be added to a safe or not
@param path
@param token
@return
Decides whether a user can be added to a safe or not @param path @param token @return
public static boolean canAddPermission(String path,String token) {
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
			      put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
				  put(LogMessage.ACTION, "canAddPermission").
			      put(LogMessage.MESSAGE, "Start executing canAddPermission.").
			      put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
			      build()));
		String safeType = ControllerUtil.getSafeType(path);
		String safeName = ControllerUtil.getSafeName(path);
		List<String> existingSafeNames = getAllExistingSafeNames(safeType, token);
		List<String> duplicateSafeNames = new ArrayList<String>();
		int count=0;
		for (String existingSafeName: existingSafeNames) {
			if (existingSafeName.equalsIgnoreCase(safeName)) {
				count++;
				duplicateSafeNames.add(existingSafeName);
			}
		}
		if (count == 1) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
				      put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					  put(LogMessage.ACTION, "canAddPermission").
				      put(LogMessage.MESSAGE, "Completed canAddPermission check and there is one valid safe, Hence permission can be added").
				      put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
				      build()));
			return true;
		}
		else {
			return false;
		}
	}
public static boolean canAddPermission ( String path , String token ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , "canAddPermission" ) . put ( LogMessage . MESSAGE , "Start executing canAddPermission." ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; String safeType = ControllerUtil . getSafeType ( path ) ; String safeName = ControllerUtil . getSafeName ( path ) ; List < String > existingSafeNames = getAllExistingSafeNames ( safeType , token ) ; List < String > duplicateSafeNames = new ArrayList < String > ( ) ; int count = 0 ; for ( String existingSafeName : existingSafeNames ) { if ( existingSafeName . equalsIgnoreCase ( safeName ) ) { count ++ ; duplicateSafeNames . add ( existingSafeName ) ; } } if ( count == 1 ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , "canAddPermission" ) . put ( LogMessage . MESSAGE , "Completed canAddPermission check and there is one valid safe, Hence permission can be added" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return true ; } else { return false ; } }
Decides whether a user can be added to a safe or not
 @param path
 @param token
 @return
Decides whether a user can be added to a safe or not @param path @param token @return
// There is one valid safe, Hence permission can be added // Exact match // There are no safes or more than one and hence permission can't be added