[IoTivity Simulator] Handling resource interfaces.
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ServiceProviderPlugin / src / oic / simulator / serviceprovider / utils / Utility.java
index 23be6db..d95b33e 100644 (file)
@@ -512,14 +512,32 @@ public class Utility {
     }
 
     public static boolean isUriValid(String resURI) {
-        if (null == resURI || resURI.length() < 2 || !resURI.startsWith("/")
-                || resURI.contains("//") || resURI.contains("?")
+        if (null == resURI || resURI.length() < 2 || resURI.length() > 63
+                || !resURI.startsWith("/") || resURI.endsWith("/")
+                || resURI.contains("/..") || resURI.contains("//")
+                || resURI.contains("/./") || resURI.contains("?")
                 || resURI.contains("#") || resURI.contains("%")) {
             return false;
         }
         return true;
     }
 
+    public static boolean isResourceTypeValid(String resType) {
+        if (null == resType || resType.isEmpty()) {
+            return false;
+        }
+
+        char[] ch = resType.toCharArray();
+        for (char c : ch) {
+            if (c != '.' && c != '-' && (c < 'a' || c > 'z')
+                    && (c < '0' || c > '9')) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
     public static Map<String, String> getResourceInterfaces(
             Class<? extends Resource> resourceClass) {
         Map<String, String> ifTypes = null;
@@ -533,5 +551,4 @@ public class Utility {
         }
         return ifTypes;
     }
-
 }
\ No newline at end of file