-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to RequestGetTopicName and PIPWebSocketLampStatus
- Now handle both RequestGetTopicUuid and RequestGetTopicName - A PIPWebSocket can be implemented to retrieve either a specific topicUuid (through the method performRequestGetTopicUuid()), or a list of topicUuid by using the performRequestGetTopicName() method implemented by the AbstractPIPWebSocket - The topicUuid can be null: a PIP invoking the performRequestGetTopicName() method only does not the topicUuid to be specified - The DHTPersistentMessageClient accepts parsable Persistent messages, as well as Response2RequestGetTopicName messages and Response2RequestGetTopicUuid messages. - PIPWebSocketLampStatus implements a PIP that retrieves the status of a specific lamp (specified by the topicUuid)
- Loading branch information
Showing
12 changed files
with
307 additions
and
63 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
PIPWebSocket/src/main/java/it/cnr/iit/ucs/pipwebsocket/PIPWebSocketLampStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package it.cnr.iit.ucs.pipwebsocket; | ||
|
||
import com.google.gson.GsonBuilder; | ||
import it.cnr.iit.ucs.exceptions.PIPException; | ||
import it.cnr.iit.ucs.obligationmanager.ObligationInterface; | ||
import it.cnr.iit.ucs.pip.AbstractPIPWebSocket; | ||
import it.cnr.iit.ucs.pipwebsocket.json.DomoLight; | ||
import it.cnr.iit.ucs.pipwebsocket.json.DomoLightRequestPostTopicUuid; | ||
import it.cnr.iit.ucs.properties.components.PipProperties; | ||
import it.cnr.iit.utility.dht.jsonpersistent.JsonInResponse2RequestGetTopicUuid; | ||
import it.cnr.iit.utility.errorhandling.Reject; | ||
import it.cnr.iit.xacml.Attribute; | ||
import oasis.names.tc.xacml.core.schema.wd_17.RequestType; | ||
|
||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
public class PIPWebSocketLampStatus extends AbstractPIPWebSocket { | ||
|
||
private static final Logger log = Logger.getLogger(PIPWebSocketLamps.class.getName()); | ||
|
||
public PIPWebSocketLampStatus(PipProperties properties) { | ||
super(properties); | ||
setClassForTypeFactory(DomoLightRequestPostTopicUuid.class); | ||
Reject.ifFalse(init(properties), "Error initialising pip : " + properties.getId()); | ||
} | ||
|
||
@Override | ||
public String retrieve(Attribute attribute) throws PIPException { | ||
String response = performRequestGetTopicUuid(); | ||
|
||
JsonInResponse2RequestGetTopicUuid jsonInResponse = new GsonBuilder() | ||
.registerTypeAdapterFactory(getTypeFactory()) | ||
.create() | ||
.fromJson(response, JsonInResponse2RequestGetTopicUuid.class); | ||
|
||
DomoLight domoLight = | ||
((DomoLightRequestPostTopicUuid) jsonInResponse.getResponse().getValue()).getValue(); | ||
|
||
String value; | ||
if (domoLight.isStatus()) { | ||
value = "true"; | ||
} else { | ||
value = "false"; | ||
} | ||
|
||
// attribute value must always be set after it has been retrieved | ||
attribute.setValue(attribute.getDataType(), value); | ||
return value; | ||
} | ||
|
||
@Override | ||
protected Logger getLogger() { | ||
return log; | ||
} | ||
|
||
|
||
@Override | ||
public void retrieve(RequestType request, List<Attribute> attributeRetrievals) { | ||
|
||
} | ||
|
||
@Override | ||
public void subscribe(RequestType request, List<Attribute> attributeRetrieval) { | ||
|
||
} | ||
|
||
@Override | ||
public void update(String json) throws PIPException { | ||
|
||
} | ||
|
||
@Override | ||
public void performObligation(ObligationInterface obligation) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.