</parent>
<artifactId>commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
<name>Common Components</name>
<description>Common components for all modules</description>
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
+ http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<tx:annotation-driven transaction-manager="transactionManager"/>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
- http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
+ http://www.springframework.org/schema/data/jpa
+ http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
+ http://www.springframework.org/schema/tx
+ http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<tx:annotation-driven transaction-manager="transactionManager" />
import org.I0Itec.zkclient.ZkConnection;
import org.apache.log4j.Logger;
import org.iotivity.cloud.mqserver.Constants;
+import org.iotivity.cloud.mqserver.kafka.KafkaCommonWrapper;
import org.iotivity.cloud.mqserver.topic.Topic;
-
import kafka.admin.AdminUtils;
import kafka.api.FetchRequest;
import kafka.api.FetchRequestBuilder;
}
private void createTopic() {
-// KafkaCommonWrapper kafkaCommonWrapper = new KafkaCommonWrapper(mZookeeper, mBroker);
-// if (kafkaCommonWrapper.createTopic(mTopicName)) {
-// getMessages();
-// }
+ KafkaCommonWrapper kafkaCommonWrapper = new KafkaCommonWrapper(mZookeeper, mBroker);
+ if (kafkaCommonWrapper.createTopic(mTopicName)) {
+ getMessages();
+ }
}
private Properties buildPropertiesForSubscribe() {
import com.samsung.commons.domain.Device;
import com.samsung.commons.domain.User;
+import com.samsung.commons.service.AgentService;
import com.samsung.commons.service.DeviceService;
import com.samsung.commons.service.IotCloudService;
import org.apache.log4j.Logger;
DeviceService deviceService;
@Autowired
+ AgentService agentService;
+
+ @Autowired
IotCloudService iotCloudService;
@Override
log.debug("New device with params : did = " + did + ", uid = " + uid + ", device type = " + name + ", model = " + model + ", route = " + route);
User user = iotCloudService.findAssociatedUserByUuid(uid);
Device device = deviceService.init(did, name, type, model, 1, user, route);
+ //TODO: remove or update after Agent functionality implementation
+ //FIXME: test Agent registration for all new devices
+ String testAgentUuid = did + name.hashCode();
+ String testAgentName = "Test Agent";
+ agentService.init(testAgentUuid, testAgentName, device);
log.info(" Registered device: " + device);
} catch (Exception e) {
log.error(e.getMessage(), e);
Policy policy = policyService.findByDeviceId(device.getId());
policyService.remove(policy);
deviceService.remove(device);
- log.info("Unregistered device: " + device);
+ log.info("Unregistered device with id: " + did);
}
if(action.equalsIgnoreCase(MessageQueueKeys.DELETE.getKey())){
device.setRemoved(true);
log.info("Device mark like removed: " + device);
}
}
+ log.info("Unregistered device with id = " + did);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
private static final String NOTIFICATION_MESSAGE = "message";
private static final String NOTIFICATION_TITLE = "title";
private static final String NOTIFICATION_CODE = "code";
+ private static final String NOTIFICATION_TYPE = "type";
private static final String POLICY = "policy";
private static final String DUID = "duid";
private static final String AGENT = "agent";
return new ResponseEntity<>(BAD_REQUEST);
}
Map<String, String> map = notification.getAdditionalMap();
- map.put(NOTIFICATION_CODE, notification.getCode());
+ map.put(NOTIFICATION_TYPE, notification.getCode());
map.put(NOTIFICATION_TITLE, notification.getTitle());
map.put(NOTIFICATION_MESSAGE, notification.getMessage());
map.put(NOTIFICATION_TIME, Long.toString(notification.getCurrentTime()));
@Override
public boolean requestPolicyForAgent(Long policyId, String agentId) {
try {
- log.info(format("Send request for policy %s", policyId));
+ log.debug(format("Send request for policy %s", policyId));
URI url = new URI(host + REST_FOR_REQUEST_POLICY + policyId + "/agent/" + agentId);
- log.info("Send to " + url);
+ log.debug("Send to " + url);
@SuppressWarnings("rawtypes")
ResponseEntity result = restTemplate.exchange(url, POST, null, ResponseEntity.class);
- log.info("Response " + result);
+ log.debug("Response " + result);
return result.getStatusCode() == OK;
} catch (URISyntaxException e) {
log.error(e.getMessage(), e);
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.3.xsd">
+
<!-- <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="autodetect" value="true"/>
<entry key="Listener:name=unreg" value-ref="deviceUnRegListener" />
</map>
</property>
- </bean> -->
+ </bean> -->
<bean id="reportExtractor"
class="com.samsung.servermq.iotivity.extractor.impl.ReportPostDataExtractor" />
<task:scheduled-tasks scheduler="listenerScheduler">
<task:scheduled ref="reportListener" method="getMessages"
fixed-delay="${iotivity.listener_delay}" />
- <task:scheduled ref="policytListener" method="getMessages"
+ <task:scheduled ref="policyListener" method="getMessages"
fixed-delay="${iotivity.listener_delay}" />
<task:scheduled ref="deviceRegListener" method="getMessages"
fixed-delay="${iotivity.listener_delay}" />
<constructor-arg name="listenerName" value="Report Listener" />
</bean>
- <bean id="policytListener" class="com.samsung.servermq.iotivity.MessageQueueListener">
+ <bean id="policyListener" class="com.samsung.servermq.iotivity.MessageQueueListener">
<constructor-arg name="zookeperHost"
value="${iotivity.zookeper_host}" />
<constructor-arg name="kafkaHost" value="${iotivity.kafka_host}" />
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:jpa="http://www.springframework.org/schema/data/jpa"
+ xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.hbm2ddl.import_files">${hibernate.hbm2ddl.import_files}</prop>
- <prop key="hibernate.temp.use_jdbc_metadata_defaults">${hibernate.temp.use_jdbc_metadata_defaults}
- </prop>
+ <prop key="hibernate.temp.use_jdbc_metadata_defaults">${hibernate.temp.use_jdbc_metadata_defaults}</prop>
</props>
</property>
</bean>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:task="http://www.springframework.org/schema/task"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
- http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd">
+ http://www.springframework.org/schema/task
+ http://www.springframework.org/schema/task/spring-task-4.3.xsd">
<bean id="reportExtractor"
class="com.samsung.servermq.iotivity.extractor.impl.ReportPostDataExtractor" />
<!-- <task:scheduled-tasks scheduler="listenerScheduler">
<task:scheduled ref="reportListener" method="getMessages"
fixed-delay="5000" />
- <task:scheduled ref="policytListener" method="getMessages"
+ <task:scheduled ref="policyListener" method="getMessages"
fixed-delay="5000" />
<task:scheduled ref="deviceRegListener" method="getMessages"
fixed-delay="5000" />
<constructor-arg name="listenerName" value="Report Listener" />
</bean>
- <bean id="policytListener" class="com.samsung.servermq.iotivity.MessageQueueListener">
+ <bean id="policyListener" class="com.samsung.servermq.iotivity.MessageQueueListener">
<constructor-arg name="zookeperHost" value="106.125.46.44:2181" />
<constructor-arg name="kafkaHost" value="106.125.46.44:9092" />
<constructor-arg name="topicName" value="/oic/ps/srv/policy" />
<root level="error">
<appender-ref ref="STDOUT" />
</root>
- <jmxConfigurator />
</configuration>
\ No newline at end of file
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
- http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
+ http://www.springframework.org/schema/data/jpa
+ http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
+ http://www.springframework.org/schema/tx
+ http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<tx:annotation-driven transaction-manager="transactionManager" />