1 package oic.simulator.serviceprovider.utils;
3 import java.util.ArrayList;
4 import java.util.Iterator;
10 public static String uriToDisplayName(String uri) {
13 String tokens[] = uri.split(Constants.FORWARD_SLASH);
14 if (Constants.PROPER_RESOURCE_URI_TOKEN_COUNT == tokens.length) {
16 result = tokens[2] + Constants.UNDERSCORE + tokens[4];
22 public static String displayNameToUri(String displayName) {
24 if (null != displayName) {
25 String tokens[] = displayName.split(Constants.UNDERSCORE);
26 if (Constants.DISPLAY_RESOURCE_URI_TOKEN_COUNT == tokens.length) {
27 // Proper Display Name
28 result = Constants.FORWARD_SLASH + Constants.OIC
29 + Constants.FORWARD_SLASH + tokens[0]
30 + Constants.FORWARD_SLASH + Constants.SIMULATOR
31 + Constants.FORWARD_SLASH + tokens[1];
37 public static String fileNameToDisplay(String fileName) {
38 if (null == fileName || fileName.length() < 1) {
41 // Remove the RAML file standard prefix
42 int len = Constants.RAML_FILE_PREFIX.length();
44 if (fileName.startsWith(Constants.RAML_FILE_PREFIX)) {
45 fileName = fileName.substring(len);
49 // Removing the file extension
50 String[] token = fileName.split(Constants.SPLIT_BY_DOT_PATTERN);
51 int tokLen = token.length;
53 if (tokLen - 2 >= 0) {
54 result = token[tokLen - 2];
59 public static String displayToFileName(String displayName) {
60 if (null == displayName || displayName.length() < 1) {
65 fileName = Constants.RAML_FILE_PREFIX + displayName;
67 // Adding the file extension
68 fileName = fileName + Constants.RAML_FILE_EXTENSION;
73 public static boolean isUriComplete(String uri) {
74 boolean uriComplete = false;
76 String tokens[] = uri.split(Constants.FORWARD_SLASH);
77 if (Constants.PROPER_RESOURCE_URI_TOKEN_COUNT == tokens.length) {
84 public static String getAutomationStatus(boolean status) {
86 return Constants.ENABLED;
88 return Constants.DISABLED;
92 public static String getAutomationString(boolean status) {
94 return Constants.ENABLE;
96 return Constants.DISABLE;
100 public static boolean getAutomationBoolean(String status) {
101 if (null != status) {
102 if (status.equals(Constants.ENABLE)) {
109 public static int getUpdateIntervalFromString(String value) {
110 int result = Constants.DEFAULT_AUTOMATION_INTERVAL;
113 result = Integer.parseInt(value);
114 } catch (NumberFormatException nfe) {
121 public static List<String> convertSetToList(Set<String> typeSet) {
122 if (null == typeSet) {
125 List<String> list = new ArrayList<String>();
126 Iterator<String> typeItr = typeSet.iterator();
127 while (typeItr.hasNext()) {
128 list.add(typeItr.next());