IoTivity Simulator System testing bug fixes.
authorG S Senthil Kumar <senthil.gs@samsung.com>
Mon, 7 Dec 2015 10:03:50 +0000 (15:33 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Wed, 16 Dec 2015 05:43:46 +0000 (05:43 +0000)
1. Resolved issues found during stress testing.
2. Limiting the maximum number of resources that can be created
   from server to 200(Considering block-wise transfer and application
   stability).
3. Includes minor optimization and code clean-up.

Change-Id: If196b72b5221e3795b4693f00a99d33650c0a8d0
Signed-off-by: G S Senthil Kumar <senthil.gs@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4431
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Radha Bhavani <radha.p@samsung.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
19 files changed:
service/simulator/SConscript
service/simulator/java/eclipse-plugin/ClientControllerPlugin/.classpath
service/simulator/java/eclipse-plugin/ClientControllerPlugin/build.properties
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/ResourceManager.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/AttributeEditingSupport.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/.classpath
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/build.properties
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/Data.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/model/AttributeElement.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/model/ResourceRepresentation.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/model/SingleResource.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Constants.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeEditingSupport.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceManagerView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourceWizard.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/LoadRamlPage.java
service/simulator/ramlparser/SConscript

index b77e5dcfaf8a13351dc3c628893e933edb25bd96..8e77c4e536e875568d27692ea29e219995d0f34e 100755 (executable)
@@ -68,7 +68,7 @@ java_headers.append(os.path.join(java_headers[0], 'solaris'))
 simulator_env.AppendUnique(CPPPATH = java_headers)
 
 simulator_env.AppendUnique(CPPPATH = ['../../extlibs/cjson'])
-simulator_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'libcoap','RamlParser','YamlParser'])
+simulator_env.PrependUnique(LIBS = ['oc', 'RamlParser'])
 simulator_env.AppendUnique(LIBS = ['pthread'])
 
 simulator_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
index cd0df03356243cf5f766f3fb6a120129bacabaa0..cdbd8da22d82650d0d98308c3657b5a20669bf63 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry kind="lib" path="libs/Simulator.jar"/>
-       <classpathentry kind="output" path="bin"/>
+    <classpathentry exported="true" kind="lib" path="libs/Simulator.jar"/>
+    <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+    <classpathentry kind="src" path="src"/>
+    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+    <classpathentry kind="output" path="bin"/>
 </classpath>
index 100c21da7e9aec53c54558440ac678e12a8b3b59..e1ca3fa4375363c8898635b98f6fb3a573b957cd 100644 (file)
@@ -4,5 +4,4 @@ bin.includes = META-INF/,\
                .,\
                plugin.xml,\
                icons/,\
-               libs/Simulator.jar,\
-               libs/libSimulatorManager.so
+               libs/
index a891896f7bd7c1ff959cf267ea798e0c5a8efb80..c417fca354edb25be2a0972cacc402b1bb05f4d1 100644 (file)
@@ -1269,13 +1269,6 @@ public class ResourceManager {
                     devInfo.getDataModelVersion()));
         }
 
-        /*
-         * metaProperties.add(new MetaProperty(Constants.DEVICE_ID, ""));
-         * metaProperties.add(new MetaProperty(Constants.DEVICE_NAME, ""));
-         * metaProperties.add(new MetaProperty(Constants.DEVICE_SPEC_VERSION,
-         * "")); metaProperties.add(new
-         * MetaProperty(Constants.DEVICE_DMV_VERSION, ""));
-         */
         return metaProperties;
     }
 
index a58b42c87b0d7d0a16ac4aa3191b406b54e4a29f..55f93d156685943071b5380b9c703b8739bef5db 100644 (file)
@@ -278,42 +278,6 @@ public class AttributeEditingSupport {
                 }
             }
         }
-
-        public AttributeValue getResultantValue(AttributeValue newValue) {
-            AttributeValue val = null;
-            IStructuredSelection selection = (IStructuredSelection) viewer
-                    .getSelection();
-            if (null == selection) {
-                return null;
-            }
-
-            Object obj = selection.getFirstElement();
-            if (null == obj) {
-                return null;
-            }
-
-            Tree t = viewer.getTree();
-            TreeItem item = t.getSelection()[0];
-            if (null == item) {
-                return null;
-            }
-
-            TreeItem parent = item.getParentItem();
-            if (null == parent) {
-                val = newValue;
-            } else {
-                while (parent.getParentItem() != null) {
-                    parent = parent.getParentItem();
-                }
-                // Parent will point to the top-level attribute of type
-                // LocalResourceAttribute
-                Object data = parent.getData();
-                val = ((AttributeElement) data).getSimulatorResourceAttribute()
-                        .value();
-            }
-
-            return val;
-        }
     }
 
     class PostRequestEditor extends EditingSupport {
index ad84a719836cdf0c4a20577927ba3b0347aa2e1a..4e3db9686263283a1f0d7b82584261be1642701e 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-    <classpathentry kind="lib" path="libs/Simulator.jar"/>
-    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
     <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
     <classpathentry kind="src" path="src"/>
+    <classpathentry kind="lib" path="libs/Simulator.jar"/>
     <classpathentry kind="output" path="bin"/>
 </classpath>
index 8dc5385adec0812ac947967dedb59e4c3a2d5dd1..b522aba9e53e0f15577e12069998edaf09f35821 100644 (file)
@@ -4,5 +4,5 @@ bin.includes = META-INF/,\
                .,\
                icons/,\
                plugin.xml,\
-               libs/,\
+               libs/
 
index 17517f12e2270aa774bb4a8a92a963ad89501b70..fa079f49385de655cac25dad4f67b6ec0629a3b0 100644 (file)
@@ -291,4 +291,7 @@ public class Data {
         return res;
     }
 
+    public synchronized int getResourceCount() {
+        return singleResourceMap.size() + collectionResourceMap.size();
+    }
 }
index 5d075daa055ba86bb86054637d89e0d9cc7016b0..a58e4280af25aef7f8edec6e9f9ef1da4ad67fd2 100644 (file)
@@ -1801,7 +1801,7 @@ public class ResourceManager {
         return true;
     }
 
-    public void attributeValueUpdated(SingleResource resource,
+    public boolean attributeValueUpdated(SingleResource resource,
             String attributeName, AttributeValue value) {
         if (null != resource && null != attributeName && null != value) {
             SimulatorSingleResource simRes = (SimulatorSingleResource) resource
@@ -1809,6 +1809,7 @@ public class ResourceManager {
             if (null != simRes) {
                 try {
                     simRes.updateAttribute(attributeName, value);
+                    return true;
                 } catch (SimulatorException e) {
                     Activator
                             .getDefault()
@@ -1818,6 +1819,7 @@ public class ResourceManager {
                 }
             }
         }
+        return false;
     }
 
     // TODO: This method should get the status from the native layer.
@@ -2382,4 +2384,8 @@ public class ResourceManager {
         }
         return values;
     }
+
+    public int getResourceCount() {
+        return data.getResourceCount();
+    }
 }
\ No newline at end of file
index 2d56a23467bc37f3fcb0ec18eb7ae9b0f3d809a7..e2b0b8c0d6dc553e7fb552bf276610d36b85748e 100644 (file)
@@ -22,6 +22,7 @@ public class AttributeElement {
     private boolean                       mAutoUpdateState    = false;
     private int                           mAutoUpdateInterval = Constants.DEFAULT_AUTOMATION_INTERVAL;
     private AutoUpdateType                mAutoUpdateType     = Constants.DEFAULT_AUTOMATION_TYPE;
+    private boolean                       mEditLock           = false;
 
     public AttributeElement(Object parent,
             SimulatorResourceAttribute attribute, boolean autoUpdateSupport)
@@ -145,6 +146,14 @@ public class AttributeElement {
         return (null == mAttribute.property());
     }
 
+    public synchronized boolean getEditLock() {
+        return mEditLock;
+    }
+
+    public synchronized void setEditLock(boolean editLock) {
+        this.mEditLock = editLock;
+    }
+
     public void update(SimulatorResourceAttribute attribute) {
         if (attribute == null)
             return;
@@ -243,7 +252,7 @@ public class AttributeElement {
             String newValue = new AttributeValueStringConverter(
                     attribute.value()).toString();
             if (!currentValue.equals(newValue)) {
-                mAttribute = attribute;
+                mAttribute.setValue(attribute.value());
                 UiListenerHandler.getInstance().attributeUpdatedUINotification(
                         this);
             }
index 0e2dfbfbe99f951c264512b46af69283347d9489..acce7be82aab96cf484ebd76cbca545528caa9af 100644 (file)
@@ -33,8 +33,9 @@ public class ResourceRepresentation {
         for (Map.Entry<String, SimulatorResourceAttribute> entry : resourceModel
                 .getAttributes().entrySet()) {
             AttributeElement attributeElement = mAttributes.get(entry.getKey());
-            if (attributeElement != null) {
-                attributeElement.update(entry.getValue());
+            if (null != attributeElement) {
+                if (!attributeElement.getEditLock())
+                    attributeElement.update(entry.getValue());
             } else // Display new attribute in UI
             {
                 AttributeElement newAttribute = new AttributeElement(this,
index 899bc60f8acd9de2bc9f2151301193c59879086d..b47b74087f2c759d977983b98849481186d9fecf 100644 (file)
@@ -163,11 +163,4 @@ public class SingleResource extends Resource {
             boolean attributeAutomationInProgress) {
         this.attributeAutomationInProgress = attributeAutomationInProgress;
     }
-
-    /*
-     * public LocalResourceAttribute getAttribute(String attributeName) { if
-     * (null == attributeName || null == resourceAttributesMap ||
-     * resourceAttributesMap.size() < 1) { return null; } return
-     * resourceAttributesMap.get(attributeName); }
-     */
 }
\ No newline at end of file
index aaf574eb7cb227f4d9f2f20fcbbd0371d11eff0d..ebc12fc1e066da94db6dd262a1bb94d31aaa68bf 100644 (file)
@@ -172,4 +172,5 @@ public class Constants {
     public static final String         INVALID_URI_MESSAGE                                  = "Resource URI should start with a '/' followed by atleast one character and it should not contain either # or ? or % or consecutive '/'.";
     public static final int            TREE_EXPANSION_LEVEL                                 = 10;
 
+    public static final int            MAX_RESOURCE_COUNT                                   = 200;
 }
\ No newline at end of file
index ebd643969311ff8c8ccc1eb7579e03b15c7ac9cb..d0d53787449eac0d9714eb530cdb7da45ca2b6a7 100644 (file)
@@ -109,7 +109,7 @@ public class AttributeEditingSupport {
                 return null;
             }
 
-            AttributeElement attributeElement = ((AttributeElement) element);
+            final AttributeElement attributeElement = ((AttributeElement) element);
             attribute = attributeElement.getSimulatorResourceAttribute();
             if (null == attribute) {
                 return null;
@@ -162,58 +162,13 @@ public class AttributeEditingSupport {
                     String oldValue = String.valueOf(Utility
                             .getAttributeValueAsString(val));
                     String newValue = comboBox.getText();
-                    if (!oldValue.equals(newValue)) {
-                        // Get the AttriuteValue from the string
-                        AttributeValue value = AttributeValueBuilder.build(
-                                newValue, type.mBaseType);
-                        boolean invalid = false;
-                        if (null == value) {
-                            invalid = true;
-                        } else {
-                            TypeInfo resTypeInfo = value.typeInfo();
-                            if (type.mDepth != resTypeInfo.mDepth
-                                    || type.mType != resTypeInfo.mType
-                                    || type.mBaseType != resTypeInfo.mBaseType) {
-                                invalid = true;
-                            }
-                        }
-                        if (invalid) {
-                            MessageBox dialog = new MessageBox(viewer.getTree()
-                                    .getShell(), SWT.ICON_ERROR | SWT.OK);
-                            dialog.setText("Invalid Value");
-                            dialog.setMessage("Given value is invalid");
-                            dialog.open();
-                        } else {
-                            updateAttributeValue(attribute, value);
-                            MessageBox dialog = new MessageBox(viewer.getTree()
-                                    .getShell(), SWT.ICON_QUESTION | SWT.OK
-                                    | SWT.CANCEL);
-                            dialog.setText("Confirm action");
-                            dialog.setMessage("Do you want to modify the value?");
-                            int retval = dialog.open();
-                            if (retval != SWT.OK) {
-                                value = AttributeValueBuilder.build(oldValue,
-                                        type.mBaseType);
-                                updateAttributeValue(attribute, value);
-                            } else {
-                                ResourceManager resourceManager;
-                                resourceManager = Activator.getDefault()
-                                        .getResourceManager();
-
-                                Resource resource = resourceManager
-                                        .getCurrentResourceInSelection();
-
-                                SimulatorResourceAttribute result = getResultantValue(value);
-
-                                resourceManager.attributeValueUpdated(
-                                        (SingleResource) resource,
-                                        result.name(), result.value());
 
-                            }
-                        }
-                        viewer.update(element, null);
-                        comboBox.setVisible(false);
-                    }
+                    attributeElement.setEditLock(true);
+                    compareAndUpdateAttribute(oldValue, newValue, element,
+                            attribute, type);
+                    attributeElement.setEditLock(false);
+
+                    comboBox.setVisible(false);
                 }
             });
             return comboEditor;
@@ -247,85 +202,73 @@ public class AttributeEditingSupport {
 
         @Override
         protected void setValue(Object element, Object value) {
-            SimulatorResourceAttribute att = null;
-
-            if (element instanceof AttributeElement) {
-                att = ((AttributeElement) element)
-                        .getSimulatorResourceAttribute();
-            }
-
-            if (att == null) {
-                return;
-            }
+        }
 
-            AttributeValue val = att.value();
-            if (null == val) {
+        public void compareAndUpdateAttribute(String oldValue, String newValue,
+                Object element, SimulatorResourceAttribute att, TypeInfo type) {
+            if (null == oldValue || null == newValue || null == element
+                    || null == att || null == type) {
                 return;
             }
-            TypeInfo type = val.typeInfo();
-            if (type.mType == ValueType.ARRAY) {
-                int index;
-                try {
-                    index = Integer.parseInt(String.valueOf(value));
-                } catch (NumberFormatException nfe) {
-                    index = -1;
+            if (!oldValue.equals(newValue)) {
+                // Get the AttriuteValue from the string
+                AttributeValue attValue = AttributeValueBuilder.build(newValue,
+                        type.mBaseType);
+                boolean invalid = false;
+                if (null == attValue) {
+                    invalid = true;
+                } else {
+                    TypeInfo resTypeInfo = attValue.typeInfo();
+                    if (type.mDepth != resTypeInfo.mDepth
+                            || type.mType != resTypeInfo.mType
+                            || type.mBaseType != resTypeInfo.mBaseType) {
+                        invalid = true;
+                    }
                 }
-                if (index == -1) {
-                    String oldValue = String.valueOf(Utility
-                            .getAttributeValueAsString(val));
-                    String newValue = comboBox.getText();
-                    if (!oldValue.equals(newValue)) {
-                        // Get the AttriuteValue from the string
-                        AttributeValue attValue = AttributeValueBuilder.build(
-                                newValue, type.mBaseType);
-                        boolean invalid = false;
-                        if (null == attValue) {
-                            invalid = true;
-                        } else {
-                            TypeInfo resTypeInfo = attValue.typeInfo();
-                            if (type.mDepth != resTypeInfo.mDepth
-                                    || type.mType != resTypeInfo.mType
-                                    || type.mBaseType != resTypeInfo.mBaseType) {
-                                invalid = true;
-                            }
-                        }
-                        if (invalid) {
-                            MessageBox dialog = new MessageBox(viewer.getTree()
-                                    .getShell(), SWT.ICON_ERROR | SWT.OK);
-                            dialog.setText("Invalid Value");
-                            dialog.setMessage("Given value is invalid");
-                            dialog.open();
-                        } else {
-                            updateAttributeValue(att, attValue);
-                            MessageBox dialog = new MessageBox(viewer.getTree()
-                                    .getShell(), SWT.ICON_QUESTION | SWT.OK
-                                    | SWT.CANCEL);
-                            dialog.setText("Confirm action");
-                            dialog.setMessage("Do you want to modify the value?");
-                            int retval = dialog.open();
-                            if (retval != SWT.OK) {
-                                attValue = AttributeValueBuilder.build(
-                                        oldValue, type.mBaseType);
-                                updateAttributeValue(att, attValue);
-                            } else {
-                                ResourceManager resourceManager;
-                                resourceManager = Activator.getDefault()
-                                        .getResourceManager();
-
-                                Resource resource = resourceManager
-                                        .getCurrentResourceInSelection();
-
-                                SimulatorResourceAttribute result = getResultantValue(attValue);
-
-                                resourceManager.attributeValueUpdated(
+                if (invalid) {
+                    MessageBox dialog = new MessageBox(viewer.getTree()
+                            .getShell(), SWT.ICON_ERROR | SWT.OK);
+                    dialog.setText("Invalid Value");
+                    dialog.setMessage("Given value is invalid");
+                    dialog.open();
+                } else {
+                    MessageBox dialog = new MessageBox(viewer.getTree()
+                            .getShell(), SWT.ICON_QUESTION | SWT.OK
+                            | SWT.CANCEL);
+                    dialog.setText("Confirm action");
+                    dialog.setMessage("Do you want to modify the value?");
+                    int retval = dialog.open();
+                    if (retval != SWT.OK) {
+                        attValue = AttributeValueBuilder.build(oldValue,
+                                type.mBaseType);
+                        updateAttributeValue(att, attValue);
+                    } else {
+                        updateAttributeValue(att, attValue);
+
+                        ResourceManager resourceManager;
+                        resourceManager = Activator.getDefault()
+                                .getResourceManager();
+
+                        Resource resource = resourceManager
+                                .getCurrentResourceInSelection();
+
+                        SimulatorResourceAttribute result = getResultantAttribute();
+
+                        boolean updated = resourceManager
+                                .attributeValueUpdated(
                                         (SingleResource) resource,
                                         result.name(), result.value());
-                            }
+                        if (!updated) {
+                            attValue = AttributeValueBuilder.build(oldValue,
+                                    type.mBaseType);
+                            updateAttributeValue(att, attValue);
+                            MessageDialog.openInformation(Display.getDefault()
+                                    .getActiveShell(), "Operation failed",
+                                    "Failed to update the attribute value.");
                         }
                     }
                 }
             }
-
             viewer.update(element, null);
         }
 
@@ -341,8 +284,6 @@ public class AttributeEditingSupport {
 
         public void updateAttributeValue(SimulatorResourceAttribute att,
                 AttributeValue value) {
-            att.setValue(value);
-
             IStructuredSelection selection = (IStructuredSelection) viewer
                     .getSelection();
             if (null == selection) {
@@ -378,8 +319,7 @@ public class AttributeEditingSupport {
             }
         }
 
-        public SimulatorResourceAttribute getResultantValue(
-                AttributeValue newValue) {
+        public SimulatorResourceAttribute getResultantAttribute() {
             IStructuredSelection selection = (IStructuredSelection) viewer
                     .getSelection();
             if (null == selection) {
@@ -535,8 +475,6 @@ public class AttributeEditingSupport {
                         MessageDialog.openInformation(Display.getDefault()
                                 .getActiveShell(), "Automation Status",
                                 "Automation start failed!!");
-                    } else {
-                        // viewer.update(element, null);
                     }
                 }
             } else {
@@ -546,7 +484,6 @@ public class AttributeEditingSupport {
                 MessageDialog.openInformation(Display.getDefault()
                         .getActiveShell(), "Automation Status",
                         "Automation stopped.");
-                // viewer.update(element, null);
             }
         }
     }
index 2f707a4d591db1e3e25cd6e8c1519a48a04a07dc..d7cc73284b05f349c8f606692281736afbbf83fa 100644 (file)
@@ -89,20 +89,27 @@ public class AttributeView extends ViewPart {
                             if (null == tree || tree.isDisposed()) {
                                 return;
                             }
+
+                            // Enabling/disabling the tree based on the resource
+                            // and automation status.
+                            if (resource instanceof SingleResource)
+                                if (((SingleResource) resource)
+                                        .isResourceAutomationInProgress())
+                                    tree.setEnabled(false);
+                                else
+                                    tree.setEnabled(true);
+
                             if (null != resource
                                     && null != resource
                                             .getResourceRepresentation()) {
                                 attViewer.setInput(resource
                                         .getResourceRepresentation());
                                 attViewer.expandAll();
-                                if (null != tree) {
-                                    tree.setLinesVisible(true);
-                                }
+                                tree.setLinesVisible(true);
+
                             } else {
                                 attViewer.setInput(null);
-                                if (null != tree) {
-                                    tree.setLinesVisible(false);
-                                }
+                                tree.setLinesVisible(false);
                             }
                         }
                     }
index 7b1b0f600b25cd1cf24605387297d94c53b0cc74..a40717cf41c2f80c803c3ed33f040e60ede1a550 100644 (file)
@@ -1486,6 +1486,14 @@ public class ResourceManagerView extends ViewPart {
         createButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
+                if (resourceManager.getResourceCount() >= Constants.MAX_RESOURCE_COUNT) {
+                    MessageDialog
+                            .openInformation(Display.getDefault()
+                                    .getActiveShell(),
+                                    "Resource limit exceeded",
+                                    "Exceeded the limit of resources that can exist in the server.");
+                    return;
+                }
                 PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
 
                     @Override
index 016fe4733dabb24e84be9015c743787d97ac60e9..0d7aa0b278aa622e2136206d814130bc6f71407e 100644 (file)
@@ -207,6 +207,15 @@ public class CreateResourceWizard extends Wizard {
         } else if (curPage == loadRamlPage) { // Handling multi-instance
             // creation of simple resource
             // with RAML
+            if ((loadRamlPage.getResourceCount() + Activator.getDefault()
+                    .getResourceManager().getResourceCount()) > Constants.MAX_RESOURCE_COUNT) {
+                MessageDialog
+                        .openInformation(Display.getDefault().getActiveShell(),
+                                "Resource limit exceeded",
+                                "Exceeded the limit of resources that can exist in the server.");
+                return false;
+            }
+
             try {
                 getContainer().run(true, true, new IRunnableWithProgress() {
 
@@ -525,14 +534,15 @@ public class CreateResourceWizard extends Wizard {
                     .createSingleResource(resource, attributes);
             if (result) {
                 status = "Resource created.";
+                createdResource = resource;
             } else {
                 status = "Failed to create resource.";
-                resource = null;
+                createdResource = null;
             }
         } catch (Exception e) {
             status = "Failed to create resource.\n"
                     + Utility.getSimulatorErrorString(e, null);
-            resource = null;
+            createdResource = null;
         }
     }
 
index 9f5b7d975869a1ba98e1d4a74ee03524e4686ab2..54e4fa28b4a5cc5e46c1961714e59c39c4caefe6 100644 (file)
@@ -44,6 +44,7 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Group;
@@ -264,6 +265,16 @@ public class LoadRamlPage extends WizardPage {
             // itself.
             return null;
         }
+
+        // Checking the resource count
+        if ((Activator.getDefault().getResourceManager().getResourceCount() + resourceCount) > Constants.MAX_RESOURCE_COUNT) {
+            MessageDialog
+                    .openInformation(Display.getDefault().getActiveShell(),
+                            "Resource limit exceeded",
+                            "Exceeded the limit of resources that can exist in the server.");
+            return null;
+        }
+
         final CreateResourceWizard wizard = ((CreateResourceWizard) getWizard());
 
         try {
index efaa23c38b40206eafa635fd8ad73a97417ffbb3..adb8803407f49c1847b97a90899f63b8fcd37c75 100755 (executable)
@@ -33,7 +33,7 @@ raml_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
 raml_env.AppendUnique(CPPDEFINES = ['LINUX'])\r
 \r
 raml_env.AppendUnique(CPPPATH = ['../../../extlibs/cjson/'])\r
-raml_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'libcoap','YamlParser'])\r
+raml_env.PrependUnique(LIBS = ['octbstack', 'YamlParser'])\r
 raml_env.AppendUnique(LIBS = ['pthread'])\r
 \r
 raml_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])\r