Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahdi BEN ALAYA2014-07-14 15:45:55 +0000
committerMahdi BEN ALAYA2014-07-14 15:45:55 +0000
commit4a5a4bb09ed5e812ab10273dbfa60ed95d9ab087 (patch)
tree543713eb6dd8eb3ab5cb7ea7e34b9f6cc3bb9d1a
parent7b78ddfe90b965d96b00e9cfb0c35180c9861a82 (diff)
downloadorg.eclipse.om2m-4a5a4bb09ed5e812ab10273dbfa60ed95d9ab087.tar.gz
org.eclipse.om2m-4a5a4bb09ed5e812ab10273dbfa60ed95d9ab087.tar.xz
org.eclipse.om2m-4a5a4bb09ed5e812ab10273dbfa60ed95d9ab087.zip
Update GSCL/NSCL registration procedure to make it compliant with the
ETSI M2M specification.
-rw-r--r--org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/Activator.java23
-rw-r--r--org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SclController.java71
2 files changed, 21 insertions, 73 deletions
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/Activator.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/Activator.java
index b229b111..b55c0b2e 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/Activator.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/Activator.java
@@ -205,7 +205,7 @@ public class Activator implements BundleActivator {
* Sends {@link SclBase} resource in DataBase.
*/
public static void registerScl(){
- //Create an Scl resource
+ //Create an GSCL Scl resource
Scl gscl = new Scl();
gscl.setSclId(Constants.SCL_ID);
AnyURIList pocs = new AnyURIList();
@@ -241,7 +241,7 @@ public class Activator implements BundleActivator {
responseConfirm = new RestClient().sendRequest(requestIndication);
//Stop registration if success of GSCL already registered
if(responseConfirm.getStatusCode().equals(StatusCode.STATUS_CREATED)){
- LOGGER.info("GSCL successfully registered to NSCL");
+ LOGGER.info("GSCL is successfully registered to NSCL");
registred=true;
}else if(responseConfirm.getStatusCode().equals(StatusCode.STATUS_CONFLICT)){
LOGGER.info("GSCL is already registered to NSCL");
@@ -257,6 +257,25 @@ public class Activator implements BundleActivator {
}
}
}
+ //Create an NSCL Scl resource
+ LOGGER.info("Create NSCL registration on GSCL");
+ Scl nscl = new Scl();
+ nscl.setUri(Constants.SCL_ID+""+"/scls/"+Constants.NSCL_ID);
+ nscl.setSclId(Constants.NSCL_ID);
+ nscl.setAccessRightID(Constants.SCL_ID+"/accessRights/"+Constants.ADMIN_PROFILE_ID);
+ nscl.setCreationTime(DateConverter.toXMLGregorianCalendar(new Date()));
+ nscl.setLastModifiedTime(DateConverter.toXMLGregorianCalendar(new Date()));
+ SearchStrings searchStrings = new SearchStrings();
+ searchStrings.getSearchString().add(Constants.SEARCH_STRING_RES_TYPE+nscl.getClass().getSimpleName());
+ searchStrings.getSearchString().add(Constants.SEARCH_STRING_RES_ID+Constants.NSCL_ID);
+ nscl.setSearchStrings(searchStrings);
+ AnyURIList pocs = new AnyURIList();
+ pocs.getReference().add(Constants.SCL_DEFAULT_PROTOCOL+"://"+Constants.NSCL_IP+":"+Constants.NSCL_PORT+Constants.CONTEXT);
+ nscl.setPocs(pocs);
+ nscl.setLink(Constants.NSCL_ID);
+ nscl.setMgmtProtocolType(MgmtProtocolType.OMA_DM);
+ DAOFactory.getSclDAO().create(nscl);
+ LOGGER.info("NSCL is successfully registred on GSCL");
}
}.start();
}
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SclController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SclController.java
index 589b2ce0..ddeff3ab 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SclController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SclController.java
@@ -111,24 +111,6 @@ public class SclController extends Controller {
}
// Check the Id uniqueness
if (DAOFactory.getSclDAO().find(requestIndication.getTargetID()+"/"+scl.getSclId()) != null) {
- // Register NSCL to G/Dscl
- if ("NSCL".equalsIgnoreCase(Constants.SCL_TYPE)) {
- LOGGER.info("Register NSCL to GSCL");
-
- final String sclLink = scl.getLink();
- final String sclPoc = scl.getPocs().getReference().get(0);
- new Thread() {
- public void run() {
- ResponseConfirm responseConfirm = register(sclLink,sclPoc);
- if (responseConfirm.getStatusCode().equals(StatusCode.STATUS_CREATED)) {
- LOGGER.info("NSCL successfully registered to GSCL");
- }
- if (responseConfirm.getStatusCode().equals(StatusCode.STATUS_CONFLICT)) {
- LOGGER.info("NSCL is already registered to GSCL");
- }
- }
- }.start();
- }
return new ResponseConfirm(new ErrorInfo(StatusCode.STATUS_CONFLICT,"SclId Conflit")) ;
}
// Check ExpirationTime
@@ -241,25 +223,6 @@ public class SclController extends Controller {
// Store scl
DAOFactory.getSclDAO().create(scl);
- // Register NSCL to G/Dscl
- if ("NSCL".equalsIgnoreCase(Constants.SCL_TYPE)) {
- LOGGER.info("Register NSCL to GSCL");
-
- final String sclLink = scl.getLink();
- final String sclPoc = scl.getPocs().getReference().get(0);
- new Thread() {
- public void run() {
- ResponseConfirm responseConfirm = register(sclLink,sclPoc);
- if (responseConfirm.getStatusCode().equals(StatusCode.STATUS_CREATED)) {
- LOGGER.info("NSCL successfully registered to GSCL");
- }
- if (responseConfirm.getStatusCode().equals(StatusCode.STATUS_CONFLICT)) {
- LOGGER.info("NSCL is already registered to GSCL");
- }
- }
- }.start();
-
- }
// Response
return new ResponseConfirm(StatusCode.STATUS_CREATED, scl);
}
@@ -532,38 +495,4 @@ public class SclController extends Controller {
return new ResponseConfirm(new ErrorInfo(StatusCode.STATUS_NOT_IMPLEMENTED,requestIndication.getMethod()+" Method is not implemented")) ;
}
- /**
- * NSCL registration
- * @param sclLink
- * @param sclPoc
- * @return The generic returned response.
- */
- public static ResponseConfirm register(String sclLink, String sclPoc) {
-
- Scl nscl = new Scl();
- nscl.setSclId(Constants.SCL_ID);
- AnyURIList pocs = new AnyURIList();
- pocs.getReference().add(Constants.SCL_DEFAULT_PROTOCOL+"://"+Constants.SCL_IP+":"+Constants.SCL_PORT+Constants.CONTEXT);
- nscl.setPocs(pocs);
- nscl.setLink(Constants.SCL_ID);
- nscl.setMgmtProtocolType(MgmtProtocolType.OMA_DM);
- // Construct the XMLString from the Object
- String nsclRep = XmlMapper.getInstance().objectToXml(nscl);
- // targetID (e.g. om2mGscl/scls)
- String targetID = new String(sclLink+"/scls");
- String base = sclPoc+"/";
-
- RequestIndication requestIndication= new RequestIndication();
- requestIndication.setBase(base);
- requestIndication.setTargetID(targetID);
- requestIndication.setMethod(Constants.AR_CREATE);
- requestIndication.setRequestingEntity(Constants.ADMIN_REQUESTING_ENTITY);
- requestIndication.setRepresentation(nsclRep);
- requestIndication.setProtocol("http");
- LOGGER.info("Sending GSCL registration to NSCL");
- // Response
- return new RestClient().sendRequest(requestIndication);
- }
-
-
}

Back to the top