diff --git a/so-devicecontrol/conf/logback-dc.xml b/so-devicecontrol/conf/logback-dc.xml deleted file mode 100644 index 3d530d7d..00000000 --- a/so-devicecontrol/conf/logback-dc.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-if-db/conf/logback-if-db.xml b/so-if-db/conf/logback-if-db.xml deleted file mode 100644 index 4fb7b91c..00000000 --- a/so-if-db/conf/logback-if-db.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/AspectController.java b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/AspectController.java deleted file mode 100644 index 9811e2d5..00000000 --- a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/AspectController.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.pineone.icbms.so.interfaces.database.controller;//package com.pineone.icbms.so.interfaces.database.controller; -// -//import com.pineone.icbms.so.interfaces.database.controller.inputdata.AspectData; -//import com.pineone.icbms.so.interfaces.database.logic.itf.IAspectDAO; -//import com.pineone.icbms.so.interfaces.database.model.AspectForDB; -//import com.pineone.icbms.so.interfaces.database.ref.DataLossException; -//import com.pineone.icbms.so.interfaces.database.ref.DataValidation; -//import com.pineone.icbms.so.interfaces.database.ref.ResponseMessage; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Controller; -//import org.springframework.web.bind.annotation.*; -// -//import java.util.List; -// -///** -// * Created by melvin on 2017. 3. 28.. -// */ -// -//// Aspect 관련 controller 기능 구현 -//@Controller -//@RequestMapping(value = "/aspect") -//public class AspectController { -// -// @Autowired -// private IAspectDAO aspectDAO; -// -// @Autowired -// private ResponseMessage responseMessage; -// -// @Autowired -// private DataValidation dataValidation; -// -// // Aspect Id 로 Aspect 내용 조회 -// @RequestMapping(value = "/{id}", method = RequestMethod.GET) -// @ResponseBody -// public AspectForDB retrieveAspect(@PathVariable long id) { -// AspectForDB aspect = aspectDAO.retrieveAspect(id); -// return aspect; -// } -// -// // SO에 등록되어 있는 전체 Aspect 내용 조회 -// @RequestMapping -// @ResponseBody -// public List retrieveAspectList() { -// List aspectList = aspectDAO.retrieveAspectList(); -// return aspectList; -// } -// -// // SO에 Aspect 데이터 등록 -// @RequestMapping(method = RequestMethod.POST) -// @ResponseBody -// public ResponseMessage createAspect(@RequestBody AspectData aspectData) { -// -// try { -// dataValidation.inspectAspectData(aspectData); -// } catch (DataLossException e) { -// responseMessage.setExceptionMessage(e.getMessage()); -// return responseMessage; -// } -// -// String createMessage = aspectDAO.createAspect(aspectData); -// responseMessage.setMessage(createMessage); -// return responseMessage; -// } -// -// // SO의 Aspect Data Update TODO Update 정책 반영필요 -// @RequestMapping(value = "{id}", method = RequestMethod.POST) -// @ResponseBody -// public ResponseMessage updateAspect(@PathVariable long id, @RequestBody AspectData aspectData) { -// -// try { -// dataValidation.inspectAspectData(aspectData); -// } catch (DataLossException e) { -// responseMessage.setExceptionMessage(e.getMessage()); -// return responseMessage; -// } -// -// String updateMessage = aspectDAO.updateAspect(id, aspectData); -// responseMessage.setMessage(updateMessage); -// return responseMessage; -// } -// -// // SO의 virtualObject Date Delete -// @RequestMapping(value = "/delete/{id}") -// @ResponseBody -// public ResponseMessage deleteAspect(@PathVariable long id) { -// String deleteMessage = aspectDAO.deleteAspect(id); -// responseMessage.setMessage(deleteMessage); -// return responseMessage; -// } -//} diff --git a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/CompositeVirtualObjectController.java b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/CompositeVirtualObjectController.java deleted file mode 100644 index 2d7c7b2a..00000000 --- a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/CompositeVirtualObjectController.java +++ /dev/null @@ -1,40 +0,0 @@ -//package com.pineone.icbms.so.interfaces.database.controller; -// -//import com.pineone.icbms.so.interfaces.database.controller.inputdata.CompositeVirtualObjectData; -//import com.pineone.icbms.so.interfaces.database.controller.inputdata.VirtualObjectData; -//import com.pineone.icbms.so.interfaces.database.logic.itf.ICompositeVirtualObjectDAO; -//import com.pineone.icbms.so.interfaces.database.ref.DataLossException; -//import com.pineone.icbms.so.interfaces.database.ref.DataValidation; -//import com.pineone.icbms.so.interfaces.database.ref.ResponseMessage; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Controller; -//import org.springframework.web.bind.annotation.*; -// -///** -// * Created by melvin on 2017. 4. 10.. -// */ -// -// -//@Controller -//@RequestMapping(value = "/cvo") -//public class CompositeVirtualObjectController { -// -// @Autowired -// private ICompositeVirtualObjectDAO compositeVirtualObjectDAO; -// -// @Autowired -// private ResponseMessage responseMessage; -// -// @Autowired -// private DataValidation dataValidation; -// -// @RequestMapping(value = "{id}", method = RequestMethod.POST) -// @ResponseBody -// public ResponseMessage updateVirtualObject(@PathVariable String id, @RequestBody CompositeVirtualObjectData compositeVirtualObjectData){ -// -// String updateMessage = (compositeVirtualObjectDAO.updateCompositeVirtualObject(id, compositeVirtualObjectData)).toString(); -// responseMessage.setMessage(updateMessage); -// return responseMessage; -// } -// -//} diff --git a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/VirtualObjectController.java b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/VirtualObjectController.java deleted file mode 100644 index 15bee2ec..00000000 --- a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/controller/VirtualObjectController.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.pineone.icbms.so.interfaces.database.controller;//package com.pineone.icbms.so.interfaces.database.controller; -// -//import com.pineone.icbms.so.interfaces.database.logic.itf.IVirtualObjectDAO; -//import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; -//import com.pineone.icbms.so.interfaces.database.ref.DataLossException; -//import com.pineone.icbms.so.interfaces.database.ref.DataValidation; -//import com.pineone.icbms.so.interfaces.database.ref.ResponseMessage; -//import com.pineone.icbms.so.interfaces.database.controller.inputdata.VirtualObjectData; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Controller; -//import org.springframework.web.bind.annotation.*; -// -//import java.util.List; -// -///** -// * Created by melvin on 2017. 3. 27.. -// */ -// -//// VirtualObject 관련 controller 기능 구현 -//@Controller -//@RequestMapping(value = "/virtualobject") -//public class VirtualObjectController { -// -// @Autowired -// private IVirtualObjectDAO virtualObjectDAO; -// -// @Autowired -// private ResponseMessage responseMessage; -// -// @Autowired -// private DataValidation dataValidation; -// -// // VirtualObject Id 로 VirtualObject 조회 -// @RequestMapping(value = "/{id}" , method = RequestMethod.GET) -// @ResponseBody -// public VirtualObjectForDB retrieveVirtualObject(@PathVariable long id){ -// VirtualObjectForDB virtualObject = virtualObjectDAO.retrieveVirtualObject(id); -// return virtualObject; -// } -// -// // SO에 등록되어 있는 전체 VirtualObject 내용 조회 -// @RequestMapping -// @ResponseBody -// public List retrieveVirtualObjectList(){ -// List virtualObjectList = virtualObjectDAO.retrieveVirtualObjectList(); -// return virtualObjectList; -// } -// -// // SO에 Virtual Object 데이터 등록 -// @RequestMapping(method = RequestMethod.POST) -// @ResponseBody -// public ResponseMessage createVirtualObject(@RequestBody VirtualObjectData virtualObjectData){ -// -// try{ -// dataValidation.inspectVirtualObjectData(virtualObjectData); -// } catch (DataLossException e) { -// responseMessage.setExceptionMessage(e.getMessage()); -// return responseMessage; -// } -// -// String createMessage = virtualObjectDAO.createVirtualObject(virtualObjectData); -// responseMessage.setMessage(createMessage); -// return responseMessage; -// } -// -// // SO의 virtualObject Data Update 정책 반영필요 -// @RequestMapping(value = "{id}", method = RequestMethod.POST) -// @ResponseBody -// public ResponseMessage updateVirtualObject(@PathVariable long id, @RequestBody VirtualObjectData virtualObjectData){ -// -// try{ -// dataValidation.inspectVirtualObjectData(virtualObjectData); -// } catch (DataLossException e) { -// responseMessage.setExceptionMessage(e.getMessage()); -// return responseMessage; -// } -// -// String updateMessage = virtualObjectDAO.updateVirtualObject(id, virtualObjectData); -// responseMessage.setMessage(updateMessage); -// return responseMessage; -// } -// -// // SO의 virtualObject Date Delete -// @RequestMapping(value = "/delete/{id}") -// @ResponseBody -// public ResponseMessage deleteVirtualObject(@PathVariable long id){ -// String deleteMessage = virtualObjectDAO.deleteVirtualObject(id); -// responseMessage.setMessage(deleteMessage); -// return responseMessage; -// } -//} diff --git a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/dao/VirtualObjectDao.java b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/dao/VirtualObjectDao.java index 9bafeacc..89f8c06e 100644 --- a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/dao/VirtualObjectDao.java +++ b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/dao/VirtualObjectDao.java @@ -1,8 +1,8 @@ package com.pineone.icbms.so.interfaces.database.dao; +import com.pineone.icbms.so.interfaces.database.model.MeasuringVoForDB; import com.pineone.icbms.so.interfaces.database.model.RuleItemForDB; import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; -import com.pineone.icbms.so.util.id.IdUtils; import org.springframework.stereotype.Component; import java.util.HashMap; @@ -87,6 +87,11 @@ public List retrieve() { return super.sqlSession.selectList("retrieveVirtualObjectByModel"); } + // retrieve list of Measuring Vo + public List getMeasuringVoList(String osId) { + return super.sqlSession.selectList("retrieveMeasuringRuleVirtualObjectListByOsId", osId); + } + // Aspect 저장 기능 구현 public VirtualObjectForDB create(VirtualObjectForDB model) { //String sessionId = IdUtils.createRandomUUID(); diff --git a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/model/MeasuringVoForDB.java b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/model/MeasuringVoForDB.java new file mode 100644 index 00000000..874915ee --- /dev/null +++ b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/model/MeasuringVoForDB.java @@ -0,0 +1,61 @@ +package com.pineone.icbms.so.interfaces.database.model; + +import lombok.*; + +@ToString +public class MeasuringVoForDB{ + + // rule_body + @Getter @Setter + private String id; //rule_body.id + + @Getter @Setter + private String cvoType; + + @Getter @Setter + private String baseCvoId; //rule_body.base_cvo_id + + @Getter @Setter + private String osId; + + @Getter @Setter + private String physicalDeviceTypeId; + + //@Getter @Setter + //private String physicalDeviceTypeUri; //physical_device_type.physical_device_type_uri + + @Getter @Setter + private String deviceId; // == deviceUri + + @Getter @Setter + private String locationId; //rule_body + + @Getter @Setter + private String locationUri; // location.uri + + // rule_item + @Getter @Setter + private String itemId; // rule_item.id + + @Getter @Setter + private String ruleBodyId; // rule_item.rule_body_id + + @Getter @Setter + private String voId; // rule_item.vo_id + + @Getter @Setter + private String aspectUri; // virtual_object.aspect_uri + + @Getter @Setter + private String functionalityId; //rule_item.funtionality_id + + @Getter @Setter + private String functionalityUri; //functionality.uri + + @Getter @Setter + private String voValueType; // rule_item.vo_value_type + + @Getter @Setter + private String voValue; // rule_item.vo_value + +} diff --git a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/model/RuleItemForDB.java b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/model/RuleItemForDB.java index 2adc9edb..67ab9745 100644 --- a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/model/RuleItemForDB.java +++ b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/model/RuleItemForDB.java @@ -18,10 +18,10 @@ public class RuleItemForDB { private String aspectUri; @Getter @Setter - private String funtionalityId; // rule_item.funtionality_id + private String functionalityId; // rule_item.funtionality_id @Getter @Setter - private String funtionalityUri; + private String functionalityUri; @Getter @Setter private String voValueType; // rule_item.vo_value_type diff --git a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/service/DataBaseStore.java b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/service/DataBaseStore.java index 4f93f72d..a6868d3f 100644 --- a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/service/DataBaseStore.java +++ b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/service/DataBaseStore.java @@ -82,8 +82,6 @@ public List getCompositeVirtualObjectListByOrchestr List compositeVirtualObjectForDBList = compositeVirtualObjectDao.retrieveCompositeVirtualObjectListByOrchestrationId(orchestrationServiceId); - List virtualObjectForDBList = null; - for(CompositeVirtualObjectForDB compositeVirtualObjectForDB : compositeVirtualObjectForDBList){ compositeVirtualObjectForDB.setVirtualObjectForDBList( getVirtualObjectListByCompositeVirtualObjectId(compositeVirtualObjectForDB.getId()) @@ -106,7 +104,17 @@ public List getRuleBodyListByOsId(String osId){ public CompositeVirtualObjectForDB getCvoById(String id) { return compositeVirtualObjectDao.retrieve(id); } - + + // retrieve list of Measuring Vo + @Override + public List getMeasuringVoList(String osId){ + log.debug("getMeasuringVoList : osId {}", osId); + + List RuleBodyForDBList = virtualObjectDao.getMeasuringVoList(osId); + + return RuleBodyForDBList; + } + /* * cvo Id로 부터 vo목록을 가져온다 */ diff --git a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/service/IDataBaseStore.java b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/service/IDataBaseStore.java index 1535c20d..2df6051b 100644 --- a/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/service/IDataBaseStore.java +++ b/so-if-db/src/main/java/com/pineone/icbms/so/interfaces/database/service/IDataBaseStore.java @@ -54,4 +54,6 @@ public interface IDataBaseStore { List retrieveDeviceType(); DeviceTypeForDB retrieveDeviceTypeById(String id); + + List getMeasuringVoList(String osId); } diff --git a/so-if-db/src/main/resources/META-INF/mappers/virtualObjectMapper.xml b/so-if-db/src/main/resources/META-INF/mappers/virtualObjectMapper.xml index cd8bc34a..93b86cdd 100644 --- a/so-if-db/src/main/resources/META-INF/mappers/virtualObjectMapper.xml +++ b/so-if-db/src/main/resources/META-INF/mappers/virtualObjectMapper.xml @@ -89,16 +89,39 @@ SELECT ri.*, vo.aspect_uri, - f.uri funtionalityUri + f.uri functionalityUri FROM rule_item ri LEFT JOIN virtual_object vo ON vo.id = ri.vo_id - LEFT JOIN functionality f ON f.id = ri.funtionality_id + LEFT JOIN functionality f ON f.id = ri.functionality_id WHERE ri.rule_body_id = #{value} + + + SELECT rbc.*, ri.* FROM rule_body rbp + LEFT JOIN noncvo nc ON rbp.base_cvo_id = nc.noncvo_id AND nc.os_id = rbp.os_id + LEFT JOIN rule_body rbc ON rbc.id = nc.rule_body_id + LEFT JOIN rule_item ri ON ri.rule_body_id = nc.rule_body_id + WHERE + rbp.os_id = #{osId} + AND rbp.cvo_type = "CVO_TYPE_NONEDEVICE" + AND ri.functionality_id = "FUNCTIONALITY_TYPE_MEASURING" + + union all + + SELECT rb.*, ri.* FROM rule_body rb + LEFT JOIN rule_item ri ON ri.rule_body_id = rb.id + WHERE + rb.os_id = #{osId} + AND rb.cvo_type != "CVO_TYPE_NONEDEVICE" + AND ri.functionality_id = "FUNCTIONALITY_TYPE_MEASURING" + + + + SELECT V.id diff --git a/so-if-db/src/test/java/com/pineone/icbms/so/interfaces/database/service/IProfileMapperTest.java b/so-if-db/src/test/java/com/pineone/icbms/so/interfaces/database/service/IProfileMapperTest.java index 1bef9c04..9f4fbe8e 100644 --- a/so-if-db/src/test/java/com/pineone/icbms/so/interfaces/database/service/IProfileMapperTest.java +++ b/so-if-db/src/test/java/com/pineone/icbms/so/interfaces/database/service/IProfileMapperTest.java @@ -1,30 +1,30 @@ -package com.pineone.icbms.so.interfaces.database.service; - -import com.pineone.icbms.so.interfaces.database.dao.ProfileDao; -import com.pineone.icbms.so.interfaces.database.model.ProfileForDB; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * Created by jonghee on 2017-06-15. - * test/resource - */ -@RunWith(SpringRunner.class) -@SpringBootTest -@MapperScan(value = {"com.pineone.icbms.so.interfaces.database.service"}) -public class IProfileMapperTest { - - @Autowired - ProfileDao dao; - - @Test - public void createTracking() throws Exception { - ProfileForDB profile = dao.retrieveProfile("PR-810fc6d0-1e08-4875-adc5-5c4adce00e33"); - System.out.println("조회결과 : " + profile.getId()); - } - +package com.pineone.icbms.so.interfaces.database.service; + +import com.pineone.icbms.so.interfaces.database.dao.ProfileDao; +import com.pineone.icbms.so.interfaces.database.model.ProfileForDB; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Created by jonghee on 2017-06-15. + * test/resource + */ +@RunWith(SpringRunner.class) +@SpringBootTest +@MapperScan(value = {"com.pineone.icbms.so.interfaces.database.service"}) +public class IProfileMapperTest { + + @Autowired + ProfileDao dao; + + @Test + public void createTracking() throws Exception { + ProfileForDB profile = dao.retrieveProfile("PR-810fc6d0-1e08-4875-adc5-5c4adce00e33"); + //System.out.println("조회결과 : " + profile.getId()); + } + } \ No newline at end of file diff --git a/so-if-mq/src/main/resources/application.properties b/so-if-mq/src/main/resources/application.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/so-if-mq/src/test/java/com/pineone/icbms/so/interfaces/messagequeue/SoIfMqApplicationTests.java b/so-if-mq/src/test/java/com/pineone/icbms/so/interfaces/messagequeue/SoIfMqApplicationTests.java deleted file mode 100644 index 6f7ffd00..00000000 --- a/so-if-mq/src/test/java/com/pineone/icbms/so/interfaces/messagequeue/SoIfMqApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.pineone.icbms.so.interfaces.messagequeue; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class SoIfMqApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/so-if-sda/conf/logback-if-sda.xml b/so-if-sda/conf/logback-if-sda.xml deleted file mode 100644 index 8324f033..00000000 --- a/so-if-sda/conf/logback-if-sda.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaClient.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaClient.java deleted file mode 100644 index 82811119..00000000 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaClient.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.pineone.icbms.so.interfaces.sda.handle; - -import com.pineone.icbms.so.devicecontrol.model.virtualdevice.DeviceControlValue; -import com.pineone.icbms.so.virtualobject.aspect.IGenericAspect; -import com.pineone.icbms.so.virtualobject.function.IGenericFunction; -import com.pineone.icbms.so.virtualobject.operation.IGenericOperation; -import com.pineone.icbms.so.virtualobject.unit.IGenericUnit; -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; - -import java.util.List; - -/** - * SDA system interface implements. - * - * Created by uni4love on 2017. 1. 23. - */ -public class SdaClient { - /** - * retreive function list. - * - * @param locationUri location uri - * @return function list - */ - public List retreiveFunctionlaityListByLocation(String locationUri) { - //implements.. - return null; - } - - /** - * retreive aspect. - * - * @param functionUri function uri - * @return aspect - */ - public IGenericAspect retreiveAspectByFunction(String functionUri) { - //implements.. - return null; - } - - /** - * retreive unit. - * - * @param aspectUri aspect uri - * @return unit - */ - public IGenericUnit retreiveUnit(String aspectUri) { - //implements.. - return null; - } - - /** - * retreive devicemapper list. - * - * @param functionUri function uri - * @param locationUri location uri - * @return devicemapper list - */ - public List retreiveDeviceList(String functionUri, String locationUri) { - //implements.. - return null; - } - - /** - * retreive operation list. - * - * @param deviceUri devicemapper uri - * @return operation list - */ - public List retreiveOperationList(String deviceUri) { - //implements.. - return null; - } - - /** - * retreive control values. - * - * @param functionUri function - * @param aspect aspect - * @param locationUri location uri - * @param deviceUri device uri - * @return List - */ - public List retreiveDeviceControlValues(String functionUri, String aspect, String locationUri, String deviceUri) { - return null; - } -} diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaManager.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaManager.java index 09475d49..ccf3a025 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaManager.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaManager.java @@ -6,9 +6,8 @@ import com.pineone.icbms.so.interfaces.sda.ref.DataNotExistException; import com.pineone.icbms.so.interfaces.sda.ref.SDAException; import com.pineone.icbms.so.interfaces.sda.ref.SdaAddressStore; -import com.pineone.icbms.so.util.http.ClientService; +import com.pineone.icbms.so.util.http.ClientServiceNoTimeout; import com.pineone.icbms.so.util.itf.address.AddressCollector; -import com.withwiz.beach.network.http.message.IHttpResponseMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -34,11 +33,12 @@ public class SdaManager implements ISdaManager { */ protected Logger log = LoggerFactory.getLogger(getClass()); - ClientService clientService = new ClientService(); + //ClientService clientService = new ClientService(); + ClientServiceNoTimeout clientServiceNoTimeout = new ClientServiceNoTimeout(); AddressCollector addressCollector = new AddressCollector(); ObjectMapper objectMapper = new ObjectMapper(); - // 상황의 발생 여부 조회 + // 상황의 발생 여부 조회 (발생 위치 리턴) - 미사용 @Override public List retrieveEventLocationList(String contextModelId) { // @@ -47,7 +47,7 @@ public List retrieveEventLocationList(String contextModelId) { try { //IHttpResponseMessage message = clientService.requestGetService( - String message = clientService.requestGetServiceReceiveString2( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + contextModelId + SdaAddressStore.SEPARATOR_WITH_COMMA); contentList = getContextModelContents(message); } catch (IOException e) { @@ -68,7 +68,7 @@ public List retrieveEventLocationList(String contextModelId) { return locationList; } - // 상황의 발생 여부 조회 + // 상황의 발생 여부 조회 (발생 정보 리턴 - location, Id, Mac) @Override public List retrieveEventList(String contextModelId) { @@ -76,7 +76,7 @@ public List retrieveEventList(String contextModelId) { try { //IHttpResponseMessage message = clientService.requestGetService( - String message = clientService.requestGetServiceReceiveString2( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + contextModelId + SdaAddressStore.SEPARATOR_WITH_COMMA); contentList = getContextModelContents(message); } catch (IOException e) { @@ -92,7 +92,8 @@ public List retrieveEventList(String contextModelId) { return contentList; } - + +/* // 특정 위치(location)에 존재하는 device Function 목록 조회 @Override public List retrieveFunctionListInLocation(String locationId) { @@ -317,69 +318,13 @@ public List retrieveListByContextModelId(String contextModelId) { return resultList; } +*/ - @Override - public List retrieveAspectList() { - // - List list = new ArrayList(); - List contentList = new ArrayList<>(); - - try { - IHttpResponseMessage message = clientService.requestGetService( - addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + - SdaAddressStore.CM_ASPECT_LIST + SdaAddressStore.SEPARATOR_WITH_COMMA); - contentList = getContextModelContents(message); - } catch (IOException e) { - e.printStackTrace(); - } catch (SDAException e) { -// e.printStackTrace(); - } - - for (ContextModelContent contextModelContent : contentList) { - AspectForIf addItam = new AspectForIf(); - addItam.setAspect(contextModelContent.getAspectUri()); - addItam.setLabel(contextModelContent.getLabel()); - list.add(addItam); - } - log.debug("Aspect : " + list); - return list; - } - - @Override - public List retrieveFunctionList() { - // - List functionList = new ArrayList(); - List contentList = new ArrayList<>(); + //public static final String CM_DD_DEVICE_LIST = "cm-dd-device-list"; //1) by location, aspect, functionality + //public static final String CM_DD_DEVICETYPE_LIST = "cm-dd-devicetype-device-list"; //2) by location, deviceType, aspect, functionality + //public static final String CM_DD_COMMAND_VALUE = "cm-dd-command-value"; //3) by id, aspect, cmd + //public static final String CM_DD_ASPECT_ACTION_VALUE = "cm-dd-aspect-action-value"; //4) by id, aspect, functionality - try { - IHttpResponseMessage message = clientService.requestGetService( - addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + - SdaAddressStore.CM_FUNCTION_LIST + SdaAddressStore.SEPARATOR_WITH_COMMA); - contentList = getContextModelContents(message); - } catch (IOException e) { - e.printStackTrace(); - } catch (SDAException e) { -// e.printStackTrace(); - } - - for (ContextModelContent contextModelContent : contentList) { - FunctionForIf addItam = new FunctionForIf(); - addItam.setFunction(contextModelContent.getFunctionUri()); - addItam.setLabel(contextModelContent.getLabel()); - functionList.add(addItam); - - } - log.debug("Function : " + functionList); - return functionList; - } - - - /* - public static final String CM_DD_DEVICE_LIST = "cm-dd-device-list"; //1) by location, aspect, functionality - public static final String CM_DD_DEVICETYPE_LIST = "cm-dd-devicetype-device-list"; //2) by location, deviceType, aspect, functionality - public static final String CM_DD_COMMAND_VALUE = "cm-dd-command-value"; //3) by id, aspect, cmd - public static final String CM_DD_ASPECT_ACTION_VALUE = "cm-dd-aspect-action-value"; //4) by id, aspect, functionality - */ // 1)cm-dd-device-list(Loc,Aspect,Func) 을 이용한 Device 목록 조회 @Override public List getDeviceListByLoc_Aspect_Func(String locationUri, String aspectUri, String functionalityUri) { @@ -388,7 +333,8 @@ public List getDeviceListByLoc_Aspect_Func(String locationUri, String as List contentList = new ArrayList<>(); try { - IHttpResponseMessage message = clientService.requestGetService( + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + SdaAddressStore.CM_DD_DEVICE_LIST + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + locationUri + "," + aspectUri + "," + functionalityUri); @@ -419,7 +365,8 @@ public List getDeviceListByLoc_DeviceType_Aspect_Func(String locationUri List contentList = new ArrayList<>(); try { - IHttpResponseMessage message = clientService.requestGetService( + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + SdaAddressStore.CM_DD_DEVICETYPE_LIST + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + locationUri + "," + deviceType + "," + aspectUri + ","+ functionalityUri); @@ -448,7 +395,8 @@ public String getCommandValueById_Aspect_Command(String deviceId, String aspectU List contentList = new ArrayList<>(); try { - IHttpResponseMessage message = clientService.requestGetService( + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + SdaAddressStore.CM_DD_COMMAND_VALUE + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + deviceId + "," + aspectUri + ","+ command); @@ -478,7 +426,8 @@ public ContextModelContent getAspectValueById_Aspect_Function(String deviceId, S List contentList = new ArrayList<>(); try { - IHttpResponseMessage message = clientService.requestGetService( + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + SdaAddressStore.CM_DD_ASPECT_ACTION_VALUE + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + deviceId + "," + aspectUri + ","+ functionUri); @@ -498,7 +447,102 @@ public ContextModelContent getAspectValueById_Aspect_Function(String deviceId, S return content; } - // get Data + // 5)cm-dd-measuring-loc_dtype_aspect (Loc, Type, Aspect)을 이용한 Measuring + // public static final String CM_DD_MEASURING_BY_LOC_DTYPE_ASPECT = "cm-dd-measuring-loc_dtype_aspect"; //5) by location, deviceType, aspect + @Override + public List getMeasuringValueByLocDeviceTypeAspect(String locationUri, String deviceType, String aspectUri) { + + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_DD_MEASURING_BY_LOC_DTYPE_ASPECT + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + + locationUri + "," + deviceType + "," + aspectUri); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + String info = "getMeasuringValueByLocDeviceTypeAspect::contentList(by " + locationUri + ", " + deviceType + ", " + aspectUri +")="; + if (contentList == null || contentList.isEmpty()) { + log.debug("info : " + info + " is empty"); + } + else { + for (ContextModelContent contextModelContent : contentList) { + log.debug(" - " + contextModelContent.getDeviceName() +"=" + contextModelContent.getValue() ); + } + } + return contentList; + } + + // 6) cm-dd-measuring-loc_aspect (Loc, Aspect)을 이용한 Measuring + // public static final String CM_DD_MEASURING_BY_LOC_ASPECT = "cm-dd-measuring-loc_aspect"; //6) by location, aspect + @Override + public List getMeasuringValueByLocAspect(String locationUri, String aspectUri) { + + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_DD_MEASURING_BY_LOC_ASPECT + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + + locationUri + "," + aspectUri); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + String info = "getMeasuringValueByLocAspect:: contentList(by " + locationUri + ", " + aspectUri +")="; + if (contentList == null || contentList.isEmpty()) { + log.debug("info : " + info + " is empty"); + } + else { + for (ContextModelContent contextModelContent : contentList) { + log.debug(" - " + contextModelContent.getDeviceName() +"=" + contextModelContent.getValue() ); + } + } + return contentList; + } + + // 7) cm-dd-measuring-devid_aspect (devId, Aspect)을 이용한 Measuring + // public static final String CM_DD_MEASURING_BY_DEVID_ASPECT = "cm-dd-measuring-devid_aspect"; //7) by devId, aspect + @Override + public List getMeasuringValueByDevIdAspect(String devUri, String aspectUri) { + + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_DD_MEASURING_BY_DEVID_ASPECT + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + + devUri + "," + aspectUri); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + String info = "getMeasuringValueByDevIdAspect:: contentList(by " + devUri + ", " + aspectUri +")="; + if (contentList == null || contentList.isEmpty()) { + log.debug("info : " + info + " is empty"); + } + else { + for (ContextModelContent contextModelContent : contentList) { + log.debug(" - " + contextModelContent.getDeviceName() +"=" + contextModelContent.getValue() ); + } + } + return contentList; + } + + //================================ +/* + // get Data (old) private List getContextModelContents(IHttpResponseMessage message) throws IOException, DataNotExistException { if (message.getStatusCode() == 200) { // System.out.println(message.getBodyByteArray().toString()); @@ -511,8 +555,8 @@ private List getContextModelContents(IHttpResponseMessage m throw new DataNotExistException(); } } - - // get Data +*/ + // get Data (new) private List getContextModelContents(String message) throws IOException, DataNotExistException { if (message != null) { // System.out.println(message.getBodyByteArray().toString()); @@ -524,4 +568,63 @@ private List getContextModelContents(String message) throws throw new DataNotExistException(); } } + + //================================ + @Override + public List retrieveFunctionList() { + // + List functionList = new ArrayList(); + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_FUNCTION_LIST + SdaAddressStore.SEPARATOR_WITH_COMMA); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + + for (ContextModelContent contextModelContent : contentList) { + FunctionForIf addItam = new FunctionForIf(); + addItam.setFunction(contextModelContent.getFunctionUri()); + addItam.setLabel(contextModelContent.getLabel()); + functionList.add(addItam); + + } + log.debug("Function : " + functionList); + return functionList; + } + + @Override + public List retrieveAspectList() { + // + List list = new ArrayList(); + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_ASPECT_LIST + SdaAddressStore.SEPARATOR_WITH_COMMA); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + + for (ContextModelContent contextModelContent : contentList) { + AspectForIf addItam = new AspectForIf(); + addItam.setAspect(contextModelContent.getAspectUri()); + addItam.setLabel(contextModelContent.getLabel()); + list.add(addItam); + } + log.debug("Aspect : " + list); + return list; + } + } diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/itf/ISdaManager.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/itf/ISdaManager.java index 1f661695..0b962e64 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/itf/ISdaManager.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/itf/ISdaManager.java @@ -16,7 +16,7 @@ public interface ISdaManager { // 상황 조회시 사용 (Location, Device, LocationList) List retrieveEventList(String contextModelId); - +/* // 특정 위치(location)에 존재하는 device Function 목록 조회 List retrieveFunctionListInLocation(String locationId); @@ -35,13 +35,14 @@ public interface ISdaManager { // Sensor Status (측정값) 조회 String retrieveSensorValue(String deviceId); - /* 전체 펑션 목록 */ + // 전체 펑션 목록 List retrieveListByContextModelId(String contextModeId); - /* 전체 aspect 목록 */ + */ + // 전체 aspect 목록 List retrieveAspectList(); - /* 전체 펑션 목록 */ + // 전체 펑션 목록 List retrieveFunctionList(); //1)cm-dd-device-list(Loc,Aspect,Func) 을 이용한 Device 목록 조회 @@ -57,6 +58,13 @@ List getDeviceListByLoc_DeviceType_Aspect_Func(String locationUri, Strin // 4)cm-dd-aspect-action-value (id, aspect, functionality) 을 이용한 aspect Value 조회 ContextModelContent getAspectValueById_Aspect_Function(String deviceId, String aspectUri, String functionUri); + // 5)cm-dd-measuring-loc_dtype_aspect (Loc, Type, Aspect)을 이용한 Measuring + List getMeasuringValueByLocDeviceTypeAspect(String locationUri, String deviceType, String aspectUri); + + // 6) cm-dd-measuring-loc_aspect (Loc, Aspect)을 이용한 Measuring + List getMeasuringValueByLocAspect(String locationUri, String aspectUri); + // 7) cm-dd-measuring-devid_aspect (devId, Aspect)을 이용한 Measuring + List getMeasuringValueByDevIdAspect(String devUri, String aspectUri); } diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/ContextModelContent.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/ContextModelContent.java index b19ba4e2..006979e2 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/ContextModelContent.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/ContextModelContent.java @@ -1,10 +1,10 @@ package com.pineone.icbms.so.interfaces.sda.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import lombok.Setter; -import lombok.ToString; /** * Context contents model. @@ -12,6 +12,7 @@ * Created by uni4love on 2017. 4. 4.. */ @JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) public class ContextModelContent { /** * location list @@ -41,6 +42,20 @@ public class ContextModelContent { @JsonProperty("dev") String deviceUri; + /** + * Device Name + */ + @Getter@Setter + @JsonProperty("dev_name") + String deviceName; + + /** + * Device Type comment + */ + @Getter@Setter + @JsonProperty("dev_type_desc") + String deviceTypeDesc; + /** * Serial Id */ diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/FunctionForIf.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/FunctionForIf.java index 10bfd908..84dcbea2 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/FunctionForIf.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/FunctionForIf.java @@ -1,7 +1,6 @@ package com.pineone.icbms.so.interfaces.sda.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.pineone.icbms.so.virtualobject.common.AGenericIdNameOwner; import lombok.Getter; import lombok.Setter; import lombok.ToString; diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/DataNotExistException.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/DataNotExistException.java index 4263de17..73286dd8 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/DataNotExistException.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/DataNotExistException.java @@ -5,7 +5,9 @@ */ public class DataNotExistException extends SDAException { - public DataNotExistException(){ + private static final long serialVersionUID = 1L; + + public DataNotExistException(){ super("DataNotExist Exception."); } } diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SDAException.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SDAException.java index 16f48357..0739b4be 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SDAException.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SDAException.java @@ -5,7 +5,9 @@ */ public class SDAException extends Exception{ - public SDAException(){ + private static final long serialVersionUID = -6591909415556966767L; + + public SDAException(){ super("SDA Exception."); } diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SdaAddressStore.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SdaAddressStore.java index 2e57d5ec..bcb5424a 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SdaAddressStore.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SdaAddressStore.java @@ -38,4 +38,13 @@ public class SdaAddressStore { /* 전체 펑셔널리티 목록 */ public static final String CM_FUNCTIONALITY_LIST = "cm-functionality-list"; + // 5) cm-dd-measuring-loc_dtype_aspect (Loc, DeviceType, Aspect)을 이용한 Measuring + public static final String CM_DD_MEASURING_BY_LOC_DTYPE_ASPECT = "cm-dd-measuring-loc_dtype_aspect"; + + // 6) cm-dd-measuring-loc_aspect (Loc, Aspect)을 이용한 Measuring + public static final String CM_DD_MEASURING_BY_LOC_ASPECT = "cm-dd-measuring-loc_aspect"; + + // 7) cm-dd-measuring-devid_aspect (devId, Aspect)을 이용한 Measuring + public static final String CM_DD_MEASURING_BY_DEVID_ASPECT = "cm-dd-measuring-devid_aspect"; + } diff --git a/so-if-si/conf/logback-if-si.xml b/so-if-si/conf/logback-if-si.xml deleted file mode 100644 index b670bf83..00000000 --- a/so-if-si/conf/logback-if-si.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/handle/DeviceManager.java b/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/handle/DeviceManager.java index f80e0cd8..5ddbf3ec 100644 --- a/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/handle/DeviceManager.java +++ b/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/handle/DeviceManager.java @@ -165,7 +165,7 @@ private DeviceControlMessage deviceDataConversion(String deviceId, String comman } - public static void testmain(String[] args) { + public void testmain(String[] args) { DeviceManager dm = new DeviceManager(); String commandId = ClientProfile.SI_COMMAND_ID + System.nanoTime(); String aspectId; @@ -175,30 +175,30 @@ public static void testmain(String[] args) { DeviceControlMessage dcMsg; aspectId = "http://www.iotoasis.org/ontology/electronicpower-aspect"; - System.out.println(aspectId); + log.info(aspectId); dcMsg = dm.deviceDataConversion("deviceId",commandId , aspectId, controlValue); - System.out.println(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); + log.info(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); aspectId = "electronicpower-aspect"; - System.out.println(aspectId); + log.info(aspectId); dcMsg = dm.deviceDataConversion("deviceId",commandId , aspectId, controlValue); - System.out.println(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); + log.info(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); aspectId = "/electronicpower-aspect"; - System.out.println(aspectId); + log.info(aspectId); dcMsg = dm.deviceDataConversion("deviceId",commandId , aspectId, controlValue); - System.out.println(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); + log.info(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); aspectId = ""; - System.out.println(aspectId); + log.info(aspectId); dcMsg = dm.deviceDataConversion("deviceId",commandId , aspectId, controlValue); - System.out.println(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); + log.info(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); // String deviceUri = "/herit-in/herit-cse/ONDB_BeamProjector01_001"; aspectId = "http://www.iotoasis.org/ontology/lecture-aspect"; String deviceCommand="1"; ResultMessage resultMessage = dm.deviceExecute(commandId, deviceUri, aspectId, deviceCommand); - System.out.println(resultMessage); + log.info(resultMessage.toString()); } } diff --git a/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/proxy/DeviceSIProxy.java b/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/proxy/DeviceSIProxy.java index 9af81964..54b17ace 100644 --- a/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/proxy/DeviceSIProxy.java +++ b/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/proxy/DeviceSIProxy.java @@ -9,7 +9,7 @@ import com.pineone.icbms.so.interfaces.si.ref.SIAddressStore; import com.pineone.icbms.so.interfaces.si.ref.ClientProfile; import com.pineone.icbms.so.util.conversion.DataConversion; -import com.pineone.icbms.so.util.http.ClientService; +import com.pineone.icbms.so.util.http.ClientServiceTimeout; import com.pineone.icbms.so.util.itf.address.AddressCollector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +23,7 @@ public class DeviceSIProxy implements DeviceControlProxy { */ protected Logger log = LoggerFactory.getLogger(getClass()); - private ClientService clientService = new ClientService(); + private ClientServiceTimeout clientServiceTimeout = new ClientServiceTimeout(); private ObjectMapper mapper = new ObjectMapper(); AddressCollector addressCollector = new AddressCollector(); @@ -36,7 +36,7 @@ public ResultMessage deviceControlRequest(String requestUrl, DeviceControlMessag // String requestBody = new Gson().toJson(deviceControlMessage); log.debug("deviceControlRequest : requestBody {}", requestBody); - String responseData = clientService.requestPostServiceReceiveString2(requestUrl, requestBody, true); //true=timeout + String responseData = clientServiceTimeout.requestPostServiceReceiveString2(requestUrl, requestBody, true); //true=timeout log.debug("deviceControlRequest : responseData {}", responseData); ResultMessage resultMessage = parsingResultMessage(responseData); @@ -49,7 +49,7 @@ public ResultMessage lwm2mDeviceControlRequest(String requestUrl, DeviceControlM String lwm2mCon = DataConversion.base64encoding(new Gson().toJson(lwm2MDeviceControl)); deviceControlMessage.setCon(lwm2mCon); String requestBody = new Gson().toJson(deviceControlMessage); - String responseData = clientService.requestPostServiceReceiveString2(requestUrl, requestBody, true); //true=timeout + String responseData = clientServiceTimeout.requestPostServiceReceiveString2(requestUrl, requestBody, true); //true=timeout ResultMessage resultMessage = parsingResultMessage(responseData); return resultMessage; } @@ -64,7 +64,7 @@ public String deviceSubscriptionRequest(String deviceUri, String commandId) { String requestBody = new Gson().toJson(deviceSubscriptionData); - String responseData = clientService.requestPostServiceReceiveString2(addressCollector.getServerAddress(AddressCollector.SI_SERVER) + SIAddressStore.SI_SUBSCRIPTION_URI, requestBody); + String responseData = clientServiceTimeout.requestPostServiceReceiveString2(addressCollector.getServerAddress(AddressCollector.SI_SERVER) + SIAddressStore.SI_SUBSCRIPTION_URI, requestBody); // ResponseData{ "code" : "2000", "message" : "", "content" : "" } ResultMessage resultMessage = parsingResultMessage(responseData); return resultMessage.getCode(); @@ -77,7 +77,7 @@ public String deviceSubscriptionReleaseRequest(String deviceUri) { deviceSubscriptionData.set_uri(deviceUri); String requestBody = new Gson().toJson(deviceSubscriptionData); - String responseData = clientService.requestPostServiceReceiveString2(addressCollector.getServerAddress(AddressCollector.SI_SERVER) + SIAddressStore.SI_SUBSCRIPTION_RELEASE_URI, requestBody); + String responseData = clientServiceTimeout.requestPostServiceReceiveString2(addressCollector.getServerAddress(AddressCollector.SI_SERVER) + SIAddressStore.SI_SUBSCRIPTION_RELEASE_URI, requestBody); ResultMessage resultMessage = parsingResultMessage(responseData); return resultMessage.getCode(); } diff --git a/so-if-si/src/test/java/DeviceControlTest.java b/so-if-si/src/test/java/DeviceControlTest.java deleted file mode 100644 index 8ce3545f..00000000 --- a/so-if-si/src/test/java/DeviceControlTest.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Created by melvin on 2017. 4. 5.. - */ -public class DeviceControlTest { -// @Test -// public void DeviceControl() throws Exception { -// -// IDeviceManager deviceManager = new DeviceManager(); -// deviceManager.deviceExecute("/herit-in/herit-cse/ONDB_BeamProjector01_001", "1"); -// } - -// @Test -// public void name() throws Exception { -// long a = 1477283378273L; -// System.out.println(new SimpleDateFormat("YYYY-MM-dd HH:mm:ss").format(a)); -// } -} diff --git a/so-scheduler/conf/application-dev.properties b/so-scheduler/conf/application-dev.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/so-scheduler/conf/logback-sch.xml b/so-scheduler/conf/logback-sch.xml deleted file mode 100644 index 163a8518..00000000 --- a/so-scheduler/conf/logback-sch.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerManager.java b/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerManager.java index e1a5e37d..6add5b34 100644 --- a/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerManager.java +++ b/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerManager.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; import java.util.List; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -203,10 +204,12 @@ public List executedJobList() { if (profileForDB != null) { profileList.add(profileForDB); } - } + } + SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String nextFireTimeStr = sdf.format(nextFireTime); log.debug(" === [jobName] : " + jobName + " [groupName] : " + jobGroup - + " - " + nextFireTime + + " - " + nextFireTimeStr + " = triggerState : " + triggerState.toString()); } } diff --git a/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerNotificationManager.java b/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerNotificationManager.java index 8e262ab1..60fccbb4 100644 --- a/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerNotificationManager.java +++ b/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerNotificationManager.java @@ -4,7 +4,7 @@ import com.pineone.icbms.so.util.Settings2; import com.pineone.icbms.so.util.conversion.DataConversion; import com.pineone.icbms.so.util.conversion.ProfileTransFormData; -import com.pineone.icbms.so.util.http.ClientService; +import com.pineone.icbms.so.util.http.ClientServiceNoTimeout; import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; @@ -107,7 +107,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException { } private boolean checkCm(String profileId, boolean checkOnly) { - ClientService clientService = new ClientService(); + ClientServiceNoTimeout clientService = new ClientServiceNoTimeout(); ProfileTransFormData profileTransFormData = new ProfileTransFormData(profileId); //profileTransFormData.setPeriod(period); profileTransFormData.setCheckOnly(checkOnly);; diff --git a/so-scheduler/src/test/java/com/pineone/icbms/so/web/SoSchedulerApplicationTests.java b/so-scheduler/src/test/java/com/pineone/icbms/so/web/SoSchedulerApplicationTests.java deleted file mode 100644 index 625fa7e5..00000000 --- a/so-scheduler/src/test/java/com/pineone/icbms/so/web/SoSchedulerApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -//package com.pineone.icbms.so.web; -// -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.test.context.junit4.SpringRunner; -// -//@RunWith(SpringRunner.class) -//@SpringBootTest -//public class SoSchedulerApplicationTests { -// -// @Test -// public void contextLoads() { -// } -// -//} diff --git a/so-serviceprocessor/build.gradle b/so-serviceprocessor/build.gradle index b4fd60ed..af48476f 100644 --- a/so-serviceprocessor/build.gradle +++ b/so-serviceprocessor/build.gradle @@ -72,9 +72,6 @@ dependencies { //json object mapper compile "com.fasterxml.jackson.core:jackson-databind:${VERSION.jackson_databind}" - //withwiz - compile "com.withwiz:plankton:0.1.3" - //spring compile('org.springframework.boot:spring-boot-starter') diff --git a/so-serviceprocessor/conf/application-dev.properties b/so-serviceprocessor/conf/application-dev.properties deleted file mode 100644 index 6ef7c9b8..00000000 --- a/so-serviceprocessor/conf/application-dev.properties +++ /dev/null @@ -1,63 +0,0 @@ -#----------SERVER -server.port=8081 - - -#----------LOG -logging.config=file:./conf/logback-sp.xml - -#----------PROCESSOR LIST -so.serviceprocessor.contextmodel.enable=true -so.serviceprocessor.orchestrationservice.enable=true -so.serviceprocessor.virtualobject.enable=true -so.serviceprocessor.devicecontrol.enable=true - -#----------DEVICE DRIVER -so.device.driver.path=/svc/apps/so/so/driver - -#----------MESSAGE QUEUE -mq.broker.list=localhost:9092 -mq.zookeeper.list=localhost:2181 - -##---------PRODUCER: All values referenced from Kafka -# ACKS_CONFIG -mq.producer.acks=2 -# RETRIES_CONFIG -mq.producer.retries=0 -# BATCH_SIZE_CONFIG -mq.producer.batch_size=16384 -# LINGER_MS_CONFIG -mq.producer.linger_ms=1 -# BUFFER_MEMORY_CONFIG SIZE -mq.producer.buffer_memoryproducer.buffer_memoryproducer.buffer_memory=33554432 - -##---------CONSUMER: All values referenced from Kafka -# POLL_TIMEOUT=3000L -mq.consumer.pool_timeout=4000 -# ENABLE_AUTO_COMMIT_CONFIG=true -mq.consumer.enable_auto_commit=false -# AUTO_COMMIT_INTERVAL_MS_CONFIG -mq.consumer.auto_commit_interval_ms=1000 -# SESSION_TIMEOUT_MS_CONFIG -mq.consumer.session_timeout_ms=15000 -# AUTO_OFFSET_RESET_CONFIG -mq.consumer.auto_offset_reset_config=earliest - -#----------BANNER -banner.location=banner.txt -banner.charset=UTF-8 - -#----------DATABASE -#spring.datasource.url=jdbc:mysql://rgate.synology.me:33306/serviceorchestration?useUnicode=true&characterEncoding=utf-8 -#spring.datasource.username=orchestrator -#spring.datasource.password=pine123 -#spring.datasource.driverClassName=com.mysql.jdbc.Driver - -#spring.jpa.hibernate.ddl-auto=create-drop -#spring.jpa.generate-ddl=false -#spring.jpa.database=mysql -#spring.jpa.show-sql=true - -#----------REMOTE SHELL -#shell.auth.simple.user.name=so -#shell.auth.simple.user.password=so!@# - diff --git a/so-serviceprocessor/conf/application-product.properties b/so-serviceprocessor/conf/application-product.properties deleted file mode 100644 index f0117bcf..00000000 --- a/so-serviceprocessor/conf/application-product.properties +++ /dev/null @@ -1,70 +0,0 @@ -#----------SERVER -server.port=8081 - - -#----------LOG -logging.config=file:../conf/logback-sp.xml - -#----------PROCESSOR LIST -so.serviceprocessor.contextmodel.enable=true -so.serviceprocessor.orchestrationservice.enable=true -so.serviceprocessor.virtualobject.enable=true -so.serviceprocessor.devicecontrol.enable=true - -#----------DEVICE DRIVER -so.device.driver.path=/svc/apps/so/so/driver - -#----------MESSAGE QUEUE -mq.broker.list=localhost:9092 -mq.zookeeper.list=localhost:2181 - -##---------PRODUCER: All values referenced from Kafka -# ACKS_CONFIG -mq.producer.acks=2 -# RETRIES_CONFIG -mq.producer.retries=0 -# BATCH_SIZE_CONFIG -mq.producer.batch_size=16384 -# LINGER_MS_CONFIG -mq.producer.linger_ms=1 -# BUFFER_MEMORY_CONFIG SIZE -mq.producer.buffer_memoryproducer.buffer_memoryproducer.buffer_memory=33554432 - -##---------CONSUMER: All values referenced from Kafka -# POLL_TIMEOUT=3000L -mq.consumer.pool_timeout=4000 -# ENABLE_AUTO_COMMIT_CONFIG=true -mq.consumer.enable_auto_commit=false -# AUTO_COMMIT_INTERVAL_MS_CONFIG -mq.consumer.auto_commit_interval_ms=1000 -# SESSION_TIMEOUT_MS_CONFIG -mq.consumer.session_timeout_ms=15000 -# AUTO_OFFSET_RESET_CONFIG -mq.consumer.auto_offset_reset_config=earliest - -#----------BANNER -banner.location=banner.txt -banner.charset=UTF-8 - -#----------DATABASE -spring.datasource.url=jdbc:mysql://rgate.synology.me:33306/serviceorchestration?useUnicode=true&characterEncoding=utf-8 -spring.datasource.username=orchestrator -spring.datasource.password=pine123 -spring.datasource.driverClassName=com.mysql.jdbc.Driver - -#spring.jpa.hibernate.ddl-auto=create-drop -#spring.jpa.generate-ddl=false -#spring.jpa.database=mysql -#spring.jpa.show-sql=true - -#----------MONGO DB -#spring.data.mongodb.database=so -#spring.data.mongodb.host= -#spring.data.mongodb.port= -#spring.data.mongodb.host=127.0.0.1 -#spring.data.mongodb.port=27017 -spring.data.mongodb.repositories.enabled=true - -#----------REMOTE SHELL -#shell.auth.simple.user.name=so -#shell.auth.simple.user.password=so!@# diff --git a/so-serviceprocessor/conf/logback-sp.xml b/so-serviceprocessor/conf/logback-sp.xml deleted file mode 100644 index 8bb06bea..00000000 --- a/so-serviceprocessor/conf/logback-sp.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_PROCESSOR_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_PROCESSOR_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_PROCESSOR_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_PROCESSOR_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/SoProcessorApplication.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/SoProcessorApplication.java index 7df2724b..2ce9ac72 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/SoProcessorApplication.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/SoProcessorApplication.java @@ -22,7 +22,7 @@ public class SoProcessorApplication implements CommandLineRunner { * @param args arguments */ public static void main(String[] args) { - System.out.println("*user.dir: " + System.getProperty("user.dir")); +// System.out.println("*user.dir: " + System.getProperty("user.dir")); // SpringApplication.run(SoProcessorApplication.class, args); // SpringApplication app = new SpringApplication(SoProcessorApplication.class); // app.run(args); diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/DepthCheckFilter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/DepthCheckFilter.java deleted file mode 100644 index 4cbf4787..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/DepthCheckFilter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.filter; - -import com.pineone.icbms.so.serviceutil.interfaces.filter.IFilter; - -/** - * Depth check filter abstract class. - * - * Created by uni4love on 2017. 1. 15.. - */ -abstract public class DepthCheckFilter implements IFilter { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/ExpireDateFilter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/ExpireDateFilter.java deleted file mode 100644 index 26b3ba38..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/ExpireDateFilter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.filter; - -import com.pineone.icbms.so.serviceutil.interfaces.filter.IFilter; - -/** - * Expire date filter abstract class. - * - * Created by uni4love on 2017. 1. 15.. - */ -abstract public class ExpireDateFilter implements IFilter { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/MessageExpireDateFilter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/MessageExpireDateFilter.java deleted file mode 100644 index f140c612..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/MessageExpireDateFilter.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.filter; - -import com.pineone.icbms.so.serviceutil.interfaces.filter.IFilter; -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; - -/** - * Message Expire date for message queue filter class. - * - * Created by uni4love on 2017. 1. 15.. - */ -public class MessageExpireDateFilter implements IFilter, IGenericProcessor { - @Override - public V filtering(V v) { - return null; - } - - /** - * return id. - * - * @return id - */ - @Override - public String getId() { - return null; - } - - /** - * return name. - * - * @return name - */ - @Override - public String getName() { - return null; - } - - /** - * called method before process() - */ - @Override - public void beforeProcess() { - - } - - /** - * called method after process() - */ - @Override - public void afterProcess() { - - } - - /** - * process method. - */ - @Override - public void process() { - //implements.. - //got from message queue, and filter - //call filtering() method. - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/ContextModelProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/ContextModelProcessor.java deleted file mode 100644 index 0ac3dc00..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/ContextModelProcessor.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.context.messagequeue.consumer.ContextModelConsumerHandler; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * ContextModelConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class ContextModelProcessor extends AGenericProcessor { - /** - * constructor - */ - public ContextModelProcessor() { - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public ContextModelProcessor(String id, String name) { - super(id, name); - } - - /** - * called by beforeProcess(). - */ - @Override - public void before() { - - } - - /** - * called by afterProcess(). - */ - @Override - public void after() { - - } - - /** - * begin Handler on thread. - */ - public void process() { - //executorservice - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - //handler list - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - ContextModelConsumerHandler consumer = new ContextModelConsumerHandler(i); - consumerList.add(consumer); - //execute a thread - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (ContextModelConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/handler/ContextModelHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/handler/ContextModelHandler.java index 09267590..3c03b980 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/handler/ContextModelHandler.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/handler/ContextModelHandler.java @@ -1,6 +1,5 @@ package com.pineone.icbms.so.serviceprocessor.processor.context.handler; -import com.pineone.icbms.so.interfaces.database.dao.SessionDao; import com.pineone.icbms.so.interfaces.database.model.ContextModelForDB; import com.pineone.icbms.so.interfaces.database.model.ProfileForDB; import com.pineone.icbms.so.interfaces.database.model.SessionEntity; @@ -14,19 +13,13 @@ import com.pineone.icbms.so.util.Settings2; import com.pineone.icbms.so.util.conversion.DataConversion; import com.pineone.icbms.so.util.conversion.ProfileTransFormData; -import com.pineone.icbms.so.util.http.ClientService; +import com.pineone.icbms.so.util.http.ClientServiceNoTimeout; import com.pineone.icbms.so.util.messagequeue.producer.DefaultProducerHandler; -import com.pineone.icbms.so.util.priority.Priority; -import com.pineone.icbms.so.util.session.DefaultSession; -import com.pineone.icbms.so.util.session.Session; import com.pineone.icbms.so.virtualobject.context.contextmodel.IGenericContextModel; import com.pineone.icbms.so.virtualobject.location.IGenericLocation; import com.pineone.icbms.so.virtualobject.orchestrationservice.IGenericOrchestrationService; import com.pineone.icbms.so.virtualobject.profile.IGenericProfile; -import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; -import java.util.Date; import java.util.List; /** @@ -309,7 +302,7 @@ int callDependantProfile(String profileId) { //Dependant Profile이 있으면 if (profileSize>0) { log.debug("callDependantProfile : dependant profiles({}) = {}", profileSize, profileDeps.toString()); - ClientService clientService = new ClientService(); + ClientServiceNoTimeout clientService = new ClientServiceNoTimeout(); for (String childId : profileDeps) { ProfileTransFormData profileTransFormData = new ProfileTransFormData(childId); diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandler.java index 3412f716..f6cf6fe9 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandler.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandler.java @@ -2,7 +2,6 @@ import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; import com.pineone.icbms.so.interfaces.messagequeue.model.ContextModelForMQ; -import com.pineone.icbms.so.serviceprocessor.Const; import com.pineone.icbms.so.serviceutil.interfaces.database.IDatabaseManager; import com.pineone.icbms.so.serviceprocessor.processor.context.handler.ContextModelHandler; import com.pineone.icbms.so.serviceutil.modelmapper.ModelMapper; diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandlerFactory.java deleted file mode 100644 index 70c64147..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandlerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.messagequeue.consumer; - -/** - * SpringKafkaContextModelConsumerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class ContextModelConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaContextModelConsumerHandler instance. - * - * @return ContextModelConsumer - */ - public static ContextModelConsumerHandler getContextModelConsumer(int id) { - return new ContextModelConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandler.java deleted file mode 100644 index d7ff6462..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.messagequeue.producer; - -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * ContextModelForMQ Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class ContextModelProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = "contextmodel"; - - /** - * kafka producer group id by class name. - */ - private final String GROUP_ID = getClass().getSimpleName(); - - /** - * constructor. - */ - public ContextModelProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandlerFactory.java deleted file mode 100644 index 22b9dd80..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.messagequeue.producer; - -/** - * SpringKafkaContextModelProducerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class ContextModelProducerHandlerFactory { - /** - * return SpringKafkaContextModelProducerHandler instance. - * - * @return SpringKafkaContextModelProducerHandler - */ - public static ContextModelProducerHandler getContextModelProducerHandler(int id) { - return new ContextModelProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/provider/ContextProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/provider/ContextProvider.java deleted file mode 100644 index cd747b2c..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/provider/ContextProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.provider; - -import com.pineone.icbms.so.serviceutil.interfaces.provider.IContextModelProvider; -import com.pineone.icbms.so.virtualobject.context.contextmodel.IGenericContextModel; - -/** - * Context provider implements. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class ContextProvider implements IContextModelProvider { - /** - * Create - * - * @param iGenericContextModel - * @return ID - */ - @Override - public String create(IGenericContextModel iGenericContextModel) { - return null; - } - - /** - * Retreive - * - * @param s - * @return M - */ - @Override - public IGenericContextModel retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericContextModel - * @return model ID - */ - @Override - public String update(IGenericContextModel iGenericContextModel) { - return null; - } - - /** - * delete - * - * @param iGenericContextModel - * @return model ID - */ - @Override - public String delete(IGenericContextModel iGenericContextModel) { - return null; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/springkafka/SpringKafkaContextModelProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/springkafka/SpringKafkaContextModelProducerHandler.java deleted file mode 100644 index 7be33353..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/springkafka/SpringKafkaContextModelProducerHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * 'contextmodel' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaContextModelProducerHandler extends AProducerHandler { - - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_CONTEXT_MODEL, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/CvoProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/CvoProcessor.java deleted file mode 100644 index 2ecb6811..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/CvoProcessor.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo; - -import com.pineone.icbms.so.serviceprocessor.processor.cvo.messagequeue.consumer.CvoConsumerHandler; -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * CvoConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class CvoProcessor extends AGenericProcessor { - /** - * constructor - */ - public CvoProcessor() { - - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public CvoProcessor(String id, String name) { - super(id, name); - } - - /** - * begin Handler on thread. - */ - @Override - public void process() { - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - CvoConsumerHandler consumer = new CvoConsumerHandler(i); - consumerList.add(consumer); - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (CvoConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * called method before process() - */ - @Override - public void before() { - - } - - /** - * called method after process() - */ - @Override - public void after() { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/handler/CvoHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/handler/CvoHandler.java index c2d06e37..b418cad0 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/handler/CvoHandler.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/handler/CvoHandler.java @@ -121,6 +121,7 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { builtCvoList.add(builtCvo); } + cvoIds = "[" + cvoIds + "]"; SessionEntity sessionCvo = databaseManager.getSessionData(sessionId); @@ -131,6 +132,11 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { sessionCvo.setServiceKey(cvoIds); databaseManager.updateSessionData(sessionCvo); + certLog.debug("=============START(CVO_TYPE_NONEDEVICE)=============="); + certLog.debug("sessionID : " + sessionId); + certLog.debug("baseCVOID : " + cvoBaseId); + certLog.debug("=======================END============================"); + handleCompositeVirtualObjectList(builtCvoList, compositeVirtualObject.getStateStore()); return; @@ -166,8 +172,8 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { if (vId.equals(validVo.getId())){ VirtualObjectForDB vo = new VirtualObjectForDB(); vo.setAspectUri(item.getAspectUri()); - vo.setFunctionalityId(item.getFuntionalityId()); - vo.setFunctionalityUri(item.getFuntionalityUri()); + vo.setFunctionalityId(item.getFunctionalityId()); + vo.setFunctionalityUri(item.getFunctionalityUri()); vo.setId(item.getVoId()); vo.setVoValueType(item.getVoValueType()); vo.setVoValue(item.getVoValue()); @@ -236,15 +242,36 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { //DeviceId 목록을 가져옴 deviceList = new SdaManager().getDeviceListByLoc_DeviceType_Aspect_Func(locationUri, physicalDeviceTypeUri, aspectUri, functionalityUri); log.info("getDeviceListByLoc_DeviceType_Aspect_Func :\nlocationUri={}\n physicalDeviceTypeUri={}\n aspectUri={}\n functionalityUri={}", locationUri, physicalDeviceTypeUri, aspectUri, functionalityUri ); - certLog.debug("{} : getDeviceListByLoc_DeviceType_Aspect_Func from knowledge base :\nlocationUri={}\n physicalDeviceTypeUri={}\n aspectUri={}\n functionalityUri={}", sessionId, locationUri, physicalDeviceTypeUri, aspectUri, functionalityUri ); + // certLog.debug("{} : getDeviceListByLoc_DeviceType_Aspect_Func from knowledge base :\nlocationUri={}\n physicalDeviceTypeUri={}\n aspectUri={}\n functionalityUri={}", sessionId, locationUri, physicalDeviceTypeUri, aspectUri, functionalityUri ); + + certLog.debug("=============START(CVO_TYPE_DEVICETYPE)=============="); + certLog.debug("sessionID : " + sessionId); + certLog.debug("===============SDA Request Parameters================"); + certLog.debug("1. locationUri : " + locationUri); + certLog.debug("2. physicalDeviceTypeUri : " + physicalDeviceTypeUri); + certLog.debug("3. aspectUri : " + aspectUri); + certLog.debug("4. functionalityUri : " + functionalityUri); + certLog.debug("===============SDA Response DeviceList================"); + certLog.debug("deviceList : " + deviceList.toString()); + certLog.debug("=======================END============================"); + } else if (cvoType.equals("CVO_TYPE_ASPECT")) { //DeviceId 목록을 가져옴 deviceList = new SdaManager().getDeviceListByLoc_Aspect_Func(locationUri, aspectUri, functionalityUri); log.info("getDeviceListByLoc_Aspect_Func :\nlocationUri={}\n aspectUri={}\n functionalityUri={}", locationUri, aspectUri, functionalityUri ); - certLog.debug("{} : getDeviceListByLoc_Aspect_Func :\nlocationUri={}\n aspectUri={}\n functionalityUri={}", sessionId, locationUri, aspectUri, functionalityUri ); - - } else if (cvoType.equals("CVO_TYPE_NONEDEVICE")) { + // certLog.debug("{} : getDeviceListByLoc_Aspect_Func :\nlocationUri={}\n aspectUri={}\n functionalityUri={}", sessionId, locationUri, aspectUri, functionalityUri ); + + certLog.debug("===============START(CVO_TYPE_ASPECT)================"); + certLog.debug("sessionID : " + sessionId); + certLog.debug("===============SDA Request Parameters================"); + certLog.debug("1. locationUri : " + locationUri); + certLog.debug("2. aspectUri : " + aspectUri); + certLog.debug("3. functionalityUri : " + functionalityUri); + certLog.debug("===============SDA Response DeviceList================"); + certLog.debug("deviceList : " + deviceList.toString()); + certLog.debug("========================END==========================="); + } } if (deviceList==null) { @@ -273,6 +300,8 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { if (cvoType.equals("CVO_TYPE_DEVICEID")) { //VO list handleVirtualObjectList(builtCvoList.get(0), compositeVirtualObject.getStateStore()); + + } else { diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/consumer/CvoConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/consumer/CvoConsumerHandlerFactory.java deleted file mode 100644 index ed4a3070..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/consumer/CvoConsumerHandlerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.messagequeue.consumer; - -/** - * SpringKafkaCvoConsumerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class CvoConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaCvoConsumerHandler instance. - * - * @return SpringKafkaCvoConsumerHandler - */ - public static CvoConsumerHandler getCvoConsumerHandler(int id) { - return new CvoConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandler.java deleted file mode 100644 index d30918ba..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.messagequeue.producer; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * CompositeVirtualObjectForDB Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class CvoProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = Settings2.TOPIC_COMPOSITE_VIRTUAL_OBJECT; - - /** - * kafka producer group id by class name. - */ - private static final String GROUP_ID = CvoProducerHandler.class.getSimpleName(); - - /** - * constructor. - */ - public CvoProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandlerFactory.java deleted file mode 100644 index ba7577b3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.messagequeue.producer; - -/** - * SpringKafkaCvoProducerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class CvoProducerHandlerFactory { - /** - * return SpringKafkaCvoProducerHandler instance. - * - * @return SpringKafkaCvoProducerHandler - */ - public static CvoProducerHandler getCvoProducerHandler(int id) { - return new CvoProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/provider/CvoProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/provider/CvoProvider.java deleted file mode 100644 index ae8bf764..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/provider/CvoProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.provider; - -import java.util.List; - -import com.pineone.icbms.so.interfaces.database.model.CompositeVirtualObjectForDB; -import com.pineone.icbms.so.interfaces.database.model.RuleBodyForDB; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.ICompositeVirtualObjectProvider; -import com.pineone.icbms.so.virtualobject.composite.IGenericCompositeVirtualObject; - -/** - * OrchestrationService provider class. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class CvoProvider implements ICompositeVirtualObjectProvider { - /** - * Create - * - * @param IGenericCompositeVirtualObject - * @return ID - */ - @Override - public String create(IGenericCompositeVirtualObject iGenericCompositeVirtualObject) { - return null; - } - - /** - * Retreive - * - * @param s - * @return M - */ - @Override - public IGenericCompositeVirtualObject retreive(String s) { - return null; - } - - /** - * Update - * - * @param IGenericCompositeVirtualObject - * @return model ID - */ - @Override - public String update(IGenericCompositeVirtualObject iGenericCompositeVirtualObject) { - return null; - } - - /** - * delete - * - * @param IGenericCompositeVirtualObject - * @return model ID - */ - @Override - public String delete(IGenericCompositeVirtualObject iGenericCompositeVirtualObject) { - return null; - } - - /** - * return OrchestrationServiceForDB from database. - * - * @param id orchestration service id - * @return OrchestrationServiceForDB - */ - public List getRuleBodyListByOsId(String id) { - return DatabaseManager.getInstance().getRuleBodyListByOsId(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/springkafka/SpringKafkaCvoProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/springkafka/SpringKafkaCvoProducerHandler.java deleted file mode 100644 index 846940b8..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/springkafka/SpringKafkaCvoProducerHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * 'compositevirtualobject' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaCvoProducerHandler extends AProducerHandler { - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_COMPOSITE_VIRTUAL_OBJECT, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/DeviceControlProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/DeviceControlProcessor.java deleted file mode 100644 index e57ec68b..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/DeviceControlProcessor.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.messagequeue.consumer.DeviceControlConsumerHandler; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * DeviceControlConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DeviceControlProcessor extends AGenericProcessor { - /** - * constructor - */ - public DeviceControlProcessor() { - - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public DeviceControlProcessor(String id, String name) { - super(id, name); - } - - /** - * begin Handler on thread. - */ - @Override - public void process() { - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - DeviceControlConsumerHandler consumer = new DeviceControlConsumerHandler(i); - consumerList.add(consumer); - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (DeviceControlConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * called method before process() - */ - @Override - public void before() { - - } - - /** - * called method after process() - */ - @Override - public void after() { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/handler/DeviceControlHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/handler/DeviceControlHandler.java index 74dbde19..0665b708 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/handler/DeviceControlHandler.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/handler/DeviceControlHandler.java @@ -1,7 +1,5 @@ package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.handler; -import com.pineone.icbms.so.devicecontrol.model.virtualdevice.DeviceControlValue; -import com.pineone.icbms.so.devicecontrol.model.virtualdevice.driver.IGenericDeviceDriver; import com.pineone.icbms.so.interfaces.database.model.SessionEntity; import com.pineone.icbms.so.interfaces.messagequeue.producer.tracking.TrackingProducer; import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; @@ -16,9 +14,6 @@ import org.slf4j.LoggerFactory; import com.pineone.icbms.so.interfaces.si.model.ResultMessage; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; /** * device control handler. @@ -73,26 +68,6 @@ public void handle(IGenericVirtualDevice virtualDevice, String locationUri, Stri String sessionId = getTracking().getSessionId(); - // get DeviceDriver from sda by virtual object features - // retrieve device list -// SdaClient sdaClient = new SdaClient(); -// List deviceList = sdaClient.retreiveDeviceList(null, locationUri); - - //create control list - // TODO product : get device control value to use SDA API. -// DeviceControlValue deviceControlValue = ModelMapper.toDeviceControlValue(deviceControlForDB); -// LinkedHashMap> controlList = new LinkedHashMap<>(); -// if (deviceList != null) { -// for (IGenericVirtualDevice device : deviceList) { -// String driverClassName = device.getDriverClassName(); - //load devicemapper driver -// IGenericDeviceDriver deviceDriver = new DeviceDriverLoader().loadDeviceDriver(Settings.DEVICE_DRIVER_PATH, driverClassName); - //retreive values from sda -// List values = sdaClient.retreiveDeviceControlValues(null, null, locationUri, device.getId()); -// controlList.put(deviceDriver, values); -// } - - String deviceId = virtualDevice.getDeviceId(); String aspectUri = virtualDevice.getAspect().getUri(); String functionUri = virtualDevice.getFunction().getUri(); @@ -181,7 +156,10 @@ public void handle(IGenericVirtualDevice virtualDevice, String locationUri, Stri // grib session device SessionEntity sessionDevice = new SessionEntity(); sessionDevice.setId(sessionId); - sessionDevice.setDeviceKey(deviceId); + + //Device Uri중에서 "http://www.iotoasis.org" 문자열 제외하고 session Log에 저장 + String stripDeviceId = deviceId.replace(ClientProfile.IOT_OASIS_DOMAIN_NAME, ""); //"http://www.iotoasis.org" 삭제 + sessionDevice.setDeviceKey(stripDeviceId); sessionDevice.setDeviceLocation(loc); log.debug("session device : {}", sessionDevice); databaseManager.createSessionDataDevice(sessionDevice); @@ -200,25 +178,6 @@ public void handle(IGenericVirtualDevice virtualDevice, String locationUri, Stri } } - /** - * control a device. - * - * @param deviceControlList device control list - */ - private void controlDevice(LinkedHashMap> deviceControlList) { - //TODO: thread process 고민 필요 - if (deviceControlList != null) { - for (Map.Entry> entry : deviceControlList.entrySet()) { - IGenericDeviceDriver deviceDriver = entry.getKey(); - List values = entry.getValue(); - // - //databaseManager.getDeviceControlByDeviceIdAndContextModelID - log.debug(">>>>>>>>> size of deviceControlList: {}, {}, {} ", deviceControlList.size(), entry.getKey(), entry.getValue()); - deviceDriver.control(values); - } - } - } - /** * control a device. * diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/consumer/DeviceControlConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/consumer/DeviceControlConsumerHandlerFactory.java deleted file mode 100644 index 0e8a11ec..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/consumer/DeviceControlConsumerHandlerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.messagequeue.consumer; - -/** - * SpringKafkaDeviceControlConsumerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class DeviceControlConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaContextModelConsumerHandler instance. - * - * @return SpringKafkaContextModelConsumerHandler - */ - public static DeviceControlConsumerHandler getDeviceControlConsumer(int id) { - return new DeviceControlConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandler.java deleted file mode 100644 index 738fb2d3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.messagequeue.producer; - -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * DeviceControlForMQ Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class DeviceControlProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = "devicecontrol"; - - /** - * kafka producer group id by class name. - */ - private static final String GROUP_ID = DeviceControlProducerHandler.class.getSimpleName(); - - /** - * constructor. - */ - public DeviceControlProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandlerFactory.java deleted file mode 100644 index 1bf9d932..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.messagequeue.producer; - -/** - * SpringKafkaDeviceControlProducerHandler factory - * - * Created by uni4love on 2017. 1. 4.. - */ -public class DeviceControlProducerHandlerFactory { - /** - * return SpringKafkaDeviceControlProducerHandler instance. - * - * @return SpringKafkaDeviceControlProducerHandler - */ - public static DeviceControlProducerHandler getDeviceControlProducerHandler(int id) { - return new DeviceControlProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/provider/DeviceProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/provider/DeviceProvider.java deleted file mode 100644 index 970d0475..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/provider/DeviceProvider.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.provider; - -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.interfaces.database.model.DeviceForDB; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.IDeviceControlProvider; - -import java.util.List; - -/** - * Device provider implements. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class DeviceProvider implements IDeviceControlProvider { - /** - * database manager - */ - DatabaseManager databaseManager; - - /** - * constructor. - * - * @param databaseManager DatabaseManager - */ - public DeviceProvider(DatabaseManager databaseManager) { - this.databaseManager = databaseManager; - } - - /** - * Create - * - * @param iGenericVirtualDevice - * @return ID - */ - @Override - public String create(IGenericVirtualDevice iGenericVirtualDevice) { - return null; - } - - /** - * Retrecive - * - * @param s - * @return M - */ - @Override - public IGenericVirtualDevice retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericVirtualDevice - * @return model ID - */ - @Override - public String update(IGenericVirtualDevice iGenericVirtualDevice) { - return null; - } - - /** - * delete - * - * @param iGenericVirtualDevice - * @return model ID - */ - @Override - public String delete(IGenericVirtualDevice iGenericVirtualDevice) { - return null; - } - - /** - * return IGenericVirtualDevice list from database. - * - * @param function function uri - * @param aspect aspect - * @param locationUri location uri - * @return IGenericVirtualDevice list - */ - public List getDeviceList(String function, String aspect, String locationUri) { - return databaseManager.getDeviceList(function, aspect, locationUri); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/springkafka/SpringKafkaDeviceControlProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/springkafka/SpringKafkaDeviceControlProducerHandler.java deleted file mode 100644 index 41f44da2..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/springkafka/SpringKafkaDeviceControlProducerHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * 'contextmodel' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaDeviceControlProducerHandler extends AProducerHandler { - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_DEVICE_CONTROL, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/OrchestrationServiceProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/OrchestrationServiceProcessor.java deleted file mode 100644 index fe61637a..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/OrchestrationServiceProcessor.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice; - -import com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.messagequeue.consumer.OrchestrationServiceConsumerHandler; -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * OrchestrationServiceConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class OrchestrationServiceProcessor extends AGenericProcessor { - /** - * constructor - */ - public OrchestrationServiceProcessor() { - - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public OrchestrationServiceProcessor(String id, String name) { - super(id, name); - } - - /** - * begin Handler on thread. - */ - @Override - public void process() { - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - OrchestrationServiceConsumerHandler consumer = new OrchestrationServiceConsumerHandler(i); - consumerList.add(consumer); - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (OrchestrationServiceConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * called method before process() - */ - @Override - public void before() { - - } - - /** - * called method after process() - */ - @Override - public void after() { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/consumer/OrchestrationServiceConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/consumer/OrchestrationServiceConsumerHandlerFactory.java deleted file mode 100644 index 2d4ecb9b..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/consumer/OrchestrationServiceConsumerHandlerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.messagequeue.consumer; - -/** - * SpringKafkaOrchestrationServiceConsumerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class OrchestrationServiceConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaOrchestrationServiceConsumerHandler instance. - * - * @return SpringKafkaOrchestrationServiceConsumerHandler - */ - public static OrchestrationServiceConsumerHandler getOrchestrationServiceConsumerHandler(int id) { - return new OrchestrationServiceConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandler.java deleted file mode 100644 index 4eed2766..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.messagequeue.producer; - -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * OrchestrationServiceForMQ Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class OrchestrationServiceProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = "orchestrationservice"; - - /** - * kafka producer group id by class name. - */ - private static final String GROUP_ID = OrchestrationServiceProducerHandler.class.getSimpleName(); - - /** - * constructor. - */ - public OrchestrationServiceProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandlerFactory.java deleted file mode 100644 index 56466a48..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.messagequeue.producer; - -/** - * SpringKafkaOrchestrationServiceProducerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class OrchestrationServiceProducerHandlerFactory { - /** - * return SpringKafkaOrchestrationServiceProducerHandler instance. - * - * @return SpringKafkaOrchestrationServiceProducerHandler - */ - public static OrchestrationServiceProducerHandler getOrchestrationServiceProducerHandler(int id) { - return new OrchestrationServiceProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/provider/OrchestrationServiceProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/provider/OrchestrationServiceProvider.java deleted file mode 100644 index 757d7a79..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/provider/OrchestrationServiceProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.provider; - -import com.pineone.icbms.so.interfaces.database.model.OrchestrationServiceForDB; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.IOrchestrationServiceProvider; -import com.pineone.icbms.so.virtualobject.orchestrationservice.IGenericOrchestrationService; - -/** - * OrchestrationService provider class. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class OrchestrationServiceProvider implements IOrchestrationServiceProvider { - /** - * Create - * - * @param iGenericOrchestrationService - * @return ID - */ - @Override - public String create(IGenericOrchestrationService iGenericOrchestrationService) { - return null; - } - - /** - * Retreive - * - * @param s - * @return M - */ - @Override - public IGenericOrchestrationService retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericOrchestrationService - * @return model ID - */ - @Override - public String update(IGenericOrchestrationService iGenericOrchestrationService) { - return null; - } - - /** - * delete - * - * @param iGenericOrchestrationService - * @return model ID - */ - @Override - public String delete(IGenericOrchestrationService iGenericOrchestrationService) { - return null; - } - - /** - * return OrchestrationServiceForDB from database. - * - * @param id orchestration service id - * @return OrchestrationServiceForDB - */ - public OrchestrationServiceForDB getOrchestrationServiceById(String id) { - return DatabaseManager.getInstance().getOrchestrationServiceById(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/springkafka/SpringKafkaOrchestrationServiceProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/springkafka/SpringKafkaOrchestrationServiceProducerHandler.java deleted file mode 100644 index ccdb7d25..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/springkafka/SpringKafkaOrchestrationServiceProducerHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * 'orchestrationservice' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaOrchestrationServiceProducerHandler extends AProducerHandler { - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_ORCHESTRATION_SERVICE, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/VirtualObjectProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/VirtualObjectProcessor.java deleted file mode 100644 index 09d80114..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/VirtualObjectProcessor.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceprocessor.processor.virtualobject.messagequeue.consumer.VirtualObjectConsumerHandler; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * VirtualObjectConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class VirtualObjectProcessor extends AGenericProcessor { - /** - * constructor - */ - public VirtualObjectProcessor() { - - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public VirtualObjectProcessor(String id, String name) { - super(id, name); - } - - /** - * begin Handler on thread. - */ - @Override - public void process() { - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - VirtualObjectConsumerHandler consumer = new VirtualObjectConsumerHandler(i); - consumerList.add(consumer); - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (VirtualObjectConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * called method before process() - */ - @Override - public void before() { - - } - - /** - * called method after process() - */ - @Override - public void after() { - - } - -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/consumer/VirtualObjectConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/consumer/VirtualObjectConsumerHandlerFactory.java deleted file mode 100644 index 0c141659..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/consumer/VirtualObjectConsumerHandlerFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.messagequeue.consumer; - -/** - * Created by uni4love on 2017. 1. 4.. - */ -public class VirtualObjectConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaVirtualObjectConsumerHandler instance. - * - * @return SpringKafkaVirtualObjectConsumerHandler - */ - public static VirtualObjectConsumerHandler getVirtualObjectConsumerHandler(int id) { - return new VirtualObjectConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandler.java deleted file mode 100644 index 6b8b7184..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.messagequeue.producer; - -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * VirtualObjectForMQ Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class VirtualObjectProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = "virtualobject"; - - /** - * kafka producer group id by class name. - */ - private static final String GROUP_ID = VirtualObjectProducerHandler.class.getSimpleName(); - - /** - * constructor. - */ - public VirtualObjectProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandlerFactory.java deleted file mode 100644 index 8a8cb911..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandlerFactory.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.messagequeue.producer; - -/** - * SpringKafkaVirtualObjectProducerHandler factory. - * Created by uni4love on 2017. 1. 4.. - */ -public class VirtualObjectProducerHandlerFactory { - /** - * return SpringKafkaVirtualObjectProducerHandler instance. - * - * @return SpringKafkaVirtualObjectProducerHandler - */ - public static VirtualObjectProducerHandler getVirtualObjectProducerHandler(int id) { - return new VirtualObjectProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/provider/VirtualObjectProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/provider/VirtualObjectProvider.java deleted file mode 100644 index b8d075ae..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/provider/VirtualObjectProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.provider; - -import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.IVirtualObjectProvider; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -/** - * VirtualObject provider class. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class VirtualObjectProvider implements IVirtualObjectProvider { - /** - * Create - * - * @param iGenericVirtualObject - * @return ID - */ - @Override - public String create(IGenericVirtualObject iGenericVirtualObject) { - return null; - } - - /** - * Retrecive - * - * @param s - * @return M - */ - @Override - public IGenericVirtualObject retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericVirtualObject - * @return model ID - */ - @Override - public String update(IGenericVirtualObject iGenericVirtualObject) { - return null; - } - - /** - * delete - * - * @param iGenericVirtualObject - * @return model ID - */ - @Override - public String delete(IGenericVirtualObject iGenericVirtualObject) { - return null; - } - - /** - * return VirtualObjectForDB from database. - * - * @param id virtual object id - * @return VirtualObjectForDB - */ - public VirtualObjectForDB getVirtualObjectById(String id) { - return DatabaseManager.getInstance().getVirtualObjectById(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/springkafka/SpringKafkaVirtualObjectProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/springkafka/SpringKafkaVirtualObjectProducerHandler.java deleted file mode 100644 index 3c597453..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/springkafka/SpringKafkaVirtualObjectProducerHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * "contextmodel' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaVirtualObjectProducerHandler extends AProducerHandler { - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_VIRTUAL_OBJECT, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/profile/provider/ProfileProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/profile/provider/ProfileProvider.java deleted file mode 100644 index 93feeb31..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/profile/provider/ProfileProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.profile.provider; - -import com.pineone.icbms.so.interfaces.database.model.ProfileForDB; -import com.pineone.icbms.so.virtualobject.profile.IGenericProfile; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.IProfileProvider; - -import java.util.List; - -/** - * Profile provider implements. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class ProfileProvider implements IProfileProvider { - /** - * Create - * - * @param iGenericProfile - * @return ID - */ - @Override - public String create(IGenericProfile iGenericProfile) { - return null; - } - - /** - * Retreive - * - * @param s - * @return M - */ - @Override - public IGenericProfile retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericProfile - * @return model ID - */ - @Override - public String update(IGenericProfile iGenericProfile) { - return null; - } - - /** - * Delete - * - * @param iGenericProfile - * @return model ID - */ - @Override - public String delete(IGenericProfile iGenericProfile) { - return null; - } - - /** - * return ProfileForDB from database. - * - * @param contextModelSid context model id - * @param locationUri location uri - * @return ProfileForDB - */ - public List getProfileListByContextModelSidAndLocationUri(String contextModelSid, String locationUri) { - return DatabaseManager.getInstance().getProfileListByContextModelSidAndLocationUri(contextModelSid, locationUri); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/AGenericProcessRegistry.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/AGenericProcessRegistry.java deleted file mode 100644 index 2b46e9c7..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/AGenericProcessRegistry.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.registry; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; -import com.pineone.icbms.so.serviceutil.interfaces.registry.IGenericProcessorRegistry; -import com.pineone.icbms.so.util.registry.AGenericKeyValueRegistry; - -/** - * Abstract Generic serviceprocessor registry - * - * Created by uni4love on 2016. 11. 24.. - */ -abstract public class AGenericProcessRegistry - extends AGenericKeyValueRegistry - implements IGenericProcessorRegistry { - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - abstract public boolean existProcessor(String processorName); -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/DefaultProcessorRegistry.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/DefaultProcessorRegistry.java deleted file mode 100644 index c948efea..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/DefaultProcessorRegistry.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.registry; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; - -import java.util.HashMap; -import java.util.Map; - -/** - * serviceprocessor default class. - * - * Created by uni4love on 2016. 11. 24.. - */ -public class DefaultProcessorRegistry extends AGenericProcessRegistry { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new HashMap(); - } - - /** - * add a serviceprocessor. - * - * @param processor - */ - @Override - public void addProcessor(IGenericProcessor processor) { - addValue(processor.getId(), processor); - } - - /** - * return existence of serviceprocessor - * - * @param processor serviceprocessor - * @return true/false - */ - @Override - public boolean existProcessor(IGenericProcessor processor) { - return this.store.containsKey(processor.getId()); - } - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - @Override - public boolean existProcessor(String processorName) { - return this.store.containsKey(processorName); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/SequenceProcessorRegistry.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/SequenceProcessorRegistry.java deleted file mode 100644 index a46d81a6..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/SequenceProcessorRegistry.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.registry; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * serviceprocessor default class. - * - * Created by uni4love on 2016. 11. 24.. - */ -public class SequenceProcessorRegistry extends AGenericProcessRegistry { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new LinkedHashMap(); - } - - /** - * add a serviceprocessor. - * - * @param processor - */ - @Override - public void addProcessor(IGenericProcessor processor) { - addValue(processor.getName(), processor); - } - - /** - * add a serviceprocessor. - * - * @param key key - * @param processor serviceprocessor - */ - public void addProcessor(String key, IGenericProcessor processor) { - addValue(key, processor); - } - - - - /** - * return existence of serviceprocessor - * - * @param processor serviceprocessor - * @return true/false - */ - @Override - public boolean existProcessor(IGenericProcessor processor) { - return this.store.containsKey(processor.getId()); - } - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - @Override - public boolean existProcessor(String processorName) { - return this.store.containsKey(processorName); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java deleted file mode 100644 index 2c2ff5f2..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.route; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.registry.SequenceProcessorRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Process Line class. - * - * This class support for serviceprocessor, filter, rule process. - * - * Created by uni4love on 2016. 11. 24.. - */ -public class ProcessLine { - /** - * logger - */ - private Logger log = LoggerFactory.getLogger(ProcessLine.class.getClass()); - - /** - * process registry - */ - private SequenceProcessorRegistry processRegistry = new SequenceProcessorRegistry(); - - /** - * add a serviceprocessor. - * - * @param processor - */ - public void addProcessor(IGenericProcessor processor) { - this.processRegistry.addProcessor(processor); - } - - /** - * return a serviceprocessor. - * - * @param key key for a serviceprocessor - * @return serviceprocessor - */ - public IGenericProcessor getProcessor(String key) { - return this.processRegistry.getValue(key); - } - - /** - * return existence of serviceprocessor - * - * @param processor serviceprocessor - * @return true/false - */ - public boolean existProcessor(IGenericProcessor processor) { - return this.processRegistry.existProcessor(processor.getId()); - } - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - public boolean existProcessor(String processorName) { - return this.processRegistry.existProcessor(processorName); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java deleted file mode 100644 index b45982fd..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java +++ /dev/null @@ -1,237 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.route; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.context.ContextModelProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.DeviceControlProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.OrchestrationServiceProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.virtualobject.VirtualObjectProcessor; -import com.pineone.icbms.so.util.id.IdUtils; -import com.withwiz.plankton.util.StringUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; - - -/** - * 미사용 - * Process router class. - * This class is Singleton instance. - * - * Created by uni4love on 2016. 11. 24.. - */ -@Component -public final class ProcessorRouter { - /** - * logger - */ - private Logger log = LoggerFactory.getLogger(ProcessorRouter.class); - - /** - * process line - */ - private ProcessLine line = new ProcessLine(); - - /** - * serviceprocessor list, - * - * TODO: 추후 class loader를 이용하여 동적으로 구동하도록 처리 요망. - * TODO: 외부에서 inject할 수 있도록 함. - * TODO: filter class도 동일 라인에 추가 가능. - */ - static Class[] processorList = { - ContextModelProcessor.class, - OrchestrationServiceProcessor.class, - VirtualObjectProcessor.class, - DeviceControlProcessor.class - }; - - /** - * singleton instance holder - */ - private static final class SingletonHolder { - static final ProcessorRouter singleton = new ProcessorRouter(); - } - - /** - * constructor - */ - private ProcessorRouter() { - init(); - } - - /** - * return ProcessorRunner singleton instance. - * - * @return ProcessorRunner - */ - public static ProcessorRouter getInstance() { - return SingletonHolder.singleton; - } - - /** - * initialize - */ - private void init() { - //instance objects - reload(); - } - - /** - * reload environments - */ - public void reload() { - //load classes - loadClass(); - } - - /** - * load classes. - */ - private void loadClass() { - //temporary load static classes; - //serviceprocessor id is name. - for (Class clz : processorList) { - Class> cls = null; - Class[] args = new Class[]{String.class, String.class}; - try { - cls = Class.forName(clz.getName()); - Constructor constructor = cls.getConstructor(args); - //parameters: id, name - Object obj = constructor.newInstance(IdUtils.createRandomUUID(), cls.getName()); - addProcessor((IGenericProcessor) obj); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - - /** - * add a serviceprocessor to registry. - * - * @param processor serviceprocessor - */ - public void addProcessor(IGenericProcessor processor) { - this.line.addProcessor(processor); - } - - /** - * return a serviceprocessor from registry. - * - * @param key key for finding a serviceprocessor. - * @return IGenericProcessor - */ - public IGenericProcessor getProcessor(String key) { - return this.line.getProcessor(key); - } - - /** - * return existence of serviceprocessor - * - * @param processorName name - */ - public boolean existProcess(String processorName) { - return line.existProcessor(processorName); - } - - /** - * print USAGE. - */ - public static void printUsage() { - StringBuilder sb = new StringBuilder("# Usage) java -jar so-serviceprocessor.jar -P[processor1,processor2,..]\n"); - sb.append("\n= current serviceprocessor name list:\n"); - for (Class cls : processorList) { - sb.append("+- " + cls.getName() + "\n"); - } - System.out.println(sb); - } - - /** - * run processors. - * - * @param args runnable serviceprocessor name - */ - public void run(String[] args) { -// log.info("user.dir: {}", System.getProperty("user.dir")); - log.debug("arguments[{}]: {}", args.length, Arrays.stream(args).toArray()); - // serviceprocessor name list from arguments - ArrayList processorNameListFromArguments = getProcessorNameListFromArguments(args); - // - if (processorNameListFromArguments == null || !checkExistProcessorNameList(processorNameListFromArguments)) { - //usage - ProcessorRouter.printUsage(); - } else { - ProcessorRouter processRouter = ProcessorRouter.getInstance(); - for (String processorName : processorNameListFromArguments) { - AGenericProcessor processor = (AGenericProcessor)processRouter.getProcessor(processorName); - new Thread(processor).start(); - } - } - } - - /** - * run parameter("serviceprocessor class name") list. - * - * @param processorNameList serviceprocessor name list - * @return result after checking - */ - private boolean checkExistProcessorNameList(ArrayList processorNameList) { - //check serviceprocessor class - ProcessorRouter processRouter = ProcessorRouter.getInstance(); - for (String processorName : processorNameList) { - log.info("Your serviceprocessor name: {}", processorName); - if (!processRouter.existProcess(processorName)) { - log.error("Your serviceprocessor NOT exist: {}", processorName); - return false; - } - } - return true; - } - - /** - * return serviceprocessor name list from arguments. - * - * @param args arguments - * @return serviceprocessor name list - */ - private ArrayList getProcessorNameListFromArguments(String[] args) { - ArrayList processorNameList = null; - for(String arg: args) { - if (arg.startsWith("-P")) { - if(processorNameList == null) - processorNameList = new ArrayList<>(); - String filteredArgs = StringUtil.getRight(arg, "-P"); - log.debug("filteredArgs: {}", filteredArgs); - String[] processorArray = filteredArgs.split(","); - processorNameList.addAll(Arrays.asList(processorArray)); - log.debug("current processorList: {}", processorNameList); - } - } - return processorNameList; - } - - - /** - * runner test main method. - * - * usage) java -j [jar file] [serviceprocessor name] - * - * @param args serviceprocessor name - */ -// public static void main(String[] args) { -// ProcessorRouter.getInstance().run(args); -// } -} \ No newline at end of file diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java deleted file mode 100644 index f5d16556..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -/** - * cut default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultCut extends AGenericIdentity implements ICut { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java deleted file mode 100644 index a1f79ccd..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenario; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * Scenario default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenario extends AGenericIdentity implements IScenario { - - /** - * scene list - */ - List sceneList = null; - - /** - * scenario context - */ - IScenarioContext scenarioContext = null; - - /** - * constructor - */ - public DefaultScenario() { - } - - /** - * return a ScenarioContext. - * - * @return ScenarioContext - */ - @Override - public IScenarioContext getScenarioContext() { - return scenarioContext; - } - - public void setScenarioContext(IScenarioContext scenarioContext) { - this.scenarioContext = scenarioContext; - } - - /** - * return scene list. - * - * @return List - */ - @Override - public List getSceneList() { - return null; - } - - public void setSceneList(List sceneList) { - this.sceneList = sceneList; - } - - public void addScene(IScene scene) { - this.sceneList.add(scene); - } - - -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java deleted file mode 100644 index be17afab..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.util.registry.AGenericKeyValueRegistry; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * scenario context default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenarioContext extends AGenericKeyValueRegistry implements IScenarioContext { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new LinkedHashMap(); - } - - /** - * return scenario id - * - * @return scenario id - */ - @Override - public String getScenarioId() { - return this.getValue("SCENARIO_ID"); - } - - public void setScenearioId(String id) { - this.addValue("SCENARIO_ID", id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java deleted file mode 100644 index 45023136..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * scene default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScene extends AGenericIdentity implements IScene { - /** - * cut list - */ - List cutList = null; - - /** - * constructor - */ - public DefaultScene() { - } - - /** - * return cut list. - * - * @return List - */ - @Override - public List getCutList() { - return null; - } - - public void setCutList(List cutList) { - this.cutList = cutList; - } - - public void addCut(DefaultCut cut) { - this.cutList.add(cut); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java deleted file mode 100644 index 90c7ea33..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.serviceprocessor.util.devicemapper.IDeviceMapper; -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mapper. - * - * Created by uni4love on 2016. 12. 30.. - */ -public class DeviceMapper implements IDeviceMapper { - - @Override - public List getDevices(IGenericVirtualObject virtualObject) { - return null; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java deleted file mode 100644 index 63bec3c3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mappe interface. - * - * Created by uni4love on 2016. 12. 30.. - */ -public interface IDeviceMapper { - /** - * from VirtualObject. - * - * @param virtualObject - */ - List getDevices(IGenericVirtualObject virtualObject); -} diff --git a/so-serviceprocessor/src/main/resources/banner.txt b/so-serviceprocessor/src/main/resources/banner.txt deleted file mode 100644 index 6dd56601..00000000 --- a/so-serviceprocessor/src/main/resources/banner.txt +++ /dev/null @@ -1,18 +0,0 @@ - _____ -/\ __`\ __ -\ \ \/\ \ __ ____/\_\ ____ - \ \ \ \ \ /'__`\ /',__\/\ \ /',__\ - \ \ \_\ \/\ \L\.\_/\__, `\ \ \/\__, `\ - \ \_____\ \__/.\_\/\____/\ \_\/\____/ - \/_____/\/__/\/_/\/___/ \/_/\/___/ - - - ____ _____ __ __ __ -/\ _`\ __ /\ __`\ /\ \ /\ \__ /\ \__ __ -\ \,\L\_\ __ _ __ __ __/\_\ ___ __ \ \ \/\ \ _ __ ___\ \ \___ __ ___\ \ ,_\ _ __ __ \ \ ,_\/\_\ ___ ___ - \/_\__ \ /'__`\/\`'__\/\ \/\ \/\ \ /'___\ /'__`\ \ \ \ \ \/\`'__\/'___\ \ _ `\ /'__`\ /',__\ \ \//\`'__\/'__`\\ \ \/\/\ \ / __`\ /' _ `\ - /\ \L\ \/\ __/\ \ \/ \ \ \_/ \ \ \/\ \__//\ __/ \ \ \_\ \ \ \//\ \__/\ \ \ \ \/\ __//\__, `\ \ \\ \ \//\ \L\.\\ \ \_\ \ \/\ \L\ \/\ \/\ \ - \ `\____\ \____\\ \_\ \ \___/ \ \_\ \____\ \____\ \ \_____\ \_\\ \____\\ \_\ \_\ \____\/\____/\ \__\ \_\\ \__/.\_\ \__\\ \_\ \____/\ \_\ \_\ - \/_____/\/____/ \/_/ \/__/ \/_/\/____/\/____/ \/_____/\/_/ \/____/ \/_/\/_/\/____/\/___/ \/__/\/_/ \/__/\/_/\/__/ \/_/\/___/ \/_/\/_/ - - \ No newline at end of file diff --git a/so-serviceutil/src/main/resources/application.properties b/so-serviceutil/src/main/resources/application.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/so-util/build.gradle b/so-util/build.gradle index 16cc6b36..f2fcb5a0 100644 --- a/so-util/build.gradle +++ b/so-util/build.gradle @@ -66,8 +66,8 @@ dependencies { //spring-kafka compile 'org.springframework.kafka:spring-kafka:1.2.0.RELEASE' - // http - compile "com.withwiz:httpclientservice:0.1.1" + //base64 + compile group: 'commons-codec', name: 'commons-codec', version: '1.10' //compile("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootVersion}") diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java deleted file mode 100644 index 8c89b3e4..00000000 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.pineone.icbms.so.util; - -import org.apache.kafka.common.serialization.StringDeserializer; -import org.apache.kafka.common.serialization.StringSerializer; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -/** - * settings for message queue. - * Created by uni4love on 2016. 12. 16.. - */ -@Configuration -public class Settings { - /** - * broker(kafka) list - */ - @Value("${mq.broker.list}") - public String brokerList = "localhost:9092"; - - /** - * Zookeeper list - */ - @Value("${mq.zookeeper.list}") - public String zookeeperList = "localhost:2181"; - - //----------------------------- consumer configs - /** - * consumer Poll timeout - */ - @Value("${mq.consumer.pool_timeout}") - public long pollTimeout = 3000L; - - /** - * ENABLE_AUTO_COMMIT_CONFIG - */ - @Value("${mq.consumer.enable_auto_commit}") - public String enableAutoCommitConfig = "true"; - - /** - * AUTO_COMMIT_INTERVAL_MS_CONFIG - */ - @Value("${mq.consumer.auto_commit_interval_ms}") - public String autoCommitIntervalMsConfig = "1000"; - - /** - * SESSION_TIMEOUT_MS_CONFIG - */ - @Value("${mq.consumer.session_timeout_ms}") - public String sessionTimeoutMsConfig= "15000"; - - /** - * AUTO_OFFSET_RESET_CONFIG - */ - @Value("${mq.consumer.auto_offset_reset}") - public String autoOffsetResetConfig= "earliest"; - - /** - * KEY_DESERIALIZER_CLASS_CONFIG - */ - public static String KEY_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - /** - * VALUE_DESERIALIZER_CLASS_CONFIG - */ - public static String VALUE_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - //----------------------------- producer configs - /** - * ACKS_CONFIG - */ - @Value("${mq.producer.acks}") - public String acksConfig= "1"; - - /** - * RETRIES_CONFIG - */ - @Value("${mq.producer.retries}") - public int retriesConfig = 0; - - /** - * BATCH_SIZE_CONFIG - */ - @Value("${mq.producer.batch_size}") - public int batchSizeConfig= 16384; - - /** - * LINGER_MS_CONFIG - */ - @Value("${mq.producer.linger_ms}") - public int lingerMsConfig= 1; - - /** - * BUFFER_MEMORY_CONFIG - */ - @Value("${mq.producer.buffer_memory}") - public int bufferMemoryConfig= 33554432; - - /** - * KEY_SERIALIZER_CLASS_CONFIG - */ - public static String KEY_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - /** - * VALUE_SERIALIZER_CLASS_CONFIG - */ - public static String VALUE_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - - //----------------------------- common configs - /** - * kafka topic: contextmodel - */ - public static String TOPIC_CONTEXT_MODEL = "contextmodel"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_ORCHESTRATION_SERVICE = "orchestrationservice"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_COMPOSITE_VIRTUAL_OBJECT = "compositevirtualobject"; - - /** - * kafka topic: virtual object - */ - public static String TOPIC_VIRTUAL_OBJECT = "virtualobject"; - - /** - * kafka topic: devicecontrol - */ - public static String TOPIC_DEVICE_CONTROL = "devicecontrol"; - - /** - * kafka topic: logging - */ - public static String TOPIC_TRACKING = "tracking"; - - /** - * each serviceprocessor handler count - */ - public static int HANDLER_COUNT = 1; - - /** - * CONTEXTMODEL serviceprocessor handler count - */ - public int HANDLER_CONTEXTMODEL_COUNT = HANDLER_COUNT; - - /** - * ORCHESTRATIONSERVICE serviceprocessor handler count - */ - public int HANDLER_ORCHESTRATIONSERVICE_COUNT = HANDLER_COUNT; - - /** - * VIRTUALOBJECT serviceprocessor handler count - */ - public int HANDELR_VIRTUALOBJECT_COUNT = HANDLER_COUNT; - - /** - * DEVICECONTROL serviceprocessor handler count - */ - public int HANDLER_DEVICECONTROL_COUNT = HANDLER_COUNT; - - /** - * class path for class loader - */ - @Value("${so.device.driver.path}") - public String deviceDriverPath= "/"; - - public String getBrokerList() { - return brokerList; - } - - public void setBrokerList(String brokerList) { - this.brokerList = brokerList; - } - - public String getZookeeperList() { - return zookeeperList; - } - - public void setZookeeperList(String zookeeperList) { - this.zookeeperList = zookeeperList; - } - - public long getPollTimeout() { - return pollTimeout; - } - - public void setPollTimeout(long pollTimeout) { - this.pollTimeout = pollTimeout; - } - - public String getEnableAutoCommitConfig() { - return enableAutoCommitConfig; - } - - public void setEnableAutoCommitConfig(String enableAutoCommitConfig) { - this.enableAutoCommitConfig = enableAutoCommitConfig; - } - - public String getAutoCommitIntervalMsConfig() { - return autoCommitIntervalMsConfig; - } - - public void setAutoCommitIntervalMsConfig(String autoCommitIntervalMsConfig) { - this.autoCommitIntervalMsConfig = autoCommitIntervalMsConfig; - } - - public String getSessionTimeoutMsConfig() { - return sessionTimeoutMsConfig; - } - - public void setSessionTimeoutMsConfig(String sessionTimeoutMsConfig) { - this.sessionTimeoutMsConfig = sessionTimeoutMsConfig; - } - - public String getAutoOffsetResetConfig() { - return autoOffsetResetConfig; - } - - public void setAutoOffsetResetConfig(String autoOffsetResetConfig) { - this.autoOffsetResetConfig = autoOffsetResetConfig; - } - - public String getAcksConfig() { - return acksConfig; - } - - public void setAcksConfig(String acksConfig) { - this.acksConfig = acksConfig; - } - - public int getRetriesConfig() { - return retriesConfig; - } - - public void setRetriesConfig(int retriesConfig) { - this.retriesConfig = retriesConfig; - } - - public int getBatchSizeConfig() { - return batchSizeConfig; - } - - public void setBatchSizeConfig(int batchSizeConfig) { - this.batchSizeConfig = batchSizeConfig; - } - - public int getLingerMsConfig() { - return lingerMsConfig; - } - - public void setLingerMsConfig(int lingerMsConfig) { - this.lingerMsConfig = lingerMsConfig; - } - - public int getBufferMemoryConfig() { - return bufferMemoryConfig; - } - - public void setBufferMemoryConfig(int bufferMemoryConfig) { - this.bufferMemoryConfig = bufferMemoryConfig; - } - - public String getDeviceDriverPath() { - return deviceDriverPath; - } - - public void setDeviceDriverPath(String deviceDriverPath) { - this.deviceDriverPath = deviceDriverPath; - } -} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java index 9b9c5fe4..9ef955ef 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java @@ -28,13 +28,13 @@ public static String getBrokerList() { /** * Zookeeper list */ - public static String zookeeperList = "localhost:2181"; + public static String zookeeperList; // = "localhost:21811"; public static String getZookeeperList() { return zookeeperList; } - @Value("${mq.zookeeper.list}") + //@Value("${mq.zookeeper.list}") public void setZookeeperList(String _zookeeperList) { zookeeperList = _zookeeperList; } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java index 0722ca6f..460475c8 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java @@ -63,6 +63,4 @@ public static List stringDataToList(String data){ public static String base64encoding(String data){ return new String(Base64.encodeBase64(data.getBytes())); } - - } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java similarity index 55% rename from so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java rename to so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java index 84519549..9e82121d 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java @@ -1,11 +1,5 @@ package com.pineone.icbms.so.util.http; -import com.withwiz.beach.network.http.message.IHttpResponseMessage; -import com.withwiz.jellyfish.service.IGenericService; -import com.withwiz.jellyfish.service.ServiceException; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientService; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceRequestDeliveryMessage; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceResponseDeliveryMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -14,8 +8,6 @@ import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; /** * ClientService class @@ -24,162 +16,14 @@ */ @Service -public class ClientService +public class ClientServiceNoTimeout { public static final int DATA_TIMEOUT_VALUE = 90000; public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 - private final Logger log = LoggerFactory.getLogger(ClientService.class); - - /** - * request post service. - * - * @param serviceUrl - * @param body - * @return - * NOTE: URL 로 Body 내용 전송 - */ - public IHttpResponseMessage requestPostService(String serviceUrl, String body) - { - log.info("Client Service requestPostService uri " + serviceUrl); - log.info("Client Service requestPostService data " + body); - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - HashMap headerList = new HashMap(); - headerList.put("Content-Type", "application/json"); - // headerList.put("Content-Length", "238"); - - req.addValue(HttpClientService.KEY_HEADER_PARAMETERS, headerList); - req.addValue(HttpClientService.KEY_SERVICE_URL, serviceUrl); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT, 50000); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_POST); - // req.addValue(HttpClientService); - - // body data - // StringInputStream inputStream = new StringInputStream(body); - ByteArrayInputStream inputStream = new ByteArrayInputStream( - body.getBytes()); - req.addValue(HttpClientService.KEY_BODY_INPUT_STREAM, inputStream); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - IHttpResponseMessage httpResponseMessage = null; - // HttpClientService - IGenericService service = new HttpClientService(); - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - /** - * request get service. - * - * @param uri - * @return - NOTE: 외부에서 데이터를 조회하기 위함. Url 의 내용을 조회 - */ - public IHttpResponseMessage requestGetService(String uri) - { - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - req.addValue(HttpClientService.KEY_SERVICE_URL, uri); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT,DATA_TIMEOUT_VALUE); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_GET); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - - // HttpClientService - IGenericService service = new HttpClientService(); - // return IHttpResponseMessage - IHttpResponseMessage httpResponseMessage = null; - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - private IHttpResponseMessage getiHttpResponseMessage(HttpClientServiceRequestDeliveryMessage req, - HttpClientServiceResponseDeliveryMessage res, - IHttpResponseMessage httpResponseMessage, - IGenericService service) { - try - { - // execute a service - service.onService(req, res); - // get a service response - httpResponseMessage = res - .getValue(HttpClientService.KEY_HTTP_RESPONSE); - // print a response - //System.out.println(res); - } - catch (ServiceException e) - { - System.out.println("connection fail :" + e.getMessage()); - //e.printStackTrace(); - } - return httpResponseMessage; - } - - public String requestPostServiceReceiveString(String uri, String data) { - return requestPostServiceReceiveString(uri,data,false); - } - - public String requestPostServiceReceiveString(String uri, String data, boolean onlyResultValue) { - IHttpResponseMessage httpResponseMessage = requestPostService(uri, data); - String returnData = null; - if (onlyResultValue) { - returnData = String.valueOf(httpResponseMessage.getStatusCode()); - } else { - returnData = responseDataToString(httpResponseMessage); - } - return returnData; - } - - - public String requestGetServiceReceiveString(String uri) { - IHttpResponseMessage httpResponseMessage = requestGetService(uri); - String returnData = responseDataToString(httpResponseMessage); - return returnData; - } - - /** - * response Data to String. - * - * @param message - * @return String - */ - public String responseDataToString(IHttpResponseMessage message) - { - String result = null; - - BufferedReader reader = null; - try - { - reader = new BufferedReader(new InputStreamReader( - message.getBodyInputStream()), 8); - StringBuilder sb = new StringBuilder(); - String line = null; - while ((line = reader.readLine()) != null) - { - sb.append(line); - } - result = sb.toString(); - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return result; - } + private final Logger log = LoggerFactory.getLogger(ClientServiceNoTimeout.class); //======================================================================================================= public String requestPostServiceReceiveString2(String uri, String param) { diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java new file mode 100644 index 00000000..ab752483 --- /dev/null +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java @@ -0,0 +1,182 @@ +package com.pineone.icbms.so.util.http; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.io.*; +import java.net.ConnectException; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * ClientServiceTimeout class + * Created by use on 2015-10-12. + * NOTE: 외부 통신을 위해 사용 + */ + +@Service +public class ClientServiceTimeout +{ + public static final int DATA_TIMEOUT_VALUE = 90000; + + public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 + public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 + + private final Logger log = LoggerFactory.getLogger(ClientServiceTimeout.class); + + public String requestPostServiceReceiveString2(String uri, String param) { + return requestPostServiceReceiveString2(uri, param, false); + } + + public String requestPostServiceReceiveString2(String uri, String param, boolean timeOut) + { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestPostServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + //log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + conn.setRequestMethod("POST"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + OutputStream out_stream = conn.getOutputStream(); + out_stream.write( param.getBytes("UTF-8") ); + log.info("requestPostServiceReceiveString2:[{}]:[{}] ", uri, out_stream.toString()); + out_stream.flush(); + out_stream.close(); + + log.info("out_stream close.."); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + //log.info("getInputStream.."); + + InputStream is = conn.getInputStream(); + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + + String line = null; + StringBuffer buff = new StringBuffer(); + + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###1 POST Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###1 POST Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + + + public String requestGetServiceReceiveString2(String uri) { + return requestGetServiceReceiveString2(uri, false); + } + public String requestGetServiceReceiveString2(String uri, boolean timeOut) { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestGetServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + + conn.setRequestMethod("GET"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + // conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.connect(); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + + //log.info("getInputStream.."); + InputStream is = conn.getInputStream(); + + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + String line = null; + StringBuffer buff = new StringBuffer(); + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###2 GET Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###2 GET Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + +} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java index 8bff1204..548f0aad 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java @@ -30,7 +30,7 @@ public static Long createRandomLongValue() { * @param args */ public static void main(String[] args) { - System.out.println(IdUtils.createRandomUUID()); - System.out.println(IdUtils.createRandomLongValue()); + //System.out.println(IdUtils.createRandomUUID()); + //System.out.println(IdUtils.createRandomLongValue()); } } diff --git a/so-util/src/test/java/Jackson_Test.java b/so-util/src/test/java/Jackson_Test.java deleted file mode 100644 index a9f8b606..00000000 --- a/so-util/src/test/java/Jackson_Test.java +++ /dev/null @@ -1,62 +0,0 @@ -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by melvin on 2017. 4. 18.. - */ - -public class Jackson_Test { - - @Test - public void name() throws Exception { - List testObjectList = new ArrayList<>(); - - TestObject testObject1 = new TestObject("5", "5", "5"); - TestObject testObject2 = new TestObject("6", "6", "6"); - TestObject testObject3 = new TestObject("7", "7", "7"); - - testObjectList.add(testObject1); - testObjectList.add(testObject2); - testObjectList.add(testObject3); - - ObjectMapper objectMapper = new ObjectMapper(); - - // List --> String - String testObjListStr = objectMapper.writeValueAsString(testObjectList); - System.out.println("*******funcListStr******** " + testObjListStr); - - // String --> List - List testObjects = objectMapper.readValue(testObjListStr, new TypeReference>() { - }); - System.out.println("*******funcList******** " + testObjects); - - // Class --> String - TestObject testObject = testObjects.get(0); - String testObjStr = objectMapper.writeValueAsString(testObject); - System.out.println("*******funcStr******** " + testObjStr); - - // String --> Class - TestObject testClass = objectMapper.readValue(testObjStr, TestObject.class); - System.out.println("*******funcClass******** " + testClass); - System.out.println("*******funcClass.name******** " + testClass.getName()); - - - List test = new ArrayList<>(); - - test.add("testObject1"); - test.add("testObject2"); - test.add("testObject3"); - - objectMapper = new ObjectMapper(); - - // List --> String - testObjListStr = objectMapper.writeValueAsString(test); - System.out.println("*******string array******** " + testObjListStr); - } - -} - diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java index 40846e69..19ccbecf 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java @@ -12,7 +12,6 @@ import com.pineone.icbms.so.interfaces.database.ref.DataValidation; import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; import com.pineone.icbms.so.interfaces.messagequeue.model.ContextModelForMQ; -import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; import com.pineone.icbms.so.interfaces.sda.model.ContextModelForIf2; import com.pineone.icbms.so.interfaces.si.handle.DeviceManager; @@ -20,7 +19,6 @@ import com.pineone.icbms.so.util.messagequeue.producer.DefaultProducerHandler; import com.pineone.icbms.so.web.model.context.Content; import com.pineone.icbms.so.web.model.context.ContextModel; -import com.pineone.icbms.so.web.model.context.ContextModelTransFormObject; import com.pineone.icbms.so.web.model.context.ResponseMessage; import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; import com.pineone.icbms.so.web.util.ContextModelMapper2; @@ -56,34 +54,6 @@ public class ContextModelController { @Autowired DataBaseStore dataBaseStore; -// /** -// * response for request "/context/cm, HTTP-method:POST". -// * -// * @param contextModelForIf ContextModelForIf -// * @return created DeviceControlCallbackForDB id -// */ -// @RequestMapping(value = "/cm", method = RequestMethod.POST) -// public String injectContextModel(@RequestBody ContextModelForIf contextModelForIf) { -// log.debug("input:ContextModelForIf: {}", contextModelForIf); -// // create a message From ContextModelForMQ for messageQueue, publish to message queue -// // ContextModelForIf --> ContextModelForMQ -// ContextModelForMQ contextModelForMQ = ModelMapper.toContextModelForMQ(contextModelForIf); -// log.debug("converted:ContextModelForMQ: {}", contextModelForMQ); -// //object to json -// String contextModelForMqString = ModelMapper.writeJsonString(contextModelForMQ); -// log.debug("generated:ContextModelForMQ {}", contextModelForMqString); -// //context model producer handler -//// ContextModelProducerHandler producerHandler = new ContextModelProducerHandler(0); -//// Future future = producerHandler.send(contextModelForMqString); -// DefaultProducerHandler producerHandler = new DefaultProducerHandler(0, "contextmodel"); -// Future future = producerHandler.send(contextModelForMQ); -// log.debug("producer.send result: {}", future); -// producerHandler.close(); -// -// //TODO: 추후 처리 결과를 정의하여 리턴함. -// return contextModelForMqString; -// } - /** * response for request "/service/context/cm, HTTP-method:POST". * @@ -189,7 +159,7 @@ private ContextModelForMQ processContextModel(ContextModelForIf2 contextModelFor //@PostMapping(value = "/test") public void testCode(HttpServletRequest request) { - DeviceManager.testmain(null); + new DeviceManager().testmain(null); } /** @@ -296,34 +266,6 @@ public ResponseMessage emergencyContextModel(@RequestBody ContextModelForIf2 con return responseMessage; } - private DataValidation newDataValidation(){ - DataValidation dataValidation = new DataValidation(); - return dataValidation; - } - - private void inspectContextModel(ContextModel contextModel) throws DataLossException { - // - if(contextModel.getId() == null || contextModel.getContextType() == null || - contextModel.getDomainIdList() == null){ - throw new DataLossException(); - } - } - -/* - private ContextModel dataObjectToContextModel(ContextModelTransFormObject contextModelDataObject){ - if(contextModelDataObject == null) return null; - return new ContextModel(contextModelDataObject.getContextId(), contentsToStringList(contextModelDataObject.getContents()), - contextModelDataObject.getCmd(), contextModelDataObject.getTime()); - } -*/ - private List contentsToStringList(List contentsList){ - - List domains = new ArrayList<>(); - for(Content content : contentsList){ - domains.add(content.getLoc()); - } - return domains; - } public String useQueueSaveContextModel(ContextModel contextModel) { // diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java new file mode 100644 index 00000000..1ab2407f --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java @@ -0,0 +1,54 @@ +package com.pineone.icbms.so.web.interfaces.api; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import com.kastkode.springsandwich.filter.annotation.Before; +import com.kastkode.springsandwich.filter.annotation.BeforeElement; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; +import com.pineone.icbms.so.web.model.measure.ResMeasuring; +import com.pineone.icbms.so.web.service.IMeasuringService; +import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; + +@Before(@BeforeElement(BeforeTtrackingHandler.class)) +@CrossOrigin(origins = "*") +@RestController +@RequestMapping(value = "/servicemodel") +public class MeasuringController { + + @Autowired + IMeasuringService measuringService; + + @RequestMapping(value = "/measure",method = RequestMethod.POST) + @ResponseStatus(value = HttpStatus.OK) + @ResponseBody + public ResMeasuring getMeasuredData(@RequestBody ReqMeasuring req, HttpServletRequest request) { + + ResMeasuring res = new ResMeasuring(); + TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); + String sessionId = trackingEntity.getSessionId(); + res.setSessionId(sessionId); + + Object r = measuringService.getMeasuredData(req, request, trackingEntity); + if (r==null) { + String failMsg = "No service data"; + res.setResultMessage(failMsg); + res.setResultCode(404); // No Information + }else { + res.setResultMessage(r); + res.setResultCode(200); //SUCCESS + } + + return res; + } +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java index d15dd908..b9aa4b92 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java @@ -59,116 +59,6 @@ public class ProfileController { @Autowired DatabaseManager databaseManager; - /** - * response for request "/profile, HTTP-method:POST". - * scheduler가 특정 주기로 호출됨 - * - * @param profileTransFormData profile - * @return profile - */ - @RequestMapping(value = "/schedule1", method = RequestMethod.POST) - public IGenericProfile callFromScheduler(@RequestBody ProfileTransFormData profileTransFormData, HttpServletRequest request) { - - if (profileTransFormData==null) { - contextLog.warn("Input Profile is null"); - return null; - } - String inputProfileId = profileTransFormData.getId(); - contextLog.debug("Checking CM by schedule : input profile=[{}]", inputProfileId); - - ProfileForDB profileForDb = databaseManager.getProfileById(profileTransFormData.getId()); - IGenericProfile profile = ModelMapper.toProfile(profileForDb); - - SessionEntity sessionEntity = new SessionEntity(); - - if (profile==null) { - contextLog.warn("Profile is null"); - return null; - } - - IGenericContextModel contextModel = profile.getContextModel(); - if (contextModel == null) { - contextLog.warn( "contextModel is null"); - return null; - } - - String contextModelId = contextModel.getId(); - ContextModelForDB cm = databaseManager.getContextModelById(contextModelId); - String contextModelName = cm.getName(); - - TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); - String sessionId = trackingEntity.getSessionId(); - String priority = profileForDb.getPriority(); - - // grib session - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelKey(contextModelId); - sessionEntity.setContextmodelName(contextModelName); - sessionEntity.setContextmodelResult("NotHappen"); - sessionEntity.setPriorityKey(priority); - //contextLog.debug("session : {}", sessionEntity); - - // grib session profile - //SessionEntity sessionProfile = new SessionEntity(); - //sessionEntity.setId(sessionId); - sessionEntity.setProfileKey(profile.getId()); - sessionEntity.setProfileName(profile.getName()); - //contextLog.debug("session profile : {}", sessionEntity); - - databaseManager.createSessionData(sessionEntity); - - boolean isCmProceed = false; //CM 처리되었나? - - //SDA로 부터 CM발생 여부 체크 - List locationList = new SdaManager().retrieveEventLocationList(contextModelId); - - contextLog.debug("called SDA: cm={}, name={}, location={}", contextModelId, contextModelName, locationList.toString()); - - if (locationList != null && locationList.size() > 0) { - - for (String location : locationList) { - if (location.equals(profile.getLocation().getUri())) { - //scheduler 또는 에 의한 Profile 내 OS 구동임을 남겨야 함 - - ContextModelHandler contextModelHandler = new ContextModelHandler(databaseManager); - contextModelHandler.setTracking(trackingEntity); - contextModelHandler.profileHandle(profile); - isCmProceed = true; - - //sessionEntity.setContextmodelResult("Happen"); - //databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(location); - databaseManager.createSessionDataLocation(sessionLocation); - - contextLog.warn("O: result: Happen cm=[{}], Location={} , sessionId={}", contextModelId, location, sessionId); - //contextLog.debug("session location : {}", sessionLocation); - } - } - } - - //Location이 없거나 처리되지 않았을때 - if (isCmProceed == false) { - contextLog.warn("X: result: Not happened cm=[{}]", contextModelId); - - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelResult("NotHappen"); - databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(""); - databaseManager.createSessionDataLocation(sessionLocation); - - //contextLog.debug("session location : {}", sessionLocation); - } - return profile; - } - /** * response for request "/profile, HTTP-method:POST". * scheduler가 특정 주기로 호출됨 diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java index 295de4f1..128d5d94 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java @@ -25,16 +25,6 @@ @ResponseStatus(value = HttpStatus.OK) public class SessionController { -// @Autowired -// SessionStore sessionStore; -// -// @RequestMapping(value = "/{number}", method = RequestMethod.GET) -// @ResponseStatus(value = HttpStatus.OK) -// public List retrieveSessionData(@PathVariable int number){ -// List sessionList = sessionStore.retrieveRecentlyDataList(number); -// return sessionToTransFormObject(sessionList); -// } - @Autowired //TrackingDao trackingDao; SessionDao sessionDao; @@ -86,8 +76,10 @@ public List retrieveSessionData(@PathVariable Integer nu sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(entity.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", entity.getVirtualobjectResult()); - - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", entity.getDeviceResult()); @@ -145,7 +137,9 @@ public SessionTransFormObject retrieveSessionDataOne(@PathVariable String sessio sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(sessionDataDb.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", sessionDataDb.getVirtualobjectResult()); - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", sessionDataDb.getDeviceResult()); diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java new file mode 100644 index 00000000..257e98fa --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java @@ -0,0 +1,27 @@ +package com.pineone.icbms.so.web.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) +public class MeasuringData { + + @Getter@Setter + private String devId ; + + @Getter@Setter + private String devName ; + + @Getter@Setter + private String devTypeDesc; + + @Getter@Setter + private String aspectName; + + @Getter@Setter + private String measuringValue; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java new file mode 100644 index 00000000..a90b4164 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java @@ -0,0 +1,21 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ReqMeasuring { + @Getter@Setter + @JsonProperty("serviceName") + String serviceName; + + @Getter@Setter + @JsonProperty("location") + String location; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java new file mode 100644 index 00000000..a5921508 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java @@ -0,0 +1,26 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ResMeasuring { + @Getter@Setter + @JsonProperty("resultCode") + Integer resultCode; + + @Getter@Setter + @JsonProperty("resultMessage") + Object resultMessage; + + @Getter@Setter + @JsonProperty("sessionId") + String sessionId; +} + diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java new file mode 100644 index 00000000..da096394 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java @@ -0,0 +1,12 @@ +package com.pineone.icbms.so.web.service; + +import javax.servlet.http.HttpServletRequest; + +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +public interface IMeasuringService { + + Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity); + +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java new file mode 100644 index 00000000..a0d60a2c --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java @@ -0,0 +1,192 @@ +package com.pineone.icbms.so.web.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.pineone.icbms.so.interfaces.database.dao.OrchestrationServiceDao; +import com.pineone.icbms.so.interfaces.database.model.DeviceTypeForDB; +import com.pineone.icbms.so.interfaces.database.model.LocationForDB; +import com.pineone.icbms.so.interfaces.database.model.MeasuringVoForDB; +import com.pineone.icbms.so.interfaces.database.model.OrchestrationServiceForDB; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; +import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; +import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; +import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; +import com.pineone.icbms.so.web.model.MeasuringData; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +import lombok.Getter; +import lombok.Setter; + +@Service +public class MeasuringService implements IMeasuringService { + @Autowired + //IDataBaseStore dataBaseStore; + DataBaseStore dataBaseStore; + + //@Autowired + //protected DatabaseManager databaseManager; + + @Autowired + OrchestrationServiceDao orchestrationServiceDao; + + @Getter @Setter + TrackingEntity tracking; + + protected Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity) { + + //입력 파라미터 + String locId = req.getLocation(); //설치 위치 + String serviceName = req.getServiceName(); //OS 이름 + + //설치 장소 + LocationForDB locForDB = dataBaseStore.getLocationById(locId); + String locationUri = locForDB.getUri(); + String locName = locForDB.getName(); + + + //1) OS Name으로 osId얻기 + OrchestrationServiceForDB param = new OrchestrationServiceForDB(); + param.setName(serviceName); + + List osForDbList = orchestrationServiceDao.retrieve(param); + if (osForDbList==null || osForDbList.size()==0) { //일치되는 자료 없음 + log.error("Service Info ({}) not found", serviceName); //orchestration_service : name + return null; + } + OrchestrationServiceForDB osForDb = osForDbList.get(0); + String osId = osForDb.getId(); + + //2) os id 로 MeasuringVoForDB 목록을 조회한다 + // osId로 rule_body/rule_item에서 vo list 얻기 : (rule_item의 functionality_id가 FUNCTIONALITY_TYPE_MEASURING인 값만 선택) + // cvo_type이 NONDEVICE_CVO인 경우에는 noncvo테이블을 참조하여 확장 + log.debug("getRuleBodyListByOsId : {}", osId); + List measuringVoForDBList = dataBaseStore.getMeasuringVoList(osId); + + // 측정데이타를 저장할 변수 생성 + List measuringDataList = new ArrayList<>(); + + //3) MeasuringVoForDB의 item별로 동작 + for (MeasuringVoForDB measuringVoItem:measuringVoForDBList) { + + String cvoBaseId = measuringVoItem.getBaseCvoId(); + String cvoType = measuringVoItem.getCvoType(); + + // BaseCvoId 부터 유효 VO 목록을 가져온다. + List validVoList = dataBaseStore.getVirtualObjectListByCompositeVirtualObjectId(cvoBaseId); + if (validVoList.size()==0) { + log.error("Not exist vo list by cvoBase={}", cvoBaseId); + continue; + } + String vId = measuringVoItem.getVoId(); + String aspectUri = null; + String voDesc = null; + + //VO값이 유효한 Vo인지 검사한다. + for (VirtualObjectForDB validVo:validVoList) { + if (vId.equals(validVo.getId())){ + aspectUri = validVo.getAspectUri(); //첫번째 VO만 참조하여 URI를 가져옴 + voDesc = validVo.getDescription(); + break; + } + } + + //유효하지 않으면 + if (aspectUri == null ) { //SKIP + log.error("Not exist aspectUri by list by vId={}", vId); + continue; + } + + // 4) cvo_type별로 sda에서 값 읽기 + List contentList = null; + //4-1) CVO_TYPE_DEVICETYPE or CVO_TYPE_DEVICETYPE_ASPECT + if (cvoType.equals("CVO_TYPE_DEVICETYPE") || cvoType.equals("CVO_TYPE_DEVICETYPE_ASPECT")) { + String physicalDeviceTypeId = measuringVoItem.getPhysicalDeviceTypeId(); + + //PysicalDeviceTypeUri + DeviceTypeForDB typeDb = dataBaseStore.retrieveDeviceTypeById(physicalDeviceTypeId); + if (typeDb==null) { + log.error("error : Device Type info is not exist : physicalDeviceTypeId={}", physicalDeviceTypeId); + continue; + } + String physicalDeviceTypeUri = typeDb.getPhysicalDeviceTypeUri(); + + contentList = new SdaManager().getMeasuringValueByLocDeviceTypeAspect(locationUri, physicalDeviceTypeUri, aspectUri); + } + //4-2) CVO_TYPE_ASPECT + else if (cvoType.equals("CVO_TYPE_ASPECT")) { + + contentList = new SdaManager().getMeasuringValueByLocAspect(locationUri, aspectUri); + } + //4-3) CVO_TYPE_DEVICEID + else if (cvoType.equals("CVO_TYPE_DEVICEID")) { + + String deviceUri = measuringVoItem.getDeviceId(); + contentList = new SdaManager().getMeasuringValueByDevIdAspect(deviceUri, aspectUri); + + } else { + // SKIP + } + + if (contentList != null) { + for (ContextModelContent contentItem:contentList) { + + MeasuringData md = new MeasuringData(); + + md.setDevId(contentItem.getDeviceUri()); + md.setDevName(contentItem.getDeviceName()); + md.setDevTypeDesc(contentItem.getDeviceTypeDesc()); + md.setAspectName(voDesc); + md.setMeasuringValue(contentItem.getValue()); + + measuringDataList.add(md); + } + } + } + +/* + String contextModelId="measuring"; + String contextModelName="Measureing"; + + setTracking((TrackingEntity) request.getSession().getAttribute("tracking")); + String sessionId = trackingEntity.getSessionId(); + + // grib session + SessionEntity sessionEntity = new SessionEntity(); + sessionEntity.setId(sessionId); + sessionEntity.setContextmodelKey(contextModelId); + sessionEntity.setContextmodelName(contextModelName); + sessionEntity.setContextmodelResult("NotHappen"); + sessionEntity.setProfileName(serviceName); + //sessionEntity.setPriorityKey("LOW"); + log.debug("session : {}", sessionEntity); + dataBaseStore.createSessionData(sessionEntity); + + + // grib session location + SessionEntity sessionLocation = new SessionEntity(); + sessionLocation.setId(sessionId); + sessionLocation.setLocationId(locationUri); + log.debug("session location : {}", sessionLocation); + try { + dataBaseStore.createSessionDataLocation(sessionLocation); + }catch(Exception e) { + log.error("Error createSessionDataLocation : error={},\n sessionLocation={}", e.getMessage(), sessionLocation); + } +*/ + + return measuringDataList; + } + +}
- * Created by uni4love on 2017. 1. 23. - */ -public class SdaClient { - /** - * retreive function list. - * - * @param locationUri location uri - * @return function list - */ - public List retreiveFunctionlaityListByLocation(String locationUri) { - //implements.. - return null; - } - - /** - * retreive aspect. - * - * @param functionUri function uri - * @return aspect - */ - public IGenericAspect retreiveAspectByFunction(String functionUri) { - //implements.. - return null; - } - - /** - * retreive unit. - * - * @param aspectUri aspect uri - * @return unit - */ - public IGenericUnit retreiveUnit(String aspectUri) { - //implements.. - return null; - } - - /** - * retreive devicemapper list. - * - * @param functionUri function uri - * @param locationUri location uri - * @return devicemapper list - */ - public List retreiveDeviceList(String functionUri, String locationUri) { - //implements.. - return null; - } - - /** - * retreive operation list. - * - * @param deviceUri devicemapper uri - * @return operation list - */ - public List retreiveOperationList(String deviceUri) { - //implements.. - return null; - } - - /** - * retreive control values. - * - * @param functionUri function - * @param aspect aspect - * @param locationUri location uri - * @param deviceUri device uri - * @return List - */ - public List retreiveDeviceControlValues(String functionUri, String aspect, String locationUri, String deviceUri) { - return null; - } -} diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaManager.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaManager.java index 09475d49..ccf3a025 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaManager.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/SdaManager.java @@ -6,9 +6,8 @@ import com.pineone.icbms.so.interfaces.sda.ref.DataNotExistException; import com.pineone.icbms.so.interfaces.sda.ref.SDAException; import com.pineone.icbms.so.interfaces.sda.ref.SdaAddressStore; -import com.pineone.icbms.so.util.http.ClientService; +import com.pineone.icbms.so.util.http.ClientServiceNoTimeout; import com.pineone.icbms.so.util.itf.address.AddressCollector; -import com.withwiz.beach.network.http.message.IHttpResponseMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -34,11 +33,12 @@ public class SdaManager implements ISdaManager { */ protected Logger log = LoggerFactory.getLogger(getClass()); - ClientService clientService = new ClientService(); + //ClientService clientService = new ClientService(); + ClientServiceNoTimeout clientServiceNoTimeout = new ClientServiceNoTimeout(); AddressCollector addressCollector = new AddressCollector(); ObjectMapper objectMapper = new ObjectMapper(); - // 상황의 발생 여부 조회 + // 상황의 발생 여부 조회 (발생 위치 리턴) - 미사용 @Override public List retrieveEventLocationList(String contextModelId) { // @@ -47,7 +47,7 @@ public List retrieveEventLocationList(String contextModelId) { try { //IHttpResponseMessage message = clientService.requestGetService( - String message = clientService.requestGetServiceReceiveString2( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + contextModelId + SdaAddressStore.SEPARATOR_WITH_COMMA); contentList = getContextModelContents(message); } catch (IOException e) { @@ -68,7 +68,7 @@ public List retrieveEventLocationList(String contextModelId) { return locationList; } - // 상황의 발생 여부 조회 + // 상황의 발생 여부 조회 (발생 정보 리턴 - location, Id, Mac) @Override public List retrieveEventList(String contextModelId) { @@ -76,7 +76,7 @@ public List retrieveEventList(String contextModelId) { try { //IHttpResponseMessage message = clientService.requestGetService( - String message = clientService.requestGetServiceReceiveString2( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + contextModelId + SdaAddressStore.SEPARATOR_WITH_COMMA); contentList = getContextModelContents(message); } catch (IOException e) { @@ -92,7 +92,8 @@ public List retrieveEventList(String contextModelId) { return contentList; } - + +/* // 특정 위치(location)에 존재하는 device Function 목록 조회 @Override public List retrieveFunctionListInLocation(String locationId) { @@ -317,69 +318,13 @@ public List retrieveListByContextModelId(String contextModelId) { return resultList; } +*/ - @Override - public List retrieveAspectList() { - // - List list = new ArrayList(); - List contentList = new ArrayList<>(); - - try { - IHttpResponseMessage message = clientService.requestGetService( - addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + - SdaAddressStore.CM_ASPECT_LIST + SdaAddressStore.SEPARATOR_WITH_COMMA); - contentList = getContextModelContents(message); - } catch (IOException e) { - e.printStackTrace(); - } catch (SDAException e) { -// e.printStackTrace(); - } - - for (ContextModelContent contextModelContent : contentList) { - AspectForIf addItam = new AspectForIf(); - addItam.setAspect(contextModelContent.getAspectUri()); - addItam.setLabel(contextModelContent.getLabel()); - list.add(addItam); - } - log.debug("Aspect : " + list); - return list; - } - - @Override - public List retrieveFunctionList() { - // - List functionList = new ArrayList(); - List contentList = new ArrayList<>(); + //public static final String CM_DD_DEVICE_LIST = "cm-dd-device-list"; //1) by location, aspect, functionality + //public static final String CM_DD_DEVICETYPE_LIST = "cm-dd-devicetype-device-list"; //2) by location, deviceType, aspect, functionality + //public static final String CM_DD_COMMAND_VALUE = "cm-dd-command-value"; //3) by id, aspect, cmd + //public static final String CM_DD_ASPECT_ACTION_VALUE = "cm-dd-aspect-action-value"; //4) by id, aspect, functionality - try { - IHttpResponseMessage message = clientService.requestGetService( - addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + - SdaAddressStore.CM_FUNCTION_LIST + SdaAddressStore.SEPARATOR_WITH_COMMA); - contentList = getContextModelContents(message); - } catch (IOException e) { - e.printStackTrace(); - } catch (SDAException e) { -// e.printStackTrace(); - } - - for (ContextModelContent contextModelContent : contentList) { - FunctionForIf addItam = new FunctionForIf(); - addItam.setFunction(contextModelContent.getFunctionUri()); - addItam.setLabel(contextModelContent.getLabel()); - functionList.add(addItam); - - } - log.debug("Function : " + functionList); - return functionList; - } - - - /* - public static final String CM_DD_DEVICE_LIST = "cm-dd-device-list"; //1) by location, aspect, functionality - public static final String CM_DD_DEVICETYPE_LIST = "cm-dd-devicetype-device-list"; //2) by location, deviceType, aspect, functionality - public static final String CM_DD_COMMAND_VALUE = "cm-dd-command-value"; //3) by id, aspect, cmd - public static final String CM_DD_ASPECT_ACTION_VALUE = "cm-dd-aspect-action-value"; //4) by id, aspect, functionality - */ // 1)cm-dd-device-list(Loc,Aspect,Func) 을 이용한 Device 목록 조회 @Override public List getDeviceListByLoc_Aspect_Func(String locationUri, String aspectUri, String functionalityUri) { @@ -388,7 +333,8 @@ public List getDeviceListByLoc_Aspect_Func(String locationUri, String as List contentList = new ArrayList<>(); try { - IHttpResponseMessage message = clientService.requestGetService( + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + SdaAddressStore.CM_DD_DEVICE_LIST + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + locationUri + "," + aspectUri + "," + functionalityUri); @@ -419,7 +365,8 @@ public List getDeviceListByLoc_DeviceType_Aspect_Func(String locationUri List contentList = new ArrayList<>(); try { - IHttpResponseMessage message = clientService.requestGetService( + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + SdaAddressStore.CM_DD_DEVICETYPE_LIST + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + locationUri + "," + deviceType + "," + aspectUri + ","+ functionalityUri); @@ -448,7 +395,8 @@ public String getCommandValueById_Aspect_Command(String deviceId, String aspectU List contentList = new ArrayList<>(); try { - IHttpResponseMessage message = clientService.requestGetService( + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + SdaAddressStore.CM_DD_COMMAND_VALUE + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + deviceId + "," + aspectUri + ","+ command); @@ -478,7 +426,8 @@ public ContextModelContent getAspectValueById_Aspect_Function(String deviceId, S List contentList = new ArrayList<>(); try { - IHttpResponseMessage message = clientService.requestGetService( + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + SdaAddressStore.CM_DD_ASPECT_ACTION_VALUE + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + deviceId + "," + aspectUri + ","+ functionUri); @@ -498,7 +447,102 @@ public ContextModelContent getAspectValueById_Aspect_Function(String deviceId, S return content; } - // get Data + // 5)cm-dd-measuring-loc_dtype_aspect (Loc, Type, Aspect)을 이용한 Measuring + // public static final String CM_DD_MEASURING_BY_LOC_DTYPE_ASPECT = "cm-dd-measuring-loc_dtype_aspect"; //5) by location, deviceType, aspect + @Override + public List getMeasuringValueByLocDeviceTypeAspect(String locationUri, String deviceType, String aspectUri) { + + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_DD_MEASURING_BY_LOC_DTYPE_ASPECT + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + + locationUri + "," + deviceType + "," + aspectUri); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + String info = "getMeasuringValueByLocDeviceTypeAspect::contentList(by " + locationUri + ", " + deviceType + ", " + aspectUri +")="; + if (contentList == null || contentList.isEmpty()) { + log.debug("info : " + info + " is empty"); + } + else { + for (ContextModelContent contextModelContent : contentList) { + log.debug(" - " + contextModelContent.getDeviceName() +"=" + contextModelContent.getValue() ); + } + } + return contentList; + } + + // 6) cm-dd-measuring-loc_aspect (Loc, Aspect)을 이용한 Measuring + // public static final String CM_DD_MEASURING_BY_LOC_ASPECT = "cm-dd-measuring-loc_aspect"; //6) by location, aspect + @Override + public List getMeasuringValueByLocAspect(String locationUri, String aspectUri) { + + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_DD_MEASURING_BY_LOC_ASPECT + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + + locationUri + "," + aspectUri); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + String info = "getMeasuringValueByLocAspect:: contentList(by " + locationUri + ", " + aspectUri +")="; + if (contentList == null || contentList.isEmpty()) { + log.debug("info : " + info + " is empty"); + } + else { + for (ContextModelContent contextModelContent : contentList) { + log.debug(" - " + contextModelContent.getDeviceName() +"=" + contextModelContent.getValue() ); + } + } + return contentList; + } + + // 7) cm-dd-measuring-devid_aspect (devId, Aspect)을 이용한 Measuring + // public static final String CM_DD_MEASURING_BY_DEVID_ASPECT = "cm-dd-measuring-devid_aspect"; //7) by devId, aspect + @Override + public List getMeasuringValueByDevIdAspect(String devUri, String aspectUri) { + + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_DD_MEASURING_BY_DEVID_ASPECT + SdaAddressStore.SEPARATOR_WITHOUT_COMMA + + devUri + "," + aspectUri); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + String info = "getMeasuringValueByDevIdAspect:: contentList(by " + devUri + ", " + aspectUri +")="; + if (contentList == null || contentList.isEmpty()) { + log.debug("info : " + info + " is empty"); + } + else { + for (ContextModelContent contextModelContent : contentList) { + log.debug(" - " + contextModelContent.getDeviceName() +"=" + contextModelContent.getValue() ); + } + } + return contentList; + } + + //================================ +/* + // get Data (old) private List getContextModelContents(IHttpResponseMessage message) throws IOException, DataNotExistException { if (message.getStatusCode() == 200) { // System.out.println(message.getBodyByteArray().toString()); @@ -511,8 +555,8 @@ private List getContextModelContents(IHttpResponseMessage m throw new DataNotExistException(); } } - - // get Data +*/ + // get Data (new) private List getContextModelContents(String message) throws IOException, DataNotExistException { if (message != null) { // System.out.println(message.getBodyByteArray().toString()); @@ -524,4 +568,63 @@ private List getContextModelContents(String message) throws throw new DataNotExistException(); } } + + //================================ + @Override + public List retrieveFunctionList() { + // + List functionList = new ArrayList(); + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_FUNCTION_LIST + SdaAddressStore.SEPARATOR_WITH_COMMA); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + + for (ContextModelContent contextModelContent : contentList) { + FunctionForIf addItam = new FunctionForIf(); + addItam.setFunction(contextModelContent.getFunctionUri()); + addItam.setLabel(contextModelContent.getLabel()); + functionList.add(addItam); + + } + log.debug("Function : " + functionList); + return functionList; + } + + @Override + public List retrieveAspectList() { + // + List list = new ArrayList(); + List contentList = new ArrayList<>(); + + try { + //IHttpResponseMessage message = clientService.requestGetService( + String message = clientServiceNoTimeout.requestGetServiceReceiveString2( + addressCollector.getServerAddress(AddressCollector.SDA_SERVER) + + SdaAddressStore.CM_ASPECT_LIST + SdaAddressStore.SEPARATOR_WITH_COMMA); + contentList = getContextModelContents(message); + } catch (IOException e) { + e.printStackTrace(); + } catch (SDAException e) { +// e.printStackTrace(); + } + + for (ContextModelContent contextModelContent : contentList) { + AspectForIf addItam = new AspectForIf(); + addItam.setAspect(contextModelContent.getAspectUri()); + addItam.setLabel(contextModelContent.getLabel()); + list.add(addItam); + } + log.debug("Aspect : " + list); + return list; + } + } diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/itf/ISdaManager.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/itf/ISdaManager.java index 1f661695..0b962e64 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/itf/ISdaManager.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/handle/itf/ISdaManager.java @@ -16,7 +16,7 @@ public interface ISdaManager { // 상황 조회시 사용 (Location, Device, LocationList) List retrieveEventList(String contextModelId); - +/* // 특정 위치(location)에 존재하는 device Function 목록 조회 List retrieveFunctionListInLocation(String locationId); @@ -35,13 +35,14 @@ public interface ISdaManager { // Sensor Status (측정값) 조회 String retrieveSensorValue(String deviceId); - /* 전체 펑션 목록 */ + // 전체 펑션 목록 List retrieveListByContextModelId(String contextModeId); - /* 전체 aspect 목록 */ + */ + // 전체 aspect 목록 List retrieveAspectList(); - /* 전체 펑션 목록 */ + // 전체 펑션 목록 List retrieveFunctionList(); //1)cm-dd-device-list(Loc,Aspect,Func) 을 이용한 Device 목록 조회 @@ -57,6 +58,13 @@ List getDeviceListByLoc_DeviceType_Aspect_Func(String locationUri, Strin // 4)cm-dd-aspect-action-value (id, aspect, functionality) 을 이용한 aspect Value 조회 ContextModelContent getAspectValueById_Aspect_Function(String deviceId, String aspectUri, String functionUri); + // 5)cm-dd-measuring-loc_dtype_aspect (Loc, Type, Aspect)을 이용한 Measuring + List getMeasuringValueByLocDeviceTypeAspect(String locationUri, String deviceType, String aspectUri); + + // 6) cm-dd-measuring-loc_aspect (Loc, Aspect)을 이용한 Measuring + List getMeasuringValueByLocAspect(String locationUri, String aspectUri); + // 7) cm-dd-measuring-devid_aspect (devId, Aspect)을 이용한 Measuring + List getMeasuringValueByDevIdAspect(String devUri, String aspectUri); } diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/ContextModelContent.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/ContextModelContent.java index b19ba4e2..006979e2 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/ContextModelContent.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/ContextModelContent.java @@ -1,10 +1,10 @@ package com.pineone.icbms.so.interfaces.sda.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import lombok.Setter; -import lombok.ToString; /** * Context contents model. @@ -12,6 +12,7 @@ * Created by uni4love on 2017. 4. 4.. */ @JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) public class ContextModelContent { /** * location list @@ -41,6 +42,20 @@ public class ContextModelContent { @JsonProperty("dev") String deviceUri; + /** + * Device Name + */ + @Getter@Setter + @JsonProperty("dev_name") + String deviceName; + + /** + * Device Type comment + */ + @Getter@Setter + @JsonProperty("dev_type_desc") + String deviceTypeDesc; + /** * Serial Id */ diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/FunctionForIf.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/FunctionForIf.java index 10bfd908..84dcbea2 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/FunctionForIf.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/model/FunctionForIf.java @@ -1,7 +1,6 @@ package com.pineone.icbms.so.interfaces.sda.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.pineone.icbms.so.virtualobject.common.AGenericIdNameOwner; import lombok.Getter; import lombok.Setter; import lombok.ToString; diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/DataNotExistException.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/DataNotExistException.java index 4263de17..73286dd8 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/DataNotExistException.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/DataNotExistException.java @@ -5,7 +5,9 @@ */ public class DataNotExistException extends SDAException { - public DataNotExistException(){ + private static final long serialVersionUID = 1L; + + public DataNotExistException(){ super("DataNotExist Exception."); } } diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SDAException.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SDAException.java index 16f48357..0739b4be 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SDAException.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SDAException.java @@ -5,7 +5,9 @@ */ public class SDAException extends Exception{ - public SDAException(){ + private static final long serialVersionUID = -6591909415556966767L; + + public SDAException(){ super("SDA Exception."); } diff --git a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SdaAddressStore.java b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SdaAddressStore.java index 2e57d5ec..bcb5424a 100644 --- a/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SdaAddressStore.java +++ b/so-if-sda/src/main/java/com/pineone/icbms/so/interfaces/sda/ref/SdaAddressStore.java @@ -38,4 +38,13 @@ public class SdaAddressStore { /* 전체 펑셔널리티 목록 */ public static final String CM_FUNCTIONALITY_LIST = "cm-functionality-list"; + // 5) cm-dd-measuring-loc_dtype_aspect (Loc, DeviceType, Aspect)을 이용한 Measuring + public static final String CM_DD_MEASURING_BY_LOC_DTYPE_ASPECT = "cm-dd-measuring-loc_dtype_aspect"; + + // 6) cm-dd-measuring-loc_aspect (Loc, Aspect)을 이용한 Measuring + public static final String CM_DD_MEASURING_BY_LOC_ASPECT = "cm-dd-measuring-loc_aspect"; + + // 7) cm-dd-measuring-devid_aspect (devId, Aspect)을 이용한 Measuring + public static final String CM_DD_MEASURING_BY_DEVID_ASPECT = "cm-dd-measuring-devid_aspect"; + } diff --git a/so-if-si/conf/logback-if-si.xml b/so-if-si/conf/logback-if-si.xml deleted file mode 100644 index b670bf83..00000000 --- a/so-if-si/conf/logback-if-si.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/handle/DeviceManager.java b/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/handle/DeviceManager.java index f80e0cd8..5ddbf3ec 100644 --- a/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/handle/DeviceManager.java +++ b/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/handle/DeviceManager.java @@ -165,7 +165,7 @@ private DeviceControlMessage deviceDataConversion(String deviceId, String comman } - public static void testmain(String[] args) { + public void testmain(String[] args) { DeviceManager dm = new DeviceManager(); String commandId = ClientProfile.SI_COMMAND_ID + System.nanoTime(); String aspectId; @@ -175,30 +175,30 @@ public static void testmain(String[] args) { DeviceControlMessage dcMsg; aspectId = "http://www.iotoasis.org/ontology/electronicpower-aspect"; - System.out.println(aspectId); + log.info(aspectId); dcMsg = dm.deviceDataConversion("deviceId",commandId , aspectId, controlValue); - System.out.println(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); + log.info(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); aspectId = "electronicpower-aspect"; - System.out.println(aspectId); + log.info(aspectId); dcMsg = dm.deviceDataConversion("deviceId",commandId , aspectId, controlValue); - System.out.println(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); + log.info(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); aspectId = "/electronicpower-aspect"; - System.out.println(aspectId); + log.info(aspectId); dcMsg = dm.deviceDataConversion("deviceId",commandId , aspectId, controlValue); - System.out.println(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); + log.info(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); aspectId = ""; - System.out.println(aspectId); + log.info(aspectId); dcMsg = dm.deviceDataConversion("deviceId",commandId , aspectId, controlValue); - System.out.println(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); + log.info(" case"+Integer.toString(count++)+"==> "+dcMsg.toString()); // String deviceUri = "/herit-in/herit-cse/ONDB_BeamProjector01_001"; aspectId = "http://www.iotoasis.org/ontology/lecture-aspect"; String deviceCommand="1"; ResultMessage resultMessage = dm.deviceExecute(commandId, deviceUri, aspectId, deviceCommand); - System.out.println(resultMessage); + log.info(resultMessage.toString()); } } diff --git a/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/proxy/DeviceSIProxy.java b/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/proxy/DeviceSIProxy.java index 9af81964..54b17ace 100644 --- a/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/proxy/DeviceSIProxy.java +++ b/so-if-si/src/main/java/com/pineone/icbms/so/interfaces/si/proxy/DeviceSIProxy.java @@ -9,7 +9,7 @@ import com.pineone.icbms.so.interfaces.si.ref.SIAddressStore; import com.pineone.icbms.so.interfaces.si.ref.ClientProfile; import com.pineone.icbms.so.util.conversion.DataConversion; -import com.pineone.icbms.so.util.http.ClientService; +import com.pineone.icbms.so.util.http.ClientServiceTimeout; import com.pineone.icbms.so.util.itf.address.AddressCollector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +23,7 @@ public class DeviceSIProxy implements DeviceControlProxy { */ protected Logger log = LoggerFactory.getLogger(getClass()); - private ClientService clientService = new ClientService(); + private ClientServiceTimeout clientServiceTimeout = new ClientServiceTimeout(); private ObjectMapper mapper = new ObjectMapper(); AddressCollector addressCollector = new AddressCollector(); @@ -36,7 +36,7 @@ public ResultMessage deviceControlRequest(String requestUrl, DeviceControlMessag // String requestBody = new Gson().toJson(deviceControlMessage); log.debug("deviceControlRequest : requestBody {}", requestBody); - String responseData = clientService.requestPostServiceReceiveString2(requestUrl, requestBody, true); //true=timeout + String responseData = clientServiceTimeout.requestPostServiceReceiveString2(requestUrl, requestBody, true); //true=timeout log.debug("deviceControlRequest : responseData {}", responseData); ResultMessage resultMessage = parsingResultMessage(responseData); @@ -49,7 +49,7 @@ public ResultMessage lwm2mDeviceControlRequest(String requestUrl, DeviceControlM String lwm2mCon = DataConversion.base64encoding(new Gson().toJson(lwm2MDeviceControl)); deviceControlMessage.setCon(lwm2mCon); String requestBody = new Gson().toJson(deviceControlMessage); - String responseData = clientService.requestPostServiceReceiveString2(requestUrl, requestBody, true); //true=timeout + String responseData = clientServiceTimeout.requestPostServiceReceiveString2(requestUrl, requestBody, true); //true=timeout ResultMessage resultMessage = parsingResultMessage(responseData); return resultMessage; } @@ -64,7 +64,7 @@ public String deviceSubscriptionRequest(String deviceUri, String commandId) { String requestBody = new Gson().toJson(deviceSubscriptionData); - String responseData = clientService.requestPostServiceReceiveString2(addressCollector.getServerAddress(AddressCollector.SI_SERVER) + SIAddressStore.SI_SUBSCRIPTION_URI, requestBody); + String responseData = clientServiceTimeout.requestPostServiceReceiveString2(addressCollector.getServerAddress(AddressCollector.SI_SERVER) + SIAddressStore.SI_SUBSCRIPTION_URI, requestBody); // ResponseData{ "code" : "2000", "message" : "", "content" : "" } ResultMessage resultMessage = parsingResultMessage(responseData); return resultMessage.getCode(); @@ -77,7 +77,7 @@ public String deviceSubscriptionReleaseRequest(String deviceUri) { deviceSubscriptionData.set_uri(deviceUri); String requestBody = new Gson().toJson(deviceSubscriptionData); - String responseData = clientService.requestPostServiceReceiveString2(addressCollector.getServerAddress(AddressCollector.SI_SERVER) + SIAddressStore.SI_SUBSCRIPTION_RELEASE_URI, requestBody); + String responseData = clientServiceTimeout.requestPostServiceReceiveString2(addressCollector.getServerAddress(AddressCollector.SI_SERVER) + SIAddressStore.SI_SUBSCRIPTION_RELEASE_URI, requestBody); ResultMessage resultMessage = parsingResultMessage(responseData); return resultMessage.getCode(); } diff --git a/so-if-si/src/test/java/DeviceControlTest.java b/so-if-si/src/test/java/DeviceControlTest.java deleted file mode 100644 index 8ce3545f..00000000 --- a/so-if-si/src/test/java/DeviceControlTest.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Created by melvin on 2017. 4. 5.. - */ -public class DeviceControlTest { -// @Test -// public void DeviceControl() throws Exception { -// -// IDeviceManager deviceManager = new DeviceManager(); -// deviceManager.deviceExecute("/herit-in/herit-cse/ONDB_BeamProjector01_001", "1"); -// } - -// @Test -// public void name() throws Exception { -// long a = 1477283378273L; -// System.out.println(new SimpleDateFormat("YYYY-MM-dd HH:mm:ss").format(a)); -// } -} diff --git a/so-scheduler/conf/application-dev.properties b/so-scheduler/conf/application-dev.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/so-scheduler/conf/logback-sch.xml b/so-scheduler/conf/logback-sch.xml deleted file mode 100644 index 163a8518..00000000 --- a/so-scheduler/conf/logback-sch.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerManager.java b/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerManager.java index e1a5e37d..6add5b34 100644 --- a/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerManager.java +++ b/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerManager.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; import java.util.List; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -203,10 +204,12 @@ public List executedJobList() { if (profileForDB != null) { profileList.add(profileForDB); } - } + } + SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String nextFireTimeStr = sdf.format(nextFireTime); log.debug(" === [jobName] : " + jobName + " [groupName] : " + jobGroup - + " - " + nextFireTime + + " - " + nextFireTimeStr + " = triggerState : " + triggerState.toString()); } } diff --git a/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerNotificationManager.java b/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerNotificationManager.java index 8e262ab1..60fccbb4 100644 --- a/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerNotificationManager.java +++ b/so-scheduler/src/main/java/com/pineone/icbms/so/schedule/logic/SchedulerNotificationManager.java @@ -4,7 +4,7 @@ import com.pineone.icbms.so.util.Settings2; import com.pineone.icbms.so.util.conversion.DataConversion; import com.pineone.icbms.so.util.conversion.ProfileTransFormData; -import com.pineone.icbms.so.util.http.ClientService; +import com.pineone.icbms.so.util.http.ClientServiceNoTimeout; import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; @@ -107,7 +107,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException { } private boolean checkCm(String profileId, boolean checkOnly) { - ClientService clientService = new ClientService(); + ClientServiceNoTimeout clientService = new ClientServiceNoTimeout(); ProfileTransFormData profileTransFormData = new ProfileTransFormData(profileId); //profileTransFormData.setPeriod(period); profileTransFormData.setCheckOnly(checkOnly);; diff --git a/so-scheduler/src/test/java/com/pineone/icbms/so/web/SoSchedulerApplicationTests.java b/so-scheduler/src/test/java/com/pineone/icbms/so/web/SoSchedulerApplicationTests.java deleted file mode 100644 index 625fa7e5..00000000 --- a/so-scheduler/src/test/java/com/pineone/icbms/so/web/SoSchedulerApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -//package com.pineone.icbms.so.web; -// -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.test.context.junit4.SpringRunner; -// -//@RunWith(SpringRunner.class) -//@SpringBootTest -//public class SoSchedulerApplicationTests { -// -// @Test -// public void contextLoads() { -// } -// -//} diff --git a/so-serviceprocessor/build.gradle b/so-serviceprocessor/build.gradle index b4fd60ed..af48476f 100644 --- a/so-serviceprocessor/build.gradle +++ b/so-serviceprocessor/build.gradle @@ -72,9 +72,6 @@ dependencies { //json object mapper compile "com.fasterxml.jackson.core:jackson-databind:${VERSION.jackson_databind}" - //withwiz - compile "com.withwiz:plankton:0.1.3" - //spring compile('org.springframework.boot:spring-boot-starter') diff --git a/so-serviceprocessor/conf/application-dev.properties b/so-serviceprocessor/conf/application-dev.properties deleted file mode 100644 index 6ef7c9b8..00000000 --- a/so-serviceprocessor/conf/application-dev.properties +++ /dev/null @@ -1,63 +0,0 @@ -#----------SERVER -server.port=8081 - - -#----------LOG -logging.config=file:./conf/logback-sp.xml - -#----------PROCESSOR LIST -so.serviceprocessor.contextmodel.enable=true -so.serviceprocessor.orchestrationservice.enable=true -so.serviceprocessor.virtualobject.enable=true -so.serviceprocessor.devicecontrol.enable=true - -#----------DEVICE DRIVER -so.device.driver.path=/svc/apps/so/so/driver - -#----------MESSAGE QUEUE -mq.broker.list=localhost:9092 -mq.zookeeper.list=localhost:2181 - -##---------PRODUCER: All values referenced from Kafka -# ACKS_CONFIG -mq.producer.acks=2 -# RETRIES_CONFIG -mq.producer.retries=0 -# BATCH_SIZE_CONFIG -mq.producer.batch_size=16384 -# LINGER_MS_CONFIG -mq.producer.linger_ms=1 -# BUFFER_MEMORY_CONFIG SIZE -mq.producer.buffer_memoryproducer.buffer_memoryproducer.buffer_memory=33554432 - -##---------CONSUMER: All values referenced from Kafka -# POLL_TIMEOUT=3000L -mq.consumer.pool_timeout=4000 -# ENABLE_AUTO_COMMIT_CONFIG=true -mq.consumer.enable_auto_commit=false -# AUTO_COMMIT_INTERVAL_MS_CONFIG -mq.consumer.auto_commit_interval_ms=1000 -# SESSION_TIMEOUT_MS_CONFIG -mq.consumer.session_timeout_ms=15000 -# AUTO_OFFSET_RESET_CONFIG -mq.consumer.auto_offset_reset_config=earliest - -#----------BANNER -banner.location=banner.txt -banner.charset=UTF-8 - -#----------DATABASE -#spring.datasource.url=jdbc:mysql://rgate.synology.me:33306/serviceorchestration?useUnicode=true&characterEncoding=utf-8 -#spring.datasource.username=orchestrator -#spring.datasource.password=pine123 -#spring.datasource.driverClassName=com.mysql.jdbc.Driver - -#spring.jpa.hibernate.ddl-auto=create-drop -#spring.jpa.generate-ddl=false -#spring.jpa.database=mysql -#spring.jpa.show-sql=true - -#----------REMOTE SHELL -#shell.auth.simple.user.name=so -#shell.auth.simple.user.password=so!@# - diff --git a/so-serviceprocessor/conf/application-product.properties b/so-serviceprocessor/conf/application-product.properties deleted file mode 100644 index f0117bcf..00000000 --- a/so-serviceprocessor/conf/application-product.properties +++ /dev/null @@ -1,70 +0,0 @@ -#----------SERVER -server.port=8081 - - -#----------LOG -logging.config=file:../conf/logback-sp.xml - -#----------PROCESSOR LIST -so.serviceprocessor.contextmodel.enable=true -so.serviceprocessor.orchestrationservice.enable=true -so.serviceprocessor.virtualobject.enable=true -so.serviceprocessor.devicecontrol.enable=true - -#----------DEVICE DRIVER -so.device.driver.path=/svc/apps/so/so/driver - -#----------MESSAGE QUEUE -mq.broker.list=localhost:9092 -mq.zookeeper.list=localhost:2181 - -##---------PRODUCER: All values referenced from Kafka -# ACKS_CONFIG -mq.producer.acks=2 -# RETRIES_CONFIG -mq.producer.retries=0 -# BATCH_SIZE_CONFIG -mq.producer.batch_size=16384 -# LINGER_MS_CONFIG -mq.producer.linger_ms=1 -# BUFFER_MEMORY_CONFIG SIZE -mq.producer.buffer_memoryproducer.buffer_memoryproducer.buffer_memory=33554432 - -##---------CONSUMER: All values referenced from Kafka -# POLL_TIMEOUT=3000L -mq.consumer.pool_timeout=4000 -# ENABLE_AUTO_COMMIT_CONFIG=true -mq.consumer.enable_auto_commit=false -# AUTO_COMMIT_INTERVAL_MS_CONFIG -mq.consumer.auto_commit_interval_ms=1000 -# SESSION_TIMEOUT_MS_CONFIG -mq.consumer.session_timeout_ms=15000 -# AUTO_OFFSET_RESET_CONFIG -mq.consumer.auto_offset_reset_config=earliest - -#----------BANNER -banner.location=banner.txt -banner.charset=UTF-8 - -#----------DATABASE -spring.datasource.url=jdbc:mysql://rgate.synology.me:33306/serviceorchestration?useUnicode=true&characterEncoding=utf-8 -spring.datasource.username=orchestrator -spring.datasource.password=pine123 -spring.datasource.driverClassName=com.mysql.jdbc.Driver - -#spring.jpa.hibernate.ddl-auto=create-drop -#spring.jpa.generate-ddl=false -#spring.jpa.database=mysql -#spring.jpa.show-sql=true - -#----------MONGO DB -#spring.data.mongodb.database=so -#spring.data.mongodb.host= -#spring.data.mongodb.port= -#spring.data.mongodb.host=127.0.0.1 -#spring.data.mongodb.port=27017 -spring.data.mongodb.repositories.enabled=true - -#----------REMOTE SHELL -#shell.auth.simple.user.name=so -#shell.auth.simple.user.password=so!@# diff --git a/so-serviceprocessor/conf/logback-sp.xml b/so-serviceprocessor/conf/logback-sp.xml deleted file mode 100644 index 8bb06bea..00000000 --- a/so-serviceprocessor/conf/logback-sp.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTF-8 - %d %-4relative [%thread] %-5level %logger{36} - %msg%n - - - - - - - - ${LOG_FILE_PATH_DEFAULT}_${byDay}.log - true - - ${ENCODER_PATTERN_FILE} - - - - - - ${LOG_FILE_PATH_DEFAULT}.log - - - ${LOG_FILE_NAME_DEFAULT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_SPRING}.log - - - ${LOG_FILE_NAME_SPRING}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_CONTEXT}.log - - - ${LOG_FILE_NAME_PROCESSOR_CONTEXT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_ORCHESTRATIONSERVICE}.log - - - ${LOG_FILE_NAME_PROCESSOR_ORCHESTRATIONSERVICE}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_VIRTUALOBJECT}.log - - - ${LOG_FILE_NAME_PROCESSOR_VIRTUALOBJECT}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - ${LOG_FILE_PATH_PROCESSOR_DEVICECONTROL}.log - - - ${LOG_FILE_NAME_PROCESSOR_DEVICECONTROL}_%d{yyyy-MM-dd}.%i.log - - - 100MB - - - - ${ENCODER_PATTERN_ROLLING_FILE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/SoProcessorApplication.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/SoProcessorApplication.java index 7df2724b..2ce9ac72 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/SoProcessorApplication.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/SoProcessorApplication.java @@ -22,7 +22,7 @@ public class SoProcessorApplication implements CommandLineRunner { * @param args arguments */ public static void main(String[] args) { - System.out.println("*user.dir: " + System.getProperty("user.dir")); +// System.out.println("*user.dir: " + System.getProperty("user.dir")); // SpringApplication.run(SoProcessorApplication.class, args); // SpringApplication app = new SpringApplication(SoProcessorApplication.class); // app.run(args); diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/DepthCheckFilter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/DepthCheckFilter.java deleted file mode 100644 index 4cbf4787..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/DepthCheckFilter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.filter; - -import com.pineone.icbms.so.serviceutil.interfaces.filter.IFilter; - -/** - * Depth check filter abstract class. - * - * Created by uni4love on 2017. 1. 15.. - */ -abstract public class DepthCheckFilter implements IFilter { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/ExpireDateFilter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/ExpireDateFilter.java deleted file mode 100644 index 26b3ba38..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/ExpireDateFilter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.filter; - -import com.pineone.icbms.so.serviceutil.interfaces.filter.IFilter; - -/** - * Expire date filter abstract class. - * - * Created by uni4love on 2017. 1. 15.. - */ -abstract public class ExpireDateFilter implements IFilter { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/MessageExpireDateFilter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/MessageExpireDateFilter.java deleted file mode 100644 index f140c612..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/filter/MessageExpireDateFilter.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.filter; - -import com.pineone.icbms.so.serviceutil.interfaces.filter.IFilter; -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; - -/** - * Message Expire date for message queue filter class. - * - * Created by uni4love on 2017. 1. 15.. - */ -public class MessageExpireDateFilter implements IFilter, IGenericProcessor { - @Override - public V filtering(V v) { - return null; - } - - /** - * return id. - * - * @return id - */ - @Override - public String getId() { - return null; - } - - /** - * return name. - * - * @return name - */ - @Override - public String getName() { - return null; - } - - /** - * called method before process() - */ - @Override - public void beforeProcess() { - - } - - /** - * called method after process() - */ - @Override - public void afterProcess() { - - } - - /** - * process method. - */ - @Override - public void process() { - //implements.. - //got from message queue, and filter - //call filtering() method. - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/ContextModelProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/ContextModelProcessor.java deleted file mode 100644 index 0ac3dc00..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/ContextModelProcessor.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.context.messagequeue.consumer.ContextModelConsumerHandler; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * ContextModelConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class ContextModelProcessor extends AGenericProcessor { - /** - * constructor - */ - public ContextModelProcessor() { - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public ContextModelProcessor(String id, String name) { - super(id, name); - } - - /** - * called by beforeProcess(). - */ - @Override - public void before() { - - } - - /** - * called by afterProcess(). - */ - @Override - public void after() { - - } - - /** - * begin Handler on thread. - */ - public void process() { - //executorservice - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - //handler list - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - ContextModelConsumerHandler consumer = new ContextModelConsumerHandler(i); - consumerList.add(consumer); - //execute a thread - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (ContextModelConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/handler/ContextModelHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/handler/ContextModelHandler.java index 09267590..3c03b980 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/handler/ContextModelHandler.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/handler/ContextModelHandler.java @@ -1,6 +1,5 @@ package com.pineone.icbms.so.serviceprocessor.processor.context.handler; -import com.pineone.icbms.so.interfaces.database.dao.SessionDao; import com.pineone.icbms.so.interfaces.database.model.ContextModelForDB; import com.pineone.icbms.so.interfaces.database.model.ProfileForDB; import com.pineone.icbms.so.interfaces.database.model.SessionEntity; @@ -14,19 +13,13 @@ import com.pineone.icbms.so.util.Settings2; import com.pineone.icbms.so.util.conversion.DataConversion; import com.pineone.icbms.so.util.conversion.ProfileTransFormData; -import com.pineone.icbms.so.util.http.ClientService; +import com.pineone.icbms.so.util.http.ClientServiceNoTimeout; import com.pineone.icbms.so.util.messagequeue.producer.DefaultProducerHandler; -import com.pineone.icbms.so.util.priority.Priority; -import com.pineone.icbms.so.util.session.DefaultSession; -import com.pineone.icbms.so.util.session.Session; import com.pineone.icbms.so.virtualobject.context.contextmodel.IGenericContextModel; import com.pineone.icbms.so.virtualobject.location.IGenericLocation; import com.pineone.icbms.so.virtualobject.orchestrationservice.IGenericOrchestrationService; import com.pineone.icbms.so.virtualobject.profile.IGenericProfile; -import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; -import java.util.Date; import java.util.List; /** @@ -309,7 +302,7 @@ int callDependantProfile(String profileId) { //Dependant Profile이 있으면 if (profileSize>0) { log.debug("callDependantProfile : dependant profiles({}) = {}", profileSize, profileDeps.toString()); - ClientService clientService = new ClientService(); + ClientServiceNoTimeout clientService = new ClientServiceNoTimeout(); for (String childId : profileDeps) { ProfileTransFormData profileTransFormData = new ProfileTransFormData(childId); diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandler.java index 3412f716..f6cf6fe9 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandler.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandler.java @@ -2,7 +2,6 @@ import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; import com.pineone.icbms.so.interfaces.messagequeue.model.ContextModelForMQ; -import com.pineone.icbms.so.serviceprocessor.Const; import com.pineone.icbms.so.serviceutil.interfaces.database.IDatabaseManager; import com.pineone.icbms.so.serviceprocessor.processor.context.handler.ContextModelHandler; import com.pineone.icbms.so.serviceutil.modelmapper.ModelMapper; diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandlerFactory.java deleted file mode 100644 index 70c64147..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/consumer/ContextModelConsumerHandlerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.messagequeue.consumer; - -/** - * SpringKafkaContextModelConsumerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class ContextModelConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaContextModelConsumerHandler instance. - * - * @return ContextModelConsumer - */ - public static ContextModelConsumerHandler getContextModelConsumer(int id) { - return new ContextModelConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandler.java deleted file mode 100644 index d7ff6462..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.messagequeue.producer; - -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * ContextModelForMQ Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class ContextModelProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = "contextmodel"; - - /** - * kafka producer group id by class name. - */ - private final String GROUP_ID = getClass().getSimpleName(); - - /** - * constructor. - */ - public ContextModelProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandlerFactory.java deleted file mode 100644 index 22b9dd80..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/messagequeue/producer/ContextModelProducerHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.messagequeue.producer; - -/** - * SpringKafkaContextModelProducerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class ContextModelProducerHandlerFactory { - /** - * return SpringKafkaContextModelProducerHandler instance. - * - * @return SpringKafkaContextModelProducerHandler - */ - public static ContextModelProducerHandler getContextModelProducerHandler(int id) { - return new ContextModelProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/provider/ContextProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/provider/ContextProvider.java deleted file mode 100644 index cd747b2c..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/provider/ContextProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.provider; - -import com.pineone.icbms.so.serviceutil.interfaces.provider.IContextModelProvider; -import com.pineone.icbms.so.virtualobject.context.contextmodel.IGenericContextModel; - -/** - * Context provider implements. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class ContextProvider implements IContextModelProvider { - /** - * Create - * - * @param iGenericContextModel - * @return ID - */ - @Override - public String create(IGenericContextModel iGenericContextModel) { - return null; - } - - /** - * Retreive - * - * @param s - * @return M - */ - @Override - public IGenericContextModel retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericContextModel - * @return model ID - */ - @Override - public String update(IGenericContextModel iGenericContextModel) { - return null; - } - - /** - * delete - * - * @param iGenericContextModel - * @return model ID - */ - @Override - public String delete(IGenericContextModel iGenericContextModel) { - return null; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/springkafka/SpringKafkaContextModelProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/springkafka/SpringKafkaContextModelProducerHandler.java deleted file mode 100644 index 7be33353..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/context/springkafka/SpringKafkaContextModelProducerHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.context.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * 'contextmodel' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaContextModelProducerHandler extends AProducerHandler { - - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_CONTEXT_MODEL, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/CvoProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/CvoProcessor.java deleted file mode 100644 index 2ecb6811..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/CvoProcessor.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo; - -import com.pineone.icbms.so.serviceprocessor.processor.cvo.messagequeue.consumer.CvoConsumerHandler; -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * CvoConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class CvoProcessor extends AGenericProcessor { - /** - * constructor - */ - public CvoProcessor() { - - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public CvoProcessor(String id, String name) { - super(id, name); - } - - /** - * begin Handler on thread. - */ - @Override - public void process() { - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - CvoConsumerHandler consumer = new CvoConsumerHandler(i); - consumerList.add(consumer); - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (CvoConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * called method before process() - */ - @Override - public void before() { - - } - - /** - * called method after process() - */ - @Override - public void after() { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/handler/CvoHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/handler/CvoHandler.java index c2d06e37..b418cad0 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/handler/CvoHandler.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/handler/CvoHandler.java @@ -121,6 +121,7 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { builtCvoList.add(builtCvo); } + cvoIds = "[" + cvoIds + "]"; SessionEntity sessionCvo = databaseManager.getSessionData(sessionId); @@ -131,6 +132,11 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { sessionCvo.setServiceKey(cvoIds); databaseManager.updateSessionData(sessionCvo); + certLog.debug("=============START(CVO_TYPE_NONEDEVICE)=============="); + certLog.debug("sessionID : " + sessionId); + certLog.debug("baseCVOID : " + cvoBaseId); + certLog.debug("=======================END============================"); + handleCompositeVirtualObjectList(builtCvoList, compositeVirtualObject.getStateStore()); return; @@ -166,8 +172,8 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { if (vId.equals(validVo.getId())){ VirtualObjectForDB vo = new VirtualObjectForDB(); vo.setAspectUri(item.getAspectUri()); - vo.setFunctionalityId(item.getFuntionalityId()); - vo.setFunctionalityUri(item.getFuntionalityUri()); + vo.setFunctionalityId(item.getFunctionalityId()); + vo.setFunctionalityUri(item.getFunctionalityUri()); vo.setId(item.getVoId()); vo.setVoValueType(item.getVoValueType()); vo.setVoValue(item.getVoValue()); @@ -236,15 +242,36 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { //DeviceId 목록을 가져옴 deviceList = new SdaManager().getDeviceListByLoc_DeviceType_Aspect_Func(locationUri, physicalDeviceTypeUri, aspectUri, functionalityUri); log.info("getDeviceListByLoc_DeviceType_Aspect_Func :\nlocationUri={}\n physicalDeviceTypeUri={}\n aspectUri={}\n functionalityUri={}", locationUri, physicalDeviceTypeUri, aspectUri, functionalityUri ); - certLog.debug("{} : getDeviceListByLoc_DeviceType_Aspect_Func from knowledge base :\nlocationUri={}\n physicalDeviceTypeUri={}\n aspectUri={}\n functionalityUri={}", sessionId, locationUri, physicalDeviceTypeUri, aspectUri, functionalityUri ); + // certLog.debug("{} : getDeviceListByLoc_DeviceType_Aspect_Func from knowledge base :\nlocationUri={}\n physicalDeviceTypeUri={}\n aspectUri={}\n functionalityUri={}", sessionId, locationUri, physicalDeviceTypeUri, aspectUri, functionalityUri ); + + certLog.debug("=============START(CVO_TYPE_DEVICETYPE)=============="); + certLog.debug("sessionID : " + sessionId); + certLog.debug("===============SDA Request Parameters================"); + certLog.debug("1. locationUri : " + locationUri); + certLog.debug("2. physicalDeviceTypeUri : " + physicalDeviceTypeUri); + certLog.debug("3. aspectUri : " + aspectUri); + certLog.debug("4. functionalityUri : " + functionalityUri); + certLog.debug("===============SDA Response DeviceList================"); + certLog.debug("deviceList : " + deviceList.toString()); + certLog.debug("=======================END============================"); + } else if (cvoType.equals("CVO_TYPE_ASPECT")) { //DeviceId 목록을 가져옴 deviceList = new SdaManager().getDeviceListByLoc_Aspect_Func(locationUri, aspectUri, functionalityUri); log.info("getDeviceListByLoc_Aspect_Func :\nlocationUri={}\n aspectUri={}\n functionalityUri={}", locationUri, aspectUri, functionalityUri ); - certLog.debug("{} : getDeviceListByLoc_Aspect_Func :\nlocationUri={}\n aspectUri={}\n functionalityUri={}", sessionId, locationUri, aspectUri, functionalityUri ); - - } else if (cvoType.equals("CVO_TYPE_NONEDEVICE")) { + // certLog.debug("{} : getDeviceListByLoc_Aspect_Func :\nlocationUri={}\n aspectUri={}\n functionalityUri={}", sessionId, locationUri, aspectUri, functionalityUri ); + + certLog.debug("===============START(CVO_TYPE_ASPECT)================"); + certLog.debug("sessionID : " + sessionId); + certLog.debug("===============SDA Request Parameters================"); + certLog.debug("1. locationUri : " + locationUri); + certLog.debug("2. aspectUri : " + aspectUri); + certLog.debug("3. functionalityUri : " + functionalityUri); + certLog.debug("===============SDA Response DeviceList================"); + certLog.debug("deviceList : " + deviceList.toString()); + certLog.debug("========================END==========================="); + } } if (deviceList==null) { @@ -273,6 +300,8 @@ public void handle(IGenericCompositeVirtualObject _compositeVirtualObject) { if (cvoType.equals("CVO_TYPE_DEVICEID")) { //VO list handleVirtualObjectList(builtCvoList.get(0), compositeVirtualObject.getStateStore()); + + } else { diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/consumer/CvoConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/consumer/CvoConsumerHandlerFactory.java deleted file mode 100644 index ed4a3070..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/consumer/CvoConsumerHandlerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.messagequeue.consumer; - -/** - * SpringKafkaCvoConsumerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class CvoConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaCvoConsumerHandler instance. - * - * @return SpringKafkaCvoConsumerHandler - */ - public static CvoConsumerHandler getCvoConsumerHandler(int id) { - return new CvoConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandler.java deleted file mode 100644 index d30918ba..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.messagequeue.producer; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * CompositeVirtualObjectForDB Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class CvoProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = Settings2.TOPIC_COMPOSITE_VIRTUAL_OBJECT; - - /** - * kafka producer group id by class name. - */ - private static final String GROUP_ID = CvoProducerHandler.class.getSimpleName(); - - /** - * constructor. - */ - public CvoProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandlerFactory.java deleted file mode 100644 index ba7577b3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/messagequeue/producer/CvoProducerHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.messagequeue.producer; - -/** - * SpringKafkaCvoProducerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class CvoProducerHandlerFactory { - /** - * return SpringKafkaCvoProducerHandler instance. - * - * @return SpringKafkaCvoProducerHandler - */ - public static CvoProducerHandler getCvoProducerHandler(int id) { - return new CvoProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/provider/CvoProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/provider/CvoProvider.java deleted file mode 100644 index ae8bf764..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/provider/CvoProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.provider; - -import java.util.List; - -import com.pineone.icbms.so.interfaces.database.model.CompositeVirtualObjectForDB; -import com.pineone.icbms.so.interfaces.database.model.RuleBodyForDB; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.ICompositeVirtualObjectProvider; -import com.pineone.icbms.so.virtualobject.composite.IGenericCompositeVirtualObject; - -/** - * OrchestrationService provider class. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class CvoProvider implements ICompositeVirtualObjectProvider { - /** - * Create - * - * @param IGenericCompositeVirtualObject - * @return ID - */ - @Override - public String create(IGenericCompositeVirtualObject iGenericCompositeVirtualObject) { - return null; - } - - /** - * Retreive - * - * @param s - * @return M - */ - @Override - public IGenericCompositeVirtualObject retreive(String s) { - return null; - } - - /** - * Update - * - * @param IGenericCompositeVirtualObject - * @return model ID - */ - @Override - public String update(IGenericCompositeVirtualObject iGenericCompositeVirtualObject) { - return null; - } - - /** - * delete - * - * @param IGenericCompositeVirtualObject - * @return model ID - */ - @Override - public String delete(IGenericCompositeVirtualObject iGenericCompositeVirtualObject) { - return null; - } - - /** - * return OrchestrationServiceForDB from database. - * - * @param id orchestration service id - * @return OrchestrationServiceForDB - */ - public List getRuleBodyListByOsId(String id) { - return DatabaseManager.getInstance().getRuleBodyListByOsId(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/springkafka/SpringKafkaCvoProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/springkafka/SpringKafkaCvoProducerHandler.java deleted file mode 100644 index 846940b8..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/cvo/springkafka/SpringKafkaCvoProducerHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.cvo.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * 'compositevirtualobject' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaCvoProducerHandler extends AProducerHandler { - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_COMPOSITE_VIRTUAL_OBJECT, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/DeviceControlProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/DeviceControlProcessor.java deleted file mode 100644 index e57ec68b..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/DeviceControlProcessor.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.messagequeue.consumer.DeviceControlConsumerHandler; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * DeviceControlConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DeviceControlProcessor extends AGenericProcessor { - /** - * constructor - */ - public DeviceControlProcessor() { - - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public DeviceControlProcessor(String id, String name) { - super(id, name); - } - - /** - * begin Handler on thread. - */ - @Override - public void process() { - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - DeviceControlConsumerHandler consumer = new DeviceControlConsumerHandler(i); - consumerList.add(consumer); - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (DeviceControlConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * called method before process() - */ - @Override - public void before() { - - } - - /** - * called method after process() - */ - @Override - public void after() { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/handler/DeviceControlHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/handler/DeviceControlHandler.java index 74dbde19..0665b708 100644 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/handler/DeviceControlHandler.java +++ b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/handler/DeviceControlHandler.java @@ -1,7 +1,5 @@ package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.handler; -import com.pineone.icbms.so.devicecontrol.model.virtualdevice.DeviceControlValue; -import com.pineone.icbms.so.devicecontrol.model.virtualdevice.driver.IGenericDeviceDriver; import com.pineone.icbms.so.interfaces.database.model.SessionEntity; import com.pineone.icbms.so.interfaces.messagequeue.producer.tracking.TrackingProducer; import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; @@ -16,9 +14,6 @@ import org.slf4j.LoggerFactory; import com.pineone.icbms.so.interfaces.si.model.ResultMessage; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; /** * device control handler. @@ -73,26 +68,6 @@ public void handle(IGenericVirtualDevice virtualDevice, String locationUri, Stri String sessionId = getTracking().getSessionId(); - // get DeviceDriver from sda by virtual object features - // retrieve device list -// SdaClient sdaClient = new SdaClient(); -// List deviceList = sdaClient.retreiveDeviceList(null, locationUri); - - //create control list - // TODO product : get device control value to use SDA API. -// DeviceControlValue deviceControlValue = ModelMapper.toDeviceControlValue(deviceControlForDB); -// LinkedHashMap> controlList = new LinkedHashMap<>(); -// if (deviceList != null) { -// for (IGenericVirtualDevice device : deviceList) { -// String driverClassName = device.getDriverClassName(); - //load devicemapper driver -// IGenericDeviceDriver deviceDriver = new DeviceDriverLoader().loadDeviceDriver(Settings.DEVICE_DRIVER_PATH, driverClassName); - //retreive values from sda -// List values = sdaClient.retreiveDeviceControlValues(null, null, locationUri, device.getId()); -// controlList.put(deviceDriver, values); -// } - - String deviceId = virtualDevice.getDeviceId(); String aspectUri = virtualDevice.getAspect().getUri(); String functionUri = virtualDevice.getFunction().getUri(); @@ -181,7 +156,10 @@ public void handle(IGenericVirtualDevice virtualDevice, String locationUri, Stri // grib session device SessionEntity sessionDevice = new SessionEntity(); sessionDevice.setId(sessionId); - sessionDevice.setDeviceKey(deviceId); + + //Device Uri중에서 "http://www.iotoasis.org" 문자열 제외하고 session Log에 저장 + String stripDeviceId = deviceId.replace(ClientProfile.IOT_OASIS_DOMAIN_NAME, ""); //"http://www.iotoasis.org" 삭제 + sessionDevice.setDeviceKey(stripDeviceId); sessionDevice.setDeviceLocation(loc); log.debug("session device : {}", sessionDevice); databaseManager.createSessionDataDevice(sessionDevice); @@ -200,25 +178,6 @@ public void handle(IGenericVirtualDevice virtualDevice, String locationUri, Stri } } - /** - * control a device. - * - * @param deviceControlList device control list - */ - private void controlDevice(LinkedHashMap> deviceControlList) { - //TODO: thread process 고민 필요 - if (deviceControlList != null) { - for (Map.Entry> entry : deviceControlList.entrySet()) { - IGenericDeviceDriver deviceDriver = entry.getKey(); - List values = entry.getValue(); - // - //databaseManager.getDeviceControlByDeviceIdAndContextModelID - log.debug(">>>>>>>>> size of deviceControlList: {}, {}, {} ", deviceControlList.size(), entry.getKey(), entry.getValue()); - deviceDriver.control(values); - } - } - } - /** * control a device. * diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/consumer/DeviceControlConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/consumer/DeviceControlConsumerHandlerFactory.java deleted file mode 100644 index 0e8a11ec..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/consumer/DeviceControlConsumerHandlerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.messagequeue.consumer; - -/** - * SpringKafkaDeviceControlConsumerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class DeviceControlConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaContextModelConsumerHandler instance. - * - * @return SpringKafkaContextModelConsumerHandler - */ - public static DeviceControlConsumerHandler getDeviceControlConsumer(int id) { - return new DeviceControlConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandler.java deleted file mode 100644 index 738fb2d3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.messagequeue.producer; - -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * DeviceControlForMQ Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class DeviceControlProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = "devicecontrol"; - - /** - * kafka producer group id by class name. - */ - private static final String GROUP_ID = DeviceControlProducerHandler.class.getSimpleName(); - - /** - * constructor. - */ - public DeviceControlProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandlerFactory.java deleted file mode 100644 index 1bf9d932..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/messagequeue/producer/DeviceControlProducerHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.messagequeue.producer; - -/** - * SpringKafkaDeviceControlProducerHandler factory - * - * Created by uni4love on 2017. 1. 4.. - */ -public class DeviceControlProducerHandlerFactory { - /** - * return SpringKafkaDeviceControlProducerHandler instance. - * - * @return SpringKafkaDeviceControlProducerHandler - */ - public static DeviceControlProducerHandler getDeviceControlProducerHandler(int id) { - return new DeviceControlProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/provider/DeviceProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/provider/DeviceProvider.java deleted file mode 100644 index 970d0475..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/provider/DeviceProvider.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.provider; - -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.interfaces.database.model.DeviceForDB; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.IDeviceControlProvider; - -import java.util.List; - -/** - * Device provider implements. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class DeviceProvider implements IDeviceControlProvider { - /** - * database manager - */ - DatabaseManager databaseManager; - - /** - * constructor. - * - * @param databaseManager DatabaseManager - */ - public DeviceProvider(DatabaseManager databaseManager) { - this.databaseManager = databaseManager; - } - - /** - * Create - * - * @param iGenericVirtualDevice - * @return ID - */ - @Override - public String create(IGenericVirtualDevice iGenericVirtualDevice) { - return null; - } - - /** - * Retrecive - * - * @param s - * @return M - */ - @Override - public IGenericVirtualDevice retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericVirtualDevice - * @return model ID - */ - @Override - public String update(IGenericVirtualDevice iGenericVirtualDevice) { - return null; - } - - /** - * delete - * - * @param iGenericVirtualDevice - * @return model ID - */ - @Override - public String delete(IGenericVirtualDevice iGenericVirtualDevice) { - return null; - } - - /** - * return IGenericVirtualDevice list from database. - * - * @param function function uri - * @param aspect aspect - * @param locationUri location uri - * @return IGenericVirtualDevice list - */ - public List getDeviceList(String function, String aspect, String locationUri) { - return databaseManager.getDeviceList(function, aspect, locationUri); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/springkafka/SpringKafkaDeviceControlProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/springkafka/SpringKafkaDeviceControlProducerHandler.java deleted file mode 100644 index 41f44da2..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/devicecontrol/springkafka/SpringKafkaDeviceControlProducerHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * 'contextmodel' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaDeviceControlProducerHandler extends AProducerHandler { - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_DEVICE_CONTROL, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/OrchestrationServiceProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/OrchestrationServiceProcessor.java deleted file mode 100644 index fe61637a..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/OrchestrationServiceProcessor.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice; - -import com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.messagequeue.consumer.OrchestrationServiceConsumerHandler; -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * OrchestrationServiceConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class OrchestrationServiceProcessor extends AGenericProcessor { - /** - * constructor - */ - public OrchestrationServiceProcessor() { - - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public OrchestrationServiceProcessor(String id, String name) { - super(id, name); - } - - /** - * begin Handler on thread. - */ - @Override - public void process() { - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - OrchestrationServiceConsumerHandler consumer = new OrchestrationServiceConsumerHandler(i); - consumerList.add(consumer); - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (OrchestrationServiceConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * called method before process() - */ - @Override - public void before() { - - } - - /** - * called method after process() - */ - @Override - public void after() { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/consumer/OrchestrationServiceConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/consumer/OrchestrationServiceConsumerHandlerFactory.java deleted file mode 100644 index 2d4ecb9b..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/consumer/OrchestrationServiceConsumerHandlerFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.messagequeue.consumer; - -/** - * SpringKafkaOrchestrationServiceConsumerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class OrchestrationServiceConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaOrchestrationServiceConsumerHandler instance. - * - * @return SpringKafkaOrchestrationServiceConsumerHandler - */ - public static OrchestrationServiceConsumerHandler getOrchestrationServiceConsumerHandler(int id) { - return new OrchestrationServiceConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandler.java deleted file mode 100644 index 4eed2766..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.messagequeue.producer; - -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * OrchestrationServiceForMQ Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class OrchestrationServiceProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = "orchestrationservice"; - - /** - * kafka producer group id by class name. - */ - private static final String GROUP_ID = OrchestrationServiceProducerHandler.class.getSimpleName(); - - /** - * constructor. - */ - public OrchestrationServiceProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandlerFactory.java deleted file mode 100644 index 56466a48..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/messagequeue/producer/OrchestrationServiceProducerHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.messagequeue.producer; - -/** - * SpringKafkaOrchestrationServiceProducerHandler factory. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class OrchestrationServiceProducerHandlerFactory { - /** - * return SpringKafkaOrchestrationServiceProducerHandler instance. - * - * @return SpringKafkaOrchestrationServiceProducerHandler - */ - public static OrchestrationServiceProducerHandler getOrchestrationServiceProducerHandler(int id) { - return new OrchestrationServiceProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/provider/OrchestrationServiceProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/provider/OrchestrationServiceProvider.java deleted file mode 100644 index 757d7a79..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/provider/OrchestrationServiceProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.provider; - -import com.pineone.icbms.so.interfaces.database.model.OrchestrationServiceForDB; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.IOrchestrationServiceProvider; -import com.pineone.icbms.so.virtualobject.orchestrationservice.IGenericOrchestrationService; - -/** - * OrchestrationService provider class. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class OrchestrationServiceProvider implements IOrchestrationServiceProvider { - /** - * Create - * - * @param iGenericOrchestrationService - * @return ID - */ - @Override - public String create(IGenericOrchestrationService iGenericOrchestrationService) { - return null; - } - - /** - * Retreive - * - * @param s - * @return M - */ - @Override - public IGenericOrchestrationService retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericOrchestrationService - * @return model ID - */ - @Override - public String update(IGenericOrchestrationService iGenericOrchestrationService) { - return null; - } - - /** - * delete - * - * @param iGenericOrchestrationService - * @return model ID - */ - @Override - public String delete(IGenericOrchestrationService iGenericOrchestrationService) { - return null; - } - - /** - * return OrchestrationServiceForDB from database. - * - * @param id orchestration service id - * @return OrchestrationServiceForDB - */ - public OrchestrationServiceForDB getOrchestrationServiceById(String id) { - return DatabaseManager.getInstance().getOrchestrationServiceById(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/springkafka/SpringKafkaOrchestrationServiceProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/springkafka/SpringKafkaOrchestrationServiceProducerHandler.java deleted file mode 100644 index ccdb7d25..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/orchestrationservice/springkafka/SpringKafkaOrchestrationServiceProducerHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * 'orchestrationservice' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaOrchestrationServiceProducerHandler extends AProducerHandler { - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_ORCHESTRATION_SERVICE, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/VirtualObjectProcessor.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/VirtualObjectProcessor.java deleted file mode 100644 index 09d80114..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/VirtualObjectProcessor.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.serviceprocessor.processor.virtualobject.messagequeue.consumer.VirtualObjectConsumerHandler; -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * VirtualObjectConsumerHandler runner. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class VirtualObjectProcessor extends AGenericProcessor { - /** - * constructor - */ - public VirtualObjectProcessor() { - - } - - /** - * constructor - * - * @param id id - * @param name name - */ - public VirtualObjectProcessor(String id, String name) { - super(id, name); - } - - /** - * begin Handler on thread. - */ - @Override - public void process() { - ExecutorService executorService = Executors.newFixedThreadPool(Settings2.HANDLER_COUNT); - List consumerList = new ArrayList<>(); - for (int i = 0; i < Settings2.HANDLER_COUNT; i++) { - VirtualObjectConsumerHandler consumer = new VirtualObjectConsumerHandler(i); - consumerList.add(consumer); - executorService.submit(consumer); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for (VirtualObjectConsumerHandler consumer : consumerList) { - consumer.shutdown(); - } - executorService.shutdown(); - try { - executorService.awaitTermination(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * called method before process() - */ - @Override - public void before() { - - } - - /** - * called method after process() - */ - @Override - public void after() { - - } - -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/consumer/VirtualObjectConsumerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/consumer/VirtualObjectConsumerHandlerFactory.java deleted file mode 100644 index 0c141659..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/consumer/VirtualObjectConsumerHandlerFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.messagequeue.consumer; - -/** - * Created by uni4love on 2017. 1. 4.. - */ -public class VirtualObjectConsumerHandlerFactory { - /** - * max count - */ - private int MAX_COUNT = 5; - - /** - * return SpringKafkaVirtualObjectConsumerHandler instance. - * - * @return SpringKafkaVirtualObjectConsumerHandler - */ - public static VirtualObjectConsumerHandler getVirtualObjectConsumerHandler(int id) { - return new VirtualObjectConsumerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandler.java deleted file mode 100644 index 6b8b7184..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.messagequeue.producer; - -import com.pineone.icbms.so.util.messagequeue.producer.AGenericProducerHandler; - -/** - * VirtualObjectForMQ Producer handler. - * - * Created by uni4love on 2016. 12. 15.. - */ -public class VirtualObjectProducerHandler extends AGenericProducerHandler { - /** - * topic list - */ - private static final String TOPIC = "virtualobject"; - - /** - * kafka producer group id by class name. - */ - private static final String GROUP_ID = VirtualObjectProducerHandler.class.getSimpleName(); - - /** - * constructor. - */ - public VirtualObjectProducerHandler(int id) { - super(id); - } - - /** - * return topic. - * - * @return topic - */ - @Override - public String getTopic() { - return TOPIC; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandlerFactory.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandlerFactory.java deleted file mode 100644 index 8a8cb911..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/messagequeue/producer/VirtualObjectProducerHandlerFactory.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.messagequeue.producer; - -/** - * SpringKafkaVirtualObjectProducerHandler factory. - * Created by uni4love on 2017. 1. 4.. - */ -public class VirtualObjectProducerHandlerFactory { - /** - * return SpringKafkaVirtualObjectProducerHandler instance. - * - * @return SpringKafkaVirtualObjectProducerHandler - */ - public static VirtualObjectProducerHandler getVirtualObjectProducerHandler(int id) { - return new VirtualObjectProducerHandler(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/provider/VirtualObjectProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/provider/VirtualObjectProvider.java deleted file mode 100644 index b8d075ae..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/provider/VirtualObjectProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.provider; - -import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.IVirtualObjectProvider; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -/** - * VirtualObject provider class. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class VirtualObjectProvider implements IVirtualObjectProvider { - /** - * Create - * - * @param iGenericVirtualObject - * @return ID - */ - @Override - public String create(IGenericVirtualObject iGenericVirtualObject) { - return null; - } - - /** - * Retrecive - * - * @param s - * @return M - */ - @Override - public IGenericVirtualObject retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericVirtualObject - * @return model ID - */ - @Override - public String update(IGenericVirtualObject iGenericVirtualObject) { - return null; - } - - /** - * delete - * - * @param iGenericVirtualObject - * @return model ID - */ - @Override - public String delete(IGenericVirtualObject iGenericVirtualObject) { - return null; - } - - /** - * return VirtualObjectForDB from database. - * - * @param id virtual object id - * @return VirtualObjectForDB - */ - public VirtualObjectForDB getVirtualObjectById(String id) { - return DatabaseManager.getInstance().getVirtualObjectById(id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/springkafka/SpringKafkaVirtualObjectProducerHandler.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/springkafka/SpringKafkaVirtualObjectProducerHandler.java deleted file mode 100644 index 3c597453..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/processor/virtualobject/springkafka/SpringKafkaVirtualObjectProducerHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.processor.virtualobject.springkafka; - -import com.pineone.icbms.so.util.Settings2; -import com.pineone.icbms.so.util.spring.springkafka.producer.AProducerHandler; -import org.springframework.kafka.support.SendResult; - -/** - * "contextmodel' topic producer. - * - * Created by uni4love on 2017. 4. 10.. - */ -public class SpringKafkaVirtualObjectProducerHandler extends AProducerHandler { - /** - * send message to kafka. - * - * @param key key - * @param message value - */ - public void send(String key, String message) { - send(Settings2.TOPIC_VIRTUAL_OBJECT, key, message, this); - } - - /** - * Called after super.onSuccess(). - * - * @param result the result - */ - @Override - public void onCompleted(SendResult result) { - - } - - /** - * Called after super.onFailure. - * - * @param ex exception - */ - @Override - public void onFailed(Throwable ex) { - - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/profile/provider/ProfileProvider.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/profile/provider/ProfileProvider.java deleted file mode 100644 index 93feeb31..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/profile/provider/ProfileProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.profile.provider; - -import com.pineone.icbms.so.interfaces.database.model.ProfileForDB; -import com.pineone.icbms.so.virtualobject.profile.IGenericProfile; -import com.pineone.icbms.so.serviceutil.interfaces.database.DatabaseManager; -import com.pineone.icbms.so.serviceutil.interfaces.provider.IProfileProvider; - -import java.util.List; - -/** - * Profile provider implements. - * - * Created by uni4love on 2017. 1. 4.. - */ -public class ProfileProvider implements IProfileProvider { - /** - * Create - * - * @param iGenericProfile - * @return ID - */ - @Override - public String create(IGenericProfile iGenericProfile) { - return null; - } - - /** - * Retreive - * - * @param s - * @return M - */ - @Override - public IGenericProfile retreive(String s) { - return null; - } - - /** - * Update - * - * @param iGenericProfile - * @return model ID - */ - @Override - public String update(IGenericProfile iGenericProfile) { - return null; - } - - /** - * Delete - * - * @param iGenericProfile - * @return model ID - */ - @Override - public String delete(IGenericProfile iGenericProfile) { - return null; - } - - /** - * return ProfileForDB from database. - * - * @param contextModelSid context model id - * @param locationUri location uri - * @return ProfileForDB - */ - public List getProfileListByContextModelSidAndLocationUri(String contextModelSid, String locationUri) { - return DatabaseManager.getInstance().getProfileListByContextModelSidAndLocationUri(contextModelSid, locationUri); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/AGenericProcessRegistry.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/AGenericProcessRegistry.java deleted file mode 100644 index 2b46e9c7..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/AGenericProcessRegistry.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.registry; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; -import com.pineone.icbms.so.serviceutil.interfaces.registry.IGenericProcessorRegistry; -import com.pineone.icbms.so.util.registry.AGenericKeyValueRegistry; - -/** - * Abstract Generic serviceprocessor registry - * - * Created by uni4love on 2016. 11. 24.. - */ -abstract public class AGenericProcessRegistry - extends AGenericKeyValueRegistry - implements IGenericProcessorRegistry { - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - abstract public boolean existProcessor(String processorName); -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/DefaultProcessorRegistry.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/DefaultProcessorRegistry.java deleted file mode 100644 index c948efea..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/DefaultProcessorRegistry.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.registry; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; - -import java.util.HashMap; -import java.util.Map; - -/** - * serviceprocessor default class. - * - * Created by uni4love on 2016. 11. 24.. - */ -public class DefaultProcessorRegistry extends AGenericProcessRegistry { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new HashMap(); - } - - /** - * add a serviceprocessor. - * - * @param processor - */ - @Override - public void addProcessor(IGenericProcessor processor) { - addValue(processor.getId(), processor); - } - - /** - * return existence of serviceprocessor - * - * @param processor serviceprocessor - * @return true/false - */ - @Override - public boolean existProcessor(IGenericProcessor processor) { - return this.store.containsKey(processor.getId()); - } - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - @Override - public boolean existProcessor(String processorName) { - return this.store.containsKey(processorName); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/SequenceProcessorRegistry.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/SequenceProcessorRegistry.java deleted file mode 100644 index a46d81a6..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/registry/SequenceProcessorRegistry.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.registry; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * serviceprocessor default class. - * - * Created by uni4love on 2016. 11. 24.. - */ -public class SequenceProcessorRegistry extends AGenericProcessRegistry { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new LinkedHashMap(); - } - - /** - * add a serviceprocessor. - * - * @param processor - */ - @Override - public void addProcessor(IGenericProcessor processor) { - addValue(processor.getName(), processor); - } - - /** - * add a serviceprocessor. - * - * @param key key - * @param processor serviceprocessor - */ - public void addProcessor(String key, IGenericProcessor processor) { - addValue(key, processor); - } - - - - /** - * return existence of serviceprocessor - * - * @param processor serviceprocessor - * @return true/false - */ - @Override - public boolean existProcessor(IGenericProcessor processor) { - return this.store.containsKey(processor.getId()); - } - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - @Override - public boolean existProcessor(String processorName) { - return this.store.containsKey(processorName); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java deleted file mode 100644 index 2c2ff5f2..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.route; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.registry.SequenceProcessorRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Process Line class. - * - * This class support for serviceprocessor, filter, rule process. - * - * Created by uni4love on 2016. 11. 24.. - */ -public class ProcessLine { - /** - * logger - */ - private Logger log = LoggerFactory.getLogger(ProcessLine.class.getClass()); - - /** - * process registry - */ - private SequenceProcessorRegistry processRegistry = new SequenceProcessorRegistry(); - - /** - * add a serviceprocessor. - * - * @param processor - */ - public void addProcessor(IGenericProcessor processor) { - this.processRegistry.addProcessor(processor); - } - - /** - * return a serviceprocessor. - * - * @param key key for a serviceprocessor - * @return serviceprocessor - */ - public IGenericProcessor getProcessor(String key) { - return this.processRegistry.getValue(key); - } - - /** - * return existence of serviceprocessor - * - * @param processor serviceprocessor - * @return true/false - */ - public boolean existProcessor(IGenericProcessor processor) { - return this.processRegistry.existProcessor(processor.getId()); - } - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - public boolean existProcessor(String processorName) { - return this.processRegistry.existProcessor(processorName); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java deleted file mode 100644 index b45982fd..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java +++ /dev/null @@ -1,237 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.route; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.context.ContextModelProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.DeviceControlProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.OrchestrationServiceProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.virtualobject.VirtualObjectProcessor; -import com.pineone.icbms.so.util.id.IdUtils; -import com.withwiz.plankton.util.StringUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; - - -/** - * 미사용 - * Process router class. - * This class is Singleton instance. - * - * Created by uni4love on 2016. 11. 24.. - */ -@Component -public final class ProcessorRouter { - /** - * logger - */ - private Logger log = LoggerFactory.getLogger(ProcessorRouter.class); - - /** - * process line - */ - private ProcessLine line = new ProcessLine(); - - /** - * serviceprocessor list, - * - * TODO: 추후 class loader를 이용하여 동적으로 구동하도록 처리 요망. - * TODO: 외부에서 inject할 수 있도록 함. - * TODO: filter class도 동일 라인에 추가 가능. - */ - static Class[] processorList = { - ContextModelProcessor.class, - OrchestrationServiceProcessor.class, - VirtualObjectProcessor.class, - DeviceControlProcessor.class - }; - - /** - * singleton instance holder - */ - private static final class SingletonHolder { - static final ProcessorRouter singleton = new ProcessorRouter(); - } - - /** - * constructor - */ - private ProcessorRouter() { - init(); - } - - /** - * return ProcessorRunner singleton instance. - * - * @return ProcessorRunner - */ - public static ProcessorRouter getInstance() { - return SingletonHolder.singleton; - } - - /** - * initialize - */ - private void init() { - //instance objects - reload(); - } - - /** - * reload environments - */ - public void reload() { - //load classes - loadClass(); - } - - /** - * load classes. - */ - private void loadClass() { - //temporary load static classes; - //serviceprocessor id is name. - for (Class clz : processorList) { - Class> cls = null; - Class[] args = new Class[]{String.class, String.class}; - try { - cls = Class.forName(clz.getName()); - Constructor constructor = cls.getConstructor(args); - //parameters: id, name - Object obj = constructor.newInstance(IdUtils.createRandomUUID(), cls.getName()); - addProcessor((IGenericProcessor) obj); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - - /** - * add a serviceprocessor to registry. - * - * @param processor serviceprocessor - */ - public void addProcessor(IGenericProcessor processor) { - this.line.addProcessor(processor); - } - - /** - * return a serviceprocessor from registry. - * - * @param key key for finding a serviceprocessor. - * @return IGenericProcessor - */ - public IGenericProcessor getProcessor(String key) { - return this.line.getProcessor(key); - } - - /** - * return existence of serviceprocessor - * - * @param processorName name - */ - public boolean existProcess(String processorName) { - return line.existProcessor(processorName); - } - - /** - * print USAGE. - */ - public static void printUsage() { - StringBuilder sb = new StringBuilder("# Usage) java -jar so-serviceprocessor.jar -P[processor1,processor2,..]\n"); - sb.append("\n= current serviceprocessor name list:\n"); - for (Class cls : processorList) { - sb.append("+- " + cls.getName() + "\n"); - } - System.out.println(sb); - } - - /** - * run processors. - * - * @param args runnable serviceprocessor name - */ - public void run(String[] args) { -// log.info("user.dir: {}", System.getProperty("user.dir")); - log.debug("arguments[{}]: {}", args.length, Arrays.stream(args).toArray()); - // serviceprocessor name list from arguments - ArrayList processorNameListFromArguments = getProcessorNameListFromArguments(args); - // - if (processorNameListFromArguments == null || !checkExistProcessorNameList(processorNameListFromArguments)) { - //usage - ProcessorRouter.printUsage(); - } else { - ProcessorRouter processRouter = ProcessorRouter.getInstance(); - for (String processorName : processorNameListFromArguments) { - AGenericProcessor processor = (AGenericProcessor)processRouter.getProcessor(processorName); - new Thread(processor).start(); - } - } - } - - /** - * run parameter("serviceprocessor class name") list. - * - * @param processorNameList serviceprocessor name list - * @return result after checking - */ - private boolean checkExistProcessorNameList(ArrayList processorNameList) { - //check serviceprocessor class - ProcessorRouter processRouter = ProcessorRouter.getInstance(); - for (String processorName : processorNameList) { - log.info("Your serviceprocessor name: {}", processorName); - if (!processRouter.existProcess(processorName)) { - log.error("Your serviceprocessor NOT exist: {}", processorName); - return false; - } - } - return true; - } - - /** - * return serviceprocessor name list from arguments. - * - * @param args arguments - * @return serviceprocessor name list - */ - private ArrayList getProcessorNameListFromArguments(String[] args) { - ArrayList processorNameList = null; - for(String arg: args) { - if (arg.startsWith("-P")) { - if(processorNameList == null) - processorNameList = new ArrayList<>(); - String filteredArgs = StringUtil.getRight(arg, "-P"); - log.debug("filteredArgs: {}", filteredArgs); - String[] processorArray = filteredArgs.split(","); - processorNameList.addAll(Arrays.asList(processorArray)); - log.debug("current processorList: {}", processorNameList); - } - } - return processorNameList; - } - - - /** - * runner test main method. - * - * usage) java -j [jar file] [serviceprocessor name] - * - * @param args serviceprocessor name - */ -// public static void main(String[] args) { -// ProcessorRouter.getInstance().run(args); -// } -} \ No newline at end of file diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java deleted file mode 100644 index f5d16556..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -/** - * cut default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultCut extends AGenericIdentity implements ICut { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java deleted file mode 100644 index a1f79ccd..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenario; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * Scenario default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenario extends AGenericIdentity implements IScenario { - - /** - * scene list - */ - List sceneList = null; - - /** - * scenario context - */ - IScenarioContext scenarioContext = null; - - /** - * constructor - */ - public DefaultScenario() { - } - - /** - * return a ScenarioContext. - * - * @return ScenarioContext - */ - @Override - public IScenarioContext getScenarioContext() { - return scenarioContext; - } - - public void setScenarioContext(IScenarioContext scenarioContext) { - this.scenarioContext = scenarioContext; - } - - /** - * return scene list. - * - * @return List - */ - @Override - public List getSceneList() { - return null; - } - - public void setSceneList(List sceneList) { - this.sceneList = sceneList; - } - - public void addScene(IScene scene) { - this.sceneList.add(scene); - } - - -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java deleted file mode 100644 index be17afab..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.util.registry.AGenericKeyValueRegistry; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * scenario context default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenarioContext extends AGenericKeyValueRegistry implements IScenarioContext { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new LinkedHashMap(); - } - - /** - * return scenario id - * - * @return scenario id - */ - @Override - public String getScenarioId() { - return this.getValue("SCENARIO_ID"); - } - - public void setScenearioId(String id) { - this.addValue("SCENARIO_ID", id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java deleted file mode 100644 index 45023136..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * scene default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScene extends AGenericIdentity implements IScene { - /** - * cut list - */ - List cutList = null; - - /** - * constructor - */ - public DefaultScene() { - } - - /** - * return cut list. - * - * @return List - */ - @Override - public List getCutList() { - return null; - } - - public void setCutList(List cutList) { - this.cutList = cutList; - } - - public void addCut(DefaultCut cut) { - this.cutList.add(cut); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java deleted file mode 100644 index 90c7ea33..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.serviceprocessor.util.devicemapper.IDeviceMapper; -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mapper. - * - * Created by uni4love on 2016. 12. 30.. - */ -public class DeviceMapper implements IDeviceMapper { - - @Override - public List getDevices(IGenericVirtualObject virtualObject) { - return null; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java deleted file mode 100644 index 63bec3c3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mappe interface. - * - * Created by uni4love on 2016. 12. 30.. - */ -public interface IDeviceMapper { - /** - * from VirtualObject. - * - * @param virtualObject - */ - List getDevices(IGenericVirtualObject virtualObject); -} diff --git a/so-serviceprocessor/src/main/resources/banner.txt b/so-serviceprocessor/src/main/resources/banner.txt deleted file mode 100644 index 6dd56601..00000000 --- a/so-serviceprocessor/src/main/resources/banner.txt +++ /dev/null @@ -1,18 +0,0 @@ - _____ -/\ __`\ __ -\ \ \/\ \ __ ____/\_\ ____ - \ \ \ \ \ /'__`\ /',__\/\ \ /',__\ - \ \ \_\ \/\ \L\.\_/\__, `\ \ \/\__, `\ - \ \_____\ \__/.\_\/\____/\ \_\/\____/ - \/_____/\/__/\/_/\/___/ \/_/\/___/ - - - ____ _____ __ __ __ -/\ _`\ __ /\ __`\ /\ \ /\ \__ /\ \__ __ -\ \,\L\_\ __ _ __ __ __/\_\ ___ __ \ \ \/\ \ _ __ ___\ \ \___ __ ___\ \ ,_\ _ __ __ \ \ ,_\/\_\ ___ ___ - \/_\__ \ /'__`\/\`'__\/\ \/\ \/\ \ /'___\ /'__`\ \ \ \ \ \/\`'__\/'___\ \ _ `\ /'__`\ /',__\ \ \//\`'__\/'__`\\ \ \/\/\ \ / __`\ /' _ `\ - /\ \L\ \/\ __/\ \ \/ \ \ \_/ \ \ \/\ \__//\ __/ \ \ \_\ \ \ \//\ \__/\ \ \ \ \/\ __//\__, `\ \ \\ \ \//\ \L\.\\ \ \_\ \ \/\ \L\ \/\ \/\ \ - \ `\____\ \____\\ \_\ \ \___/ \ \_\ \____\ \____\ \ \_____\ \_\\ \____\\ \_\ \_\ \____\/\____/\ \__\ \_\\ \__/.\_\ \__\\ \_\ \____/\ \_\ \_\ - \/_____/\/____/ \/_/ \/__/ \/_/\/____/\/____/ \/_____/\/_/ \/____/ \/_/\/_/\/____/\/___/ \/__/\/_/ \/__/\/_/\/__/ \/_/\/___/ \/_/\/_/ - - \ No newline at end of file diff --git a/so-serviceutil/src/main/resources/application.properties b/so-serviceutil/src/main/resources/application.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/so-util/build.gradle b/so-util/build.gradle index 16cc6b36..f2fcb5a0 100644 --- a/so-util/build.gradle +++ b/so-util/build.gradle @@ -66,8 +66,8 @@ dependencies { //spring-kafka compile 'org.springframework.kafka:spring-kafka:1.2.0.RELEASE' - // http - compile "com.withwiz:httpclientservice:0.1.1" + //base64 + compile group: 'commons-codec', name: 'commons-codec', version: '1.10' //compile("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootVersion}") diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java deleted file mode 100644 index 8c89b3e4..00000000 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.pineone.icbms.so.util; - -import org.apache.kafka.common.serialization.StringDeserializer; -import org.apache.kafka.common.serialization.StringSerializer; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -/** - * settings for message queue. - * Created by uni4love on 2016. 12. 16.. - */ -@Configuration -public class Settings { - /** - * broker(kafka) list - */ - @Value("${mq.broker.list}") - public String brokerList = "localhost:9092"; - - /** - * Zookeeper list - */ - @Value("${mq.zookeeper.list}") - public String zookeeperList = "localhost:2181"; - - //----------------------------- consumer configs - /** - * consumer Poll timeout - */ - @Value("${mq.consumer.pool_timeout}") - public long pollTimeout = 3000L; - - /** - * ENABLE_AUTO_COMMIT_CONFIG - */ - @Value("${mq.consumer.enable_auto_commit}") - public String enableAutoCommitConfig = "true"; - - /** - * AUTO_COMMIT_INTERVAL_MS_CONFIG - */ - @Value("${mq.consumer.auto_commit_interval_ms}") - public String autoCommitIntervalMsConfig = "1000"; - - /** - * SESSION_TIMEOUT_MS_CONFIG - */ - @Value("${mq.consumer.session_timeout_ms}") - public String sessionTimeoutMsConfig= "15000"; - - /** - * AUTO_OFFSET_RESET_CONFIG - */ - @Value("${mq.consumer.auto_offset_reset}") - public String autoOffsetResetConfig= "earliest"; - - /** - * KEY_DESERIALIZER_CLASS_CONFIG - */ - public static String KEY_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - /** - * VALUE_DESERIALIZER_CLASS_CONFIG - */ - public static String VALUE_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - //----------------------------- producer configs - /** - * ACKS_CONFIG - */ - @Value("${mq.producer.acks}") - public String acksConfig= "1"; - - /** - * RETRIES_CONFIG - */ - @Value("${mq.producer.retries}") - public int retriesConfig = 0; - - /** - * BATCH_SIZE_CONFIG - */ - @Value("${mq.producer.batch_size}") - public int batchSizeConfig= 16384; - - /** - * LINGER_MS_CONFIG - */ - @Value("${mq.producer.linger_ms}") - public int lingerMsConfig= 1; - - /** - * BUFFER_MEMORY_CONFIG - */ - @Value("${mq.producer.buffer_memory}") - public int bufferMemoryConfig= 33554432; - - /** - * KEY_SERIALIZER_CLASS_CONFIG - */ - public static String KEY_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - /** - * VALUE_SERIALIZER_CLASS_CONFIG - */ - public static String VALUE_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - - //----------------------------- common configs - /** - * kafka topic: contextmodel - */ - public static String TOPIC_CONTEXT_MODEL = "contextmodel"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_ORCHESTRATION_SERVICE = "orchestrationservice"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_COMPOSITE_VIRTUAL_OBJECT = "compositevirtualobject"; - - /** - * kafka topic: virtual object - */ - public static String TOPIC_VIRTUAL_OBJECT = "virtualobject"; - - /** - * kafka topic: devicecontrol - */ - public static String TOPIC_DEVICE_CONTROL = "devicecontrol"; - - /** - * kafka topic: logging - */ - public static String TOPIC_TRACKING = "tracking"; - - /** - * each serviceprocessor handler count - */ - public static int HANDLER_COUNT = 1; - - /** - * CONTEXTMODEL serviceprocessor handler count - */ - public int HANDLER_CONTEXTMODEL_COUNT = HANDLER_COUNT; - - /** - * ORCHESTRATIONSERVICE serviceprocessor handler count - */ - public int HANDLER_ORCHESTRATIONSERVICE_COUNT = HANDLER_COUNT; - - /** - * VIRTUALOBJECT serviceprocessor handler count - */ - public int HANDELR_VIRTUALOBJECT_COUNT = HANDLER_COUNT; - - /** - * DEVICECONTROL serviceprocessor handler count - */ - public int HANDLER_DEVICECONTROL_COUNT = HANDLER_COUNT; - - /** - * class path for class loader - */ - @Value("${so.device.driver.path}") - public String deviceDriverPath= "/"; - - public String getBrokerList() { - return brokerList; - } - - public void setBrokerList(String brokerList) { - this.brokerList = brokerList; - } - - public String getZookeeperList() { - return zookeeperList; - } - - public void setZookeeperList(String zookeeperList) { - this.zookeeperList = zookeeperList; - } - - public long getPollTimeout() { - return pollTimeout; - } - - public void setPollTimeout(long pollTimeout) { - this.pollTimeout = pollTimeout; - } - - public String getEnableAutoCommitConfig() { - return enableAutoCommitConfig; - } - - public void setEnableAutoCommitConfig(String enableAutoCommitConfig) { - this.enableAutoCommitConfig = enableAutoCommitConfig; - } - - public String getAutoCommitIntervalMsConfig() { - return autoCommitIntervalMsConfig; - } - - public void setAutoCommitIntervalMsConfig(String autoCommitIntervalMsConfig) { - this.autoCommitIntervalMsConfig = autoCommitIntervalMsConfig; - } - - public String getSessionTimeoutMsConfig() { - return sessionTimeoutMsConfig; - } - - public void setSessionTimeoutMsConfig(String sessionTimeoutMsConfig) { - this.sessionTimeoutMsConfig = sessionTimeoutMsConfig; - } - - public String getAutoOffsetResetConfig() { - return autoOffsetResetConfig; - } - - public void setAutoOffsetResetConfig(String autoOffsetResetConfig) { - this.autoOffsetResetConfig = autoOffsetResetConfig; - } - - public String getAcksConfig() { - return acksConfig; - } - - public void setAcksConfig(String acksConfig) { - this.acksConfig = acksConfig; - } - - public int getRetriesConfig() { - return retriesConfig; - } - - public void setRetriesConfig(int retriesConfig) { - this.retriesConfig = retriesConfig; - } - - public int getBatchSizeConfig() { - return batchSizeConfig; - } - - public void setBatchSizeConfig(int batchSizeConfig) { - this.batchSizeConfig = batchSizeConfig; - } - - public int getLingerMsConfig() { - return lingerMsConfig; - } - - public void setLingerMsConfig(int lingerMsConfig) { - this.lingerMsConfig = lingerMsConfig; - } - - public int getBufferMemoryConfig() { - return bufferMemoryConfig; - } - - public void setBufferMemoryConfig(int bufferMemoryConfig) { - this.bufferMemoryConfig = bufferMemoryConfig; - } - - public String getDeviceDriverPath() { - return deviceDriverPath; - } - - public void setDeviceDriverPath(String deviceDriverPath) { - this.deviceDriverPath = deviceDriverPath; - } -} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java index 9b9c5fe4..9ef955ef 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java @@ -28,13 +28,13 @@ public static String getBrokerList() { /** * Zookeeper list */ - public static String zookeeperList = "localhost:2181"; + public static String zookeeperList; // = "localhost:21811"; public static String getZookeeperList() { return zookeeperList; } - @Value("${mq.zookeeper.list}") + //@Value("${mq.zookeeper.list}") public void setZookeeperList(String _zookeeperList) { zookeeperList = _zookeeperList; } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java index 0722ca6f..460475c8 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java @@ -63,6 +63,4 @@ public static List stringDataToList(String data){ public static String base64encoding(String data){ return new String(Base64.encodeBase64(data.getBytes())); } - - } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java similarity index 55% rename from so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java rename to so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java index 84519549..9e82121d 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java @@ -1,11 +1,5 @@ package com.pineone.icbms.so.util.http; -import com.withwiz.beach.network.http.message.IHttpResponseMessage; -import com.withwiz.jellyfish.service.IGenericService; -import com.withwiz.jellyfish.service.ServiceException; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientService; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceRequestDeliveryMessage; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceResponseDeliveryMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -14,8 +8,6 @@ import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; /** * ClientService class @@ -24,162 +16,14 @@ */ @Service -public class ClientService +public class ClientServiceNoTimeout { public static final int DATA_TIMEOUT_VALUE = 90000; public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 - private final Logger log = LoggerFactory.getLogger(ClientService.class); - - /** - * request post service. - * - * @param serviceUrl - * @param body - * @return - * NOTE: URL 로 Body 내용 전송 - */ - public IHttpResponseMessage requestPostService(String serviceUrl, String body) - { - log.info("Client Service requestPostService uri " + serviceUrl); - log.info("Client Service requestPostService data " + body); - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - HashMap headerList = new HashMap(); - headerList.put("Content-Type", "application/json"); - // headerList.put("Content-Length", "238"); - - req.addValue(HttpClientService.KEY_HEADER_PARAMETERS, headerList); - req.addValue(HttpClientService.KEY_SERVICE_URL, serviceUrl); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT, 50000); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_POST); - // req.addValue(HttpClientService); - - // body data - // StringInputStream inputStream = new StringInputStream(body); - ByteArrayInputStream inputStream = new ByteArrayInputStream( - body.getBytes()); - req.addValue(HttpClientService.KEY_BODY_INPUT_STREAM, inputStream); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - IHttpResponseMessage httpResponseMessage = null; - // HttpClientService - IGenericService service = new HttpClientService(); - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - /** - * request get service. - * - * @param uri - * @return - NOTE: 외부에서 데이터를 조회하기 위함. Url 의 내용을 조회 - */ - public IHttpResponseMessage requestGetService(String uri) - { - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - req.addValue(HttpClientService.KEY_SERVICE_URL, uri); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT,DATA_TIMEOUT_VALUE); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_GET); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - - // HttpClientService - IGenericService service = new HttpClientService(); - // return IHttpResponseMessage - IHttpResponseMessage httpResponseMessage = null; - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - private IHttpResponseMessage getiHttpResponseMessage(HttpClientServiceRequestDeliveryMessage req, - HttpClientServiceResponseDeliveryMessage res, - IHttpResponseMessage httpResponseMessage, - IGenericService service) { - try - { - // execute a service - service.onService(req, res); - // get a service response - httpResponseMessage = res - .getValue(HttpClientService.KEY_HTTP_RESPONSE); - // print a response - //System.out.println(res); - } - catch (ServiceException e) - { - System.out.println("connection fail :" + e.getMessage()); - //e.printStackTrace(); - } - return httpResponseMessage; - } - - public String requestPostServiceReceiveString(String uri, String data) { - return requestPostServiceReceiveString(uri,data,false); - } - - public String requestPostServiceReceiveString(String uri, String data, boolean onlyResultValue) { - IHttpResponseMessage httpResponseMessage = requestPostService(uri, data); - String returnData = null; - if (onlyResultValue) { - returnData = String.valueOf(httpResponseMessage.getStatusCode()); - } else { - returnData = responseDataToString(httpResponseMessage); - } - return returnData; - } - - - public String requestGetServiceReceiveString(String uri) { - IHttpResponseMessage httpResponseMessage = requestGetService(uri); - String returnData = responseDataToString(httpResponseMessage); - return returnData; - } - - /** - * response Data to String. - * - * @param message - * @return String - */ - public String responseDataToString(IHttpResponseMessage message) - { - String result = null; - - BufferedReader reader = null; - try - { - reader = new BufferedReader(new InputStreamReader( - message.getBodyInputStream()), 8); - StringBuilder sb = new StringBuilder(); - String line = null; - while ((line = reader.readLine()) != null) - { - sb.append(line); - } - result = sb.toString(); - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return result; - } + private final Logger log = LoggerFactory.getLogger(ClientServiceNoTimeout.class); //======================================================================================================= public String requestPostServiceReceiveString2(String uri, String param) { diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java new file mode 100644 index 00000000..ab752483 --- /dev/null +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java @@ -0,0 +1,182 @@ +package com.pineone.icbms.so.util.http; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.io.*; +import java.net.ConnectException; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * ClientServiceTimeout class + * Created by use on 2015-10-12. + * NOTE: 외부 통신을 위해 사용 + */ + +@Service +public class ClientServiceTimeout +{ + public static final int DATA_TIMEOUT_VALUE = 90000; + + public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 + public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 + + private final Logger log = LoggerFactory.getLogger(ClientServiceTimeout.class); + + public String requestPostServiceReceiveString2(String uri, String param) { + return requestPostServiceReceiveString2(uri, param, false); + } + + public String requestPostServiceReceiveString2(String uri, String param, boolean timeOut) + { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestPostServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + //log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + conn.setRequestMethod("POST"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + OutputStream out_stream = conn.getOutputStream(); + out_stream.write( param.getBytes("UTF-8") ); + log.info("requestPostServiceReceiveString2:[{}]:[{}] ", uri, out_stream.toString()); + out_stream.flush(); + out_stream.close(); + + log.info("out_stream close.."); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + //log.info("getInputStream.."); + + InputStream is = conn.getInputStream(); + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + + String line = null; + StringBuffer buff = new StringBuffer(); + + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###1 POST Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###1 POST Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + + + public String requestGetServiceReceiveString2(String uri) { + return requestGetServiceReceiveString2(uri, false); + } + public String requestGetServiceReceiveString2(String uri, boolean timeOut) { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestGetServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + + conn.setRequestMethod("GET"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + // conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.connect(); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + + //log.info("getInputStream.."); + InputStream is = conn.getInputStream(); + + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + String line = null; + StringBuffer buff = new StringBuffer(); + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###2 GET Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###2 GET Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + +} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java index 8bff1204..548f0aad 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java @@ -30,7 +30,7 @@ public static Long createRandomLongValue() { * @param args */ public static void main(String[] args) { - System.out.println(IdUtils.createRandomUUID()); - System.out.println(IdUtils.createRandomLongValue()); + //System.out.println(IdUtils.createRandomUUID()); + //System.out.println(IdUtils.createRandomLongValue()); } } diff --git a/so-util/src/test/java/Jackson_Test.java b/so-util/src/test/java/Jackson_Test.java deleted file mode 100644 index a9f8b606..00000000 --- a/so-util/src/test/java/Jackson_Test.java +++ /dev/null @@ -1,62 +0,0 @@ -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by melvin on 2017. 4. 18.. - */ - -public class Jackson_Test { - - @Test - public void name() throws Exception { - List testObjectList = new ArrayList<>(); - - TestObject testObject1 = new TestObject("5", "5", "5"); - TestObject testObject2 = new TestObject("6", "6", "6"); - TestObject testObject3 = new TestObject("7", "7", "7"); - - testObjectList.add(testObject1); - testObjectList.add(testObject2); - testObjectList.add(testObject3); - - ObjectMapper objectMapper = new ObjectMapper(); - - // List --> String - String testObjListStr = objectMapper.writeValueAsString(testObjectList); - System.out.println("*******funcListStr******** " + testObjListStr); - - // String --> List - List testObjects = objectMapper.readValue(testObjListStr, new TypeReference>() { - }); - System.out.println("*******funcList******** " + testObjects); - - // Class --> String - TestObject testObject = testObjects.get(0); - String testObjStr = objectMapper.writeValueAsString(testObject); - System.out.println("*******funcStr******** " + testObjStr); - - // String --> Class - TestObject testClass = objectMapper.readValue(testObjStr, TestObject.class); - System.out.println("*******funcClass******** " + testClass); - System.out.println("*******funcClass.name******** " + testClass.getName()); - - - List test = new ArrayList<>(); - - test.add("testObject1"); - test.add("testObject2"); - test.add("testObject3"); - - objectMapper = new ObjectMapper(); - - // List --> String - testObjListStr = objectMapper.writeValueAsString(test); - System.out.println("*******string array******** " + testObjListStr); - } - -} - diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java index 40846e69..19ccbecf 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java @@ -12,7 +12,6 @@ import com.pineone.icbms.so.interfaces.database.ref.DataValidation; import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; import com.pineone.icbms.so.interfaces.messagequeue.model.ContextModelForMQ; -import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; import com.pineone.icbms.so.interfaces.sda.model.ContextModelForIf2; import com.pineone.icbms.so.interfaces.si.handle.DeviceManager; @@ -20,7 +19,6 @@ import com.pineone.icbms.so.util.messagequeue.producer.DefaultProducerHandler; import com.pineone.icbms.so.web.model.context.Content; import com.pineone.icbms.so.web.model.context.ContextModel; -import com.pineone.icbms.so.web.model.context.ContextModelTransFormObject; import com.pineone.icbms.so.web.model.context.ResponseMessage; import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; import com.pineone.icbms.so.web.util.ContextModelMapper2; @@ -56,34 +54,6 @@ public class ContextModelController { @Autowired DataBaseStore dataBaseStore; -// /** -// * response for request "/context/cm, HTTP-method:POST". -// * -// * @param contextModelForIf ContextModelForIf -// * @return created DeviceControlCallbackForDB id -// */ -// @RequestMapping(value = "/cm", method = RequestMethod.POST) -// public String injectContextModel(@RequestBody ContextModelForIf contextModelForIf) { -// log.debug("input:ContextModelForIf: {}", contextModelForIf); -// // create a message From ContextModelForMQ for messageQueue, publish to message queue -// // ContextModelForIf --> ContextModelForMQ -// ContextModelForMQ contextModelForMQ = ModelMapper.toContextModelForMQ(contextModelForIf); -// log.debug("converted:ContextModelForMQ: {}", contextModelForMQ); -// //object to json -// String contextModelForMqString = ModelMapper.writeJsonString(contextModelForMQ); -// log.debug("generated:ContextModelForMQ {}", contextModelForMqString); -// //context model producer handler -//// ContextModelProducerHandler producerHandler = new ContextModelProducerHandler(0); -//// Future future = producerHandler.send(contextModelForMqString); -// DefaultProducerHandler producerHandler = new DefaultProducerHandler(0, "contextmodel"); -// Future future = producerHandler.send(contextModelForMQ); -// log.debug("producer.send result: {}", future); -// producerHandler.close(); -// -// //TODO: 추후 처리 결과를 정의하여 리턴함. -// return contextModelForMqString; -// } - /** * response for request "/service/context/cm, HTTP-method:POST". * @@ -189,7 +159,7 @@ private ContextModelForMQ processContextModel(ContextModelForIf2 contextModelFor //@PostMapping(value = "/test") public void testCode(HttpServletRequest request) { - DeviceManager.testmain(null); + new DeviceManager().testmain(null); } /** @@ -296,34 +266,6 @@ public ResponseMessage emergencyContextModel(@RequestBody ContextModelForIf2 con return responseMessage; } - private DataValidation newDataValidation(){ - DataValidation dataValidation = new DataValidation(); - return dataValidation; - } - - private void inspectContextModel(ContextModel contextModel) throws DataLossException { - // - if(contextModel.getId() == null || contextModel.getContextType() == null || - contextModel.getDomainIdList() == null){ - throw new DataLossException(); - } - } - -/* - private ContextModel dataObjectToContextModel(ContextModelTransFormObject contextModelDataObject){ - if(contextModelDataObject == null) return null; - return new ContextModel(contextModelDataObject.getContextId(), contentsToStringList(contextModelDataObject.getContents()), - contextModelDataObject.getCmd(), contextModelDataObject.getTime()); - } -*/ - private List contentsToStringList(List contentsList){ - - List domains = new ArrayList<>(); - for(Content content : contentsList){ - domains.add(content.getLoc()); - } - return domains; - } public String useQueueSaveContextModel(ContextModel contextModel) { // diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java new file mode 100644 index 00000000..1ab2407f --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java @@ -0,0 +1,54 @@ +package com.pineone.icbms.so.web.interfaces.api; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import com.kastkode.springsandwich.filter.annotation.Before; +import com.kastkode.springsandwich.filter.annotation.BeforeElement; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; +import com.pineone.icbms.so.web.model.measure.ResMeasuring; +import com.pineone.icbms.so.web.service.IMeasuringService; +import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; + +@Before(@BeforeElement(BeforeTtrackingHandler.class)) +@CrossOrigin(origins = "*") +@RestController +@RequestMapping(value = "/servicemodel") +public class MeasuringController { + + @Autowired + IMeasuringService measuringService; + + @RequestMapping(value = "/measure",method = RequestMethod.POST) + @ResponseStatus(value = HttpStatus.OK) + @ResponseBody + public ResMeasuring getMeasuredData(@RequestBody ReqMeasuring req, HttpServletRequest request) { + + ResMeasuring res = new ResMeasuring(); + TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); + String sessionId = trackingEntity.getSessionId(); + res.setSessionId(sessionId); + + Object r = measuringService.getMeasuredData(req, request, trackingEntity); + if (r==null) { + String failMsg = "No service data"; + res.setResultMessage(failMsg); + res.setResultCode(404); // No Information + }else { + res.setResultMessage(r); + res.setResultCode(200); //SUCCESS + } + + return res; + } +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java index d15dd908..b9aa4b92 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java @@ -59,116 +59,6 @@ public class ProfileController { @Autowired DatabaseManager databaseManager; - /** - * response for request "/profile, HTTP-method:POST". - * scheduler가 특정 주기로 호출됨 - * - * @param profileTransFormData profile - * @return profile - */ - @RequestMapping(value = "/schedule1", method = RequestMethod.POST) - public IGenericProfile callFromScheduler(@RequestBody ProfileTransFormData profileTransFormData, HttpServletRequest request) { - - if (profileTransFormData==null) { - contextLog.warn("Input Profile is null"); - return null; - } - String inputProfileId = profileTransFormData.getId(); - contextLog.debug("Checking CM by schedule : input profile=[{}]", inputProfileId); - - ProfileForDB profileForDb = databaseManager.getProfileById(profileTransFormData.getId()); - IGenericProfile profile = ModelMapper.toProfile(profileForDb); - - SessionEntity sessionEntity = new SessionEntity(); - - if (profile==null) { - contextLog.warn("Profile is null"); - return null; - } - - IGenericContextModel contextModel = profile.getContextModel(); - if (contextModel == null) { - contextLog.warn( "contextModel is null"); - return null; - } - - String contextModelId = contextModel.getId(); - ContextModelForDB cm = databaseManager.getContextModelById(contextModelId); - String contextModelName = cm.getName(); - - TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); - String sessionId = trackingEntity.getSessionId(); - String priority = profileForDb.getPriority(); - - // grib session - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelKey(contextModelId); - sessionEntity.setContextmodelName(contextModelName); - sessionEntity.setContextmodelResult("NotHappen"); - sessionEntity.setPriorityKey(priority); - //contextLog.debug("session : {}", sessionEntity); - - // grib session profile - //SessionEntity sessionProfile = new SessionEntity(); - //sessionEntity.setId(sessionId); - sessionEntity.setProfileKey(profile.getId()); - sessionEntity.setProfileName(profile.getName()); - //contextLog.debug("session profile : {}", sessionEntity); - - databaseManager.createSessionData(sessionEntity); - - boolean isCmProceed = false; //CM 처리되었나? - - //SDA로 부터 CM발생 여부 체크 - List locationList = new SdaManager().retrieveEventLocationList(contextModelId); - - contextLog.debug("called SDA: cm={}, name={}, location={}", contextModelId, contextModelName, locationList.toString()); - - if (locationList != null && locationList.size() > 0) { - - for (String location : locationList) { - if (location.equals(profile.getLocation().getUri())) { - //scheduler 또는 에 의한 Profile 내 OS 구동임을 남겨야 함 - - ContextModelHandler contextModelHandler = new ContextModelHandler(databaseManager); - contextModelHandler.setTracking(trackingEntity); - contextModelHandler.profileHandle(profile); - isCmProceed = true; - - //sessionEntity.setContextmodelResult("Happen"); - //databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(location); - databaseManager.createSessionDataLocation(sessionLocation); - - contextLog.warn("O: result: Happen cm=[{}], Location={} , sessionId={}", contextModelId, location, sessionId); - //contextLog.debug("session location : {}", sessionLocation); - } - } - } - - //Location이 없거나 처리되지 않았을때 - if (isCmProceed == false) { - contextLog.warn("X: result: Not happened cm=[{}]", contextModelId); - - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelResult("NotHappen"); - databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(""); - databaseManager.createSessionDataLocation(sessionLocation); - - //contextLog.debug("session location : {}", sessionLocation); - } - return profile; - } - /** * response for request "/profile, HTTP-method:POST". * scheduler가 특정 주기로 호출됨 diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java index 295de4f1..128d5d94 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java @@ -25,16 +25,6 @@ @ResponseStatus(value = HttpStatus.OK) public class SessionController { -// @Autowired -// SessionStore sessionStore; -// -// @RequestMapping(value = "/{number}", method = RequestMethod.GET) -// @ResponseStatus(value = HttpStatus.OK) -// public List retrieveSessionData(@PathVariable int number){ -// List sessionList = sessionStore.retrieveRecentlyDataList(number); -// return sessionToTransFormObject(sessionList); -// } - @Autowired //TrackingDao trackingDao; SessionDao sessionDao; @@ -86,8 +76,10 @@ public List retrieveSessionData(@PathVariable Integer nu sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(entity.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", entity.getVirtualobjectResult()); - - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", entity.getDeviceResult()); @@ -145,7 +137,9 @@ public SessionTransFormObject retrieveSessionDataOne(@PathVariable String sessio sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(sessionDataDb.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", sessionDataDb.getVirtualobjectResult()); - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", sessionDataDb.getDeviceResult()); diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java new file mode 100644 index 00000000..257e98fa --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java @@ -0,0 +1,27 @@ +package com.pineone.icbms.so.web.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) +public class MeasuringData { + + @Getter@Setter + private String devId ; + + @Getter@Setter + private String devName ; + + @Getter@Setter + private String devTypeDesc; + + @Getter@Setter + private String aspectName; + + @Getter@Setter + private String measuringValue; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java new file mode 100644 index 00000000..a90b4164 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java @@ -0,0 +1,21 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ReqMeasuring { + @Getter@Setter + @JsonProperty("serviceName") + String serviceName; + + @Getter@Setter + @JsonProperty("location") + String location; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java new file mode 100644 index 00000000..a5921508 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java @@ -0,0 +1,26 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ResMeasuring { + @Getter@Setter + @JsonProperty("resultCode") + Integer resultCode; + + @Getter@Setter + @JsonProperty("resultMessage") + Object resultMessage; + + @Getter@Setter + @JsonProperty("sessionId") + String sessionId; +} + diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java new file mode 100644 index 00000000..da096394 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java @@ -0,0 +1,12 @@ +package com.pineone.icbms.so.web.service; + +import javax.servlet.http.HttpServletRequest; + +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +public interface IMeasuringService { + + Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity); + +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java new file mode 100644 index 00000000..a0d60a2c --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java @@ -0,0 +1,192 @@ +package com.pineone.icbms.so.web.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.pineone.icbms.so.interfaces.database.dao.OrchestrationServiceDao; +import com.pineone.icbms.so.interfaces.database.model.DeviceTypeForDB; +import com.pineone.icbms.so.interfaces.database.model.LocationForDB; +import com.pineone.icbms.so.interfaces.database.model.MeasuringVoForDB; +import com.pineone.icbms.so.interfaces.database.model.OrchestrationServiceForDB; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; +import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; +import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; +import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; +import com.pineone.icbms.so.web.model.MeasuringData; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +import lombok.Getter; +import lombok.Setter; + +@Service +public class MeasuringService implements IMeasuringService { + @Autowired + //IDataBaseStore dataBaseStore; + DataBaseStore dataBaseStore; + + //@Autowired + //protected DatabaseManager databaseManager; + + @Autowired + OrchestrationServiceDao orchestrationServiceDao; + + @Getter @Setter + TrackingEntity tracking; + + protected Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity) { + + //입력 파라미터 + String locId = req.getLocation(); //설치 위치 + String serviceName = req.getServiceName(); //OS 이름 + + //설치 장소 + LocationForDB locForDB = dataBaseStore.getLocationById(locId); + String locationUri = locForDB.getUri(); + String locName = locForDB.getName(); + + + //1) OS Name으로 osId얻기 + OrchestrationServiceForDB param = new OrchestrationServiceForDB(); + param.setName(serviceName); + + List osForDbList = orchestrationServiceDao.retrieve(param); + if (osForDbList==null || osForDbList.size()==0) { //일치되는 자료 없음 + log.error("Service Info ({}) not found", serviceName); //orchestration_service : name + return null; + } + OrchestrationServiceForDB osForDb = osForDbList.get(0); + String osId = osForDb.getId(); + + //2) os id 로 MeasuringVoForDB 목록을 조회한다 + // osId로 rule_body/rule_item에서 vo list 얻기 : (rule_item의 functionality_id가 FUNCTIONALITY_TYPE_MEASURING인 값만 선택) + // cvo_type이 NONDEVICE_CVO인 경우에는 noncvo테이블을 참조하여 확장 + log.debug("getRuleBodyListByOsId : {}", osId); + List measuringVoForDBList = dataBaseStore.getMeasuringVoList(osId); + + // 측정데이타를 저장할 변수 생성 + List measuringDataList = new ArrayList<>(); + + //3) MeasuringVoForDB의 item별로 동작 + for (MeasuringVoForDB measuringVoItem:measuringVoForDBList) { + + String cvoBaseId = measuringVoItem.getBaseCvoId(); + String cvoType = measuringVoItem.getCvoType(); + + // BaseCvoId 부터 유효 VO 목록을 가져온다. + List validVoList = dataBaseStore.getVirtualObjectListByCompositeVirtualObjectId(cvoBaseId); + if (validVoList.size()==0) { + log.error("Not exist vo list by cvoBase={}", cvoBaseId); + continue; + } + String vId = measuringVoItem.getVoId(); + String aspectUri = null; + String voDesc = null; + + //VO값이 유효한 Vo인지 검사한다. + for (VirtualObjectForDB validVo:validVoList) { + if (vId.equals(validVo.getId())){ + aspectUri = validVo.getAspectUri(); //첫번째 VO만 참조하여 URI를 가져옴 + voDesc = validVo.getDescription(); + break; + } + } + + //유효하지 않으면 + if (aspectUri == null ) { //SKIP + log.error("Not exist aspectUri by list by vId={}", vId); + continue; + } + + // 4) cvo_type별로 sda에서 값 읽기 + List contentList = null; + //4-1) CVO_TYPE_DEVICETYPE or CVO_TYPE_DEVICETYPE_ASPECT + if (cvoType.equals("CVO_TYPE_DEVICETYPE") || cvoType.equals("CVO_TYPE_DEVICETYPE_ASPECT")) { + String physicalDeviceTypeId = measuringVoItem.getPhysicalDeviceTypeId(); + + //PysicalDeviceTypeUri + DeviceTypeForDB typeDb = dataBaseStore.retrieveDeviceTypeById(physicalDeviceTypeId); + if (typeDb==null) { + log.error("error : Device Type info is not exist : physicalDeviceTypeId={}", physicalDeviceTypeId); + continue; + } + String physicalDeviceTypeUri = typeDb.getPhysicalDeviceTypeUri(); + + contentList = new SdaManager().getMeasuringValueByLocDeviceTypeAspect(locationUri, physicalDeviceTypeUri, aspectUri); + } + //4-2) CVO_TYPE_ASPECT + else if (cvoType.equals("CVO_TYPE_ASPECT")) { + + contentList = new SdaManager().getMeasuringValueByLocAspect(locationUri, aspectUri); + } + //4-3) CVO_TYPE_DEVICEID + else if (cvoType.equals("CVO_TYPE_DEVICEID")) { + + String deviceUri = measuringVoItem.getDeviceId(); + contentList = new SdaManager().getMeasuringValueByDevIdAspect(deviceUri, aspectUri); + + } else { + // SKIP + } + + if (contentList != null) { + for (ContextModelContent contentItem:contentList) { + + MeasuringData md = new MeasuringData(); + + md.setDevId(contentItem.getDeviceUri()); + md.setDevName(contentItem.getDeviceName()); + md.setDevTypeDesc(contentItem.getDeviceTypeDesc()); + md.setAspectName(voDesc); + md.setMeasuringValue(contentItem.getValue()); + + measuringDataList.add(md); + } + } + } + +/* + String contextModelId="measuring"; + String contextModelName="Measureing"; + + setTracking((TrackingEntity) request.getSession().getAttribute("tracking")); + String sessionId = trackingEntity.getSessionId(); + + // grib session + SessionEntity sessionEntity = new SessionEntity(); + sessionEntity.setId(sessionId); + sessionEntity.setContextmodelKey(contextModelId); + sessionEntity.setContextmodelName(contextModelName); + sessionEntity.setContextmodelResult("NotHappen"); + sessionEntity.setProfileName(serviceName); + //sessionEntity.setPriorityKey("LOW"); + log.debug("session : {}", sessionEntity); + dataBaseStore.createSessionData(sessionEntity); + + + // grib session location + SessionEntity sessionLocation = new SessionEntity(); + sessionLocation.setId(sessionId); + sessionLocation.setLocationId(locationUri); + log.debug("session location : {}", sessionLocation); + try { + dataBaseStore.createSessionDataLocation(sessionLocation); + }catch(Exception e) { + log.error("Error createSessionDataLocation : error={},\n sessionLocation={}", e.getMessage(), sessionLocation); + } +*/ + + return measuringDataList; + } + +}
- * Created by uni4love on 2016. 11. 24.. - */ -public class SequenceProcessorRegistry extends AGenericProcessRegistry { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new LinkedHashMap(); - } - - /** - * add a serviceprocessor. - * - * @param processor - */ - @Override - public void addProcessor(IGenericProcessor processor) { - addValue(processor.getName(), processor); - } - - /** - * add a serviceprocessor. - * - * @param key key - * @param processor serviceprocessor - */ - public void addProcessor(String key, IGenericProcessor processor) { - addValue(key, processor); - } - - - - /** - * return existence of serviceprocessor - * - * @param processor serviceprocessor - * @return true/false - */ - @Override - public boolean existProcessor(IGenericProcessor processor) { - return this.store.containsKey(processor.getId()); - } - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - @Override - public boolean existProcessor(String processorName) { - return this.store.containsKey(processorName); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java deleted file mode 100644 index 2c2ff5f2..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessLine.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.route; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.registry.SequenceProcessorRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Process Line class. - * - * This class support for serviceprocessor, filter, rule process. - * - * Created by uni4love on 2016. 11. 24.. - */ -public class ProcessLine { - /** - * logger - */ - private Logger log = LoggerFactory.getLogger(ProcessLine.class.getClass()); - - /** - * process registry - */ - private SequenceProcessorRegistry processRegistry = new SequenceProcessorRegistry(); - - /** - * add a serviceprocessor. - * - * @param processor - */ - public void addProcessor(IGenericProcessor processor) { - this.processRegistry.addProcessor(processor); - } - - /** - * return a serviceprocessor. - * - * @param key key for a serviceprocessor - * @return serviceprocessor - */ - public IGenericProcessor getProcessor(String key) { - return this.processRegistry.getValue(key); - } - - /** - * return existence of serviceprocessor - * - * @param processor serviceprocessor - * @return true/false - */ - public boolean existProcessor(IGenericProcessor processor) { - return this.processRegistry.existProcessor(processor.getId()); - } - - /** - * return existence of serviceprocessor - * - * @param processorName serviceprocessor name - * @return true/false - */ - public boolean existProcessor(String processorName) { - return this.processRegistry.existProcessor(processorName); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java deleted file mode 100644 index b45982fd..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/route/ProcessorRouter.java +++ /dev/null @@ -1,237 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.route; - -import com.pineone.icbms.so.serviceutil.interfaces.processor.AGenericProcessor; -import com.pineone.icbms.so.serviceutil.interfaces.processor.IGenericProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.context.ContextModelProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.devicecontrol.DeviceControlProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.orchestrationservice.OrchestrationServiceProcessor; -import com.pineone.icbms.so.serviceprocessor.processor.virtualobject.VirtualObjectProcessor; -import com.pineone.icbms.so.util.id.IdUtils; -import com.withwiz.plankton.util.StringUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; - - -/** - * 미사용 - * Process router class. - * This class is Singleton instance. - * - * Created by uni4love on 2016. 11. 24.. - */ -@Component -public final class ProcessorRouter { - /** - * logger - */ - private Logger log = LoggerFactory.getLogger(ProcessorRouter.class); - - /** - * process line - */ - private ProcessLine line = new ProcessLine(); - - /** - * serviceprocessor list, - * - * TODO: 추후 class loader를 이용하여 동적으로 구동하도록 처리 요망. - * TODO: 외부에서 inject할 수 있도록 함. - * TODO: filter class도 동일 라인에 추가 가능. - */ - static Class[] processorList = { - ContextModelProcessor.class, - OrchestrationServiceProcessor.class, - VirtualObjectProcessor.class, - DeviceControlProcessor.class - }; - - /** - * singleton instance holder - */ - private static final class SingletonHolder { - static final ProcessorRouter singleton = new ProcessorRouter(); - } - - /** - * constructor - */ - private ProcessorRouter() { - init(); - } - - /** - * return ProcessorRunner singleton instance. - * - * @return ProcessorRunner - */ - public static ProcessorRouter getInstance() { - return SingletonHolder.singleton; - } - - /** - * initialize - */ - private void init() { - //instance objects - reload(); - } - - /** - * reload environments - */ - public void reload() { - //load classes - loadClass(); - } - - /** - * load classes. - */ - private void loadClass() { - //temporary load static classes; - //serviceprocessor id is name. - for (Class clz : processorList) { - Class> cls = null; - Class[] args = new Class[]{String.class, String.class}; - try { - cls = Class.forName(clz.getName()); - Constructor constructor = cls.getConstructor(args); - //parameters: id, name - Object obj = constructor.newInstance(IdUtils.createRandomUUID(), cls.getName()); - addProcessor((IGenericProcessor) obj); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - - /** - * add a serviceprocessor to registry. - * - * @param processor serviceprocessor - */ - public void addProcessor(IGenericProcessor processor) { - this.line.addProcessor(processor); - } - - /** - * return a serviceprocessor from registry. - * - * @param key key for finding a serviceprocessor. - * @return IGenericProcessor - */ - public IGenericProcessor getProcessor(String key) { - return this.line.getProcessor(key); - } - - /** - * return existence of serviceprocessor - * - * @param processorName name - */ - public boolean existProcess(String processorName) { - return line.existProcessor(processorName); - } - - /** - * print USAGE. - */ - public static void printUsage() { - StringBuilder sb = new StringBuilder("# Usage) java -jar so-serviceprocessor.jar -P[processor1,processor2,..]\n"); - sb.append("\n= current serviceprocessor name list:\n"); - for (Class cls : processorList) { - sb.append("+- " + cls.getName() + "\n"); - } - System.out.println(sb); - } - - /** - * run processors. - * - * @param args runnable serviceprocessor name - */ - public void run(String[] args) { -// log.info("user.dir: {}", System.getProperty("user.dir")); - log.debug("arguments[{}]: {}", args.length, Arrays.stream(args).toArray()); - // serviceprocessor name list from arguments - ArrayList processorNameListFromArguments = getProcessorNameListFromArguments(args); - // - if (processorNameListFromArguments == null || !checkExistProcessorNameList(processorNameListFromArguments)) { - //usage - ProcessorRouter.printUsage(); - } else { - ProcessorRouter processRouter = ProcessorRouter.getInstance(); - for (String processorName : processorNameListFromArguments) { - AGenericProcessor processor = (AGenericProcessor)processRouter.getProcessor(processorName); - new Thread(processor).start(); - } - } - } - - /** - * run parameter("serviceprocessor class name") list. - * - * @param processorNameList serviceprocessor name list - * @return result after checking - */ - private boolean checkExistProcessorNameList(ArrayList processorNameList) { - //check serviceprocessor class - ProcessorRouter processRouter = ProcessorRouter.getInstance(); - for (String processorName : processorNameList) { - log.info("Your serviceprocessor name: {}", processorName); - if (!processRouter.existProcess(processorName)) { - log.error("Your serviceprocessor NOT exist: {}", processorName); - return false; - } - } - return true; - } - - /** - * return serviceprocessor name list from arguments. - * - * @param args arguments - * @return serviceprocessor name list - */ - private ArrayList getProcessorNameListFromArguments(String[] args) { - ArrayList processorNameList = null; - for(String arg: args) { - if (arg.startsWith("-P")) { - if(processorNameList == null) - processorNameList = new ArrayList<>(); - String filteredArgs = StringUtil.getRight(arg, "-P"); - log.debug("filteredArgs: {}", filteredArgs); - String[] processorArray = filteredArgs.split(","); - processorNameList.addAll(Arrays.asList(processorArray)); - log.debug("current processorList: {}", processorNameList); - } - } - return processorNameList; - } - - - /** - * runner test main method. - * - * usage) java -j [jar file] [serviceprocessor name] - * - * @param args serviceprocessor name - */ -// public static void main(String[] args) { -// ProcessorRouter.getInstance().run(args); -// } -} \ No newline at end of file diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java deleted file mode 100644 index f5d16556..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -/** - * cut default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultCut extends AGenericIdentity implements ICut { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java deleted file mode 100644 index a1f79ccd..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenario; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * Scenario default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenario extends AGenericIdentity implements IScenario { - - /** - * scene list - */ - List sceneList = null; - - /** - * scenario context - */ - IScenarioContext scenarioContext = null; - - /** - * constructor - */ - public DefaultScenario() { - } - - /** - * return a ScenarioContext. - * - * @return ScenarioContext - */ - @Override - public IScenarioContext getScenarioContext() { - return scenarioContext; - } - - public void setScenarioContext(IScenarioContext scenarioContext) { - this.scenarioContext = scenarioContext; - } - - /** - * return scene list. - * - * @return List - */ - @Override - public List getSceneList() { - return null; - } - - public void setSceneList(List sceneList) { - this.sceneList = sceneList; - } - - public void addScene(IScene scene) { - this.sceneList.add(scene); - } - - -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java deleted file mode 100644 index be17afab..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.util.registry.AGenericKeyValueRegistry; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * scenario context default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenarioContext extends AGenericKeyValueRegistry implements IScenarioContext { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new LinkedHashMap(); - } - - /** - * return scenario id - * - * @return scenario id - */ - @Override - public String getScenarioId() { - return this.getValue("SCENARIO_ID"); - } - - public void setScenearioId(String id) { - this.addValue("SCENARIO_ID", id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java deleted file mode 100644 index 45023136..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * scene default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScene extends AGenericIdentity implements IScene { - /** - * cut list - */ - List cutList = null; - - /** - * constructor - */ - public DefaultScene() { - } - - /** - * return cut list. - * - * @return List - */ - @Override - public List getCutList() { - return null; - } - - public void setCutList(List cutList) { - this.cutList = cutList; - } - - public void addCut(DefaultCut cut) { - this.cutList.add(cut); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java deleted file mode 100644 index 90c7ea33..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.serviceprocessor.util.devicemapper.IDeviceMapper; -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mapper. - * - * Created by uni4love on 2016. 12. 30.. - */ -public class DeviceMapper implements IDeviceMapper { - - @Override - public List getDevices(IGenericVirtualObject virtualObject) { - return null; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java deleted file mode 100644 index 63bec3c3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mappe interface. - * - * Created by uni4love on 2016. 12. 30.. - */ -public interface IDeviceMapper { - /** - * from VirtualObject. - * - * @param virtualObject - */ - List getDevices(IGenericVirtualObject virtualObject); -} diff --git a/so-serviceprocessor/src/main/resources/banner.txt b/so-serviceprocessor/src/main/resources/banner.txt deleted file mode 100644 index 6dd56601..00000000 --- a/so-serviceprocessor/src/main/resources/banner.txt +++ /dev/null @@ -1,18 +0,0 @@ - _____ -/\ __`\ __ -\ \ \/\ \ __ ____/\_\ ____ - \ \ \ \ \ /'__`\ /',__\/\ \ /',__\ - \ \ \_\ \/\ \L\.\_/\__, `\ \ \/\__, `\ - \ \_____\ \__/.\_\/\____/\ \_\/\____/ - \/_____/\/__/\/_/\/___/ \/_/\/___/ - - - ____ _____ __ __ __ -/\ _`\ __ /\ __`\ /\ \ /\ \__ /\ \__ __ -\ \,\L\_\ __ _ __ __ __/\_\ ___ __ \ \ \/\ \ _ __ ___\ \ \___ __ ___\ \ ,_\ _ __ __ \ \ ,_\/\_\ ___ ___ - \/_\__ \ /'__`\/\`'__\/\ \/\ \/\ \ /'___\ /'__`\ \ \ \ \ \/\`'__\/'___\ \ _ `\ /'__`\ /',__\ \ \//\`'__\/'__`\\ \ \/\/\ \ / __`\ /' _ `\ - /\ \L\ \/\ __/\ \ \/ \ \ \_/ \ \ \/\ \__//\ __/ \ \ \_\ \ \ \//\ \__/\ \ \ \ \/\ __//\__, `\ \ \\ \ \//\ \L\.\\ \ \_\ \ \/\ \L\ \/\ \/\ \ - \ `\____\ \____\\ \_\ \ \___/ \ \_\ \____\ \____\ \ \_____\ \_\\ \____\\ \_\ \_\ \____\/\____/\ \__\ \_\\ \__/.\_\ \__\\ \_\ \____/\ \_\ \_\ - \/_____/\/____/ \/_/ \/__/ \/_/\/____/\/____/ \/_____/\/_/ \/____/ \/_/\/_/\/____/\/___/ \/__/\/_/ \/__/\/_/\/__/ \/_/\/___/ \/_/\/_/ - - \ No newline at end of file diff --git a/so-serviceutil/src/main/resources/application.properties b/so-serviceutil/src/main/resources/application.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/so-util/build.gradle b/so-util/build.gradle index 16cc6b36..f2fcb5a0 100644 --- a/so-util/build.gradle +++ b/so-util/build.gradle @@ -66,8 +66,8 @@ dependencies { //spring-kafka compile 'org.springframework.kafka:spring-kafka:1.2.0.RELEASE' - // http - compile "com.withwiz:httpclientservice:0.1.1" + //base64 + compile group: 'commons-codec', name: 'commons-codec', version: '1.10' //compile("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootVersion}") diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java deleted file mode 100644 index 8c89b3e4..00000000 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.pineone.icbms.so.util; - -import org.apache.kafka.common.serialization.StringDeserializer; -import org.apache.kafka.common.serialization.StringSerializer; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -/** - * settings for message queue. - * Created by uni4love on 2016. 12. 16.. - */ -@Configuration -public class Settings { - /** - * broker(kafka) list - */ - @Value("${mq.broker.list}") - public String brokerList = "localhost:9092"; - - /** - * Zookeeper list - */ - @Value("${mq.zookeeper.list}") - public String zookeeperList = "localhost:2181"; - - //----------------------------- consumer configs - /** - * consumer Poll timeout - */ - @Value("${mq.consumer.pool_timeout}") - public long pollTimeout = 3000L; - - /** - * ENABLE_AUTO_COMMIT_CONFIG - */ - @Value("${mq.consumer.enable_auto_commit}") - public String enableAutoCommitConfig = "true"; - - /** - * AUTO_COMMIT_INTERVAL_MS_CONFIG - */ - @Value("${mq.consumer.auto_commit_interval_ms}") - public String autoCommitIntervalMsConfig = "1000"; - - /** - * SESSION_TIMEOUT_MS_CONFIG - */ - @Value("${mq.consumer.session_timeout_ms}") - public String sessionTimeoutMsConfig= "15000"; - - /** - * AUTO_OFFSET_RESET_CONFIG - */ - @Value("${mq.consumer.auto_offset_reset}") - public String autoOffsetResetConfig= "earliest"; - - /** - * KEY_DESERIALIZER_CLASS_CONFIG - */ - public static String KEY_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - /** - * VALUE_DESERIALIZER_CLASS_CONFIG - */ - public static String VALUE_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - //----------------------------- producer configs - /** - * ACKS_CONFIG - */ - @Value("${mq.producer.acks}") - public String acksConfig= "1"; - - /** - * RETRIES_CONFIG - */ - @Value("${mq.producer.retries}") - public int retriesConfig = 0; - - /** - * BATCH_SIZE_CONFIG - */ - @Value("${mq.producer.batch_size}") - public int batchSizeConfig= 16384; - - /** - * LINGER_MS_CONFIG - */ - @Value("${mq.producer.linger_ms}") - public int lingerMsConfig= 1; - - /** - * BUFFER_MEMORY_CONFIG - */ - @Value("${mq.producer.buffer_memory}") - public int bufferMemoryConfig= 33554432; - - /** - * KEY_SERIALIZER_CLASS_CONFIG - */ - public static String KEY_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - /** - * VALUE_SERIALIZER_CLASS_CONFIG - */ - public static String VALUE_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - - //----------------------------- common configs - /** - * kafka topic: contextmodel - */ - public static String TOPIC_CONTEXT_MODEL = "contextmodel"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_ORCHESTRATION_SERVICE = "orchestrationservice"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_COMPOSITE_VIRTUAL_OBJECT = "compositevirtualobject"; - - /** - * kafka topic: virtual object - */ - public static String TOPIC_VIRTUAL_OBJECT = "virtualobject"; - - /** - * kafka topic: devicecontrol - */ - public static String TOPIC_DEVICE_CONTROL = "devicecontrol"; - - /** - * kafka topic: logging - */ - public static String TOPIC_TRACKING = "tracking"; - - /** - * each serviceprocessor handler count - */ - public static int HANDLER_COUNT = 1; - - /** - * CONTEXTMODEL serviceprocessor handler count - */ - public int HANDLER_CONTEXTMODEL_COUNT = HANDLER_COUNT; - - /** - * ORCHESTRATIONSERVICE serviceprocessor handler count - */ - public int HANDLER_ORCHESTRATIONSERVICE_COUNT = HANDLER_COUNT; - - /** - * VIRTUALOBJECT serviceprocessor handler count - */ - public int HANDELR_VIRTUALOBJECT_COUNT = HANDLER_COUNT; - - /** - * DEVICECONTROL serviceprocessor handler count - */ - public int HANDLER_DEVICECONTROL_COUNT = HANDLER_COUNT; - - /** - * class path for class loader - */ - @Value("${so.device.driver.path}") - public String deviceDriverPath= "/"; - - public String getBrokerList() { - return brokerList; - } - - public void setBrokerList(String brokerList) { - this.brokerList = brokerList; - } - - public String getZookeeperList() { - return zookeeperList; - } - - public void setZookeeperList(String zookeeperList) { - this.zookeeperList = zookeeperList; - } - - public long getPollTimeout() { - return pollTimeout; - } - - public void setPollTimeout(long pollTimeout) { - this.pollTimeout = pollTimeout; - } - - public String getEnableAutoCommitConfig() { - return enableAutoCommitConfig; - } - - public void setEnableAutoCommitConfig(String enableAutoCommitConfig) { - this.enableAutoCommitConfig = enableAutoCommitConfig; - } - - public String getAutoCommitIntervalMsConfig() { - return autoCommitIntervalMsConfig; - } - - public void setAutoCommitIntervalMsConfig(String autoCommitIntervalMsConfig) { - this.autoCommitIntervalMsConfig = autoCommitIntervalMsConfig; - } - - public String getSessionTimeoutMsConfig() { - return sessionTimeoutMsConfig; - } - - public void setSessionTimeoutMsConfig(String sessionTimeoutMsConfig) { - this.sessionTimeoutMsConfig = sessionTimeoutMsConfig; - } - - public String getAutoOffsetResetConfig() { - return autoOffsetResetConfig; - } - - public void setAutoOffsetResetConfig(String autoOffsetResetConfig) { - this.autoOffsetResetConfig = autoOffsetResetConfig; - } - - public String getAcksConfig() { - return acksConfig; - } - - public void setAcksConfig(String acksConfig) { - this.acksConfig = acksConfig; - } - - public int getRetriesConfig() { - return retriesConfig; - } - - public void setRetriesConfig(int retriesConfig) { - this.retriesConfig = retriesConfig; - } - - public int getBatchSizeConfig() { - return batchSizeConfig; - } - - public void setBatchSizeConfig(int batchSizeConfig) { - this.batchSizeConfig = batchSizeConfig; - } - - public int getLingerMsConfig() { - return lingerMsConfig; - } - - public void setLingerMsConfig(int lingerMsConfig) { - this.lingerMsConfig = lingerMsConfig; - } - - public int getBufferMemoryConfig() { - return bufferMemoryConfig; - } - - public void setBufferMemoryConfig(int bufferMemoryConfig) { - this.bufferMemoryConfig = bufferMemoryConfig; - } - - public String getDeviceDriverPath() { - return deviceDriverPath; - } - - public void setDeviceDriverPath(String deviceDriverPath) { - this.deviceDriverPath = deviceDriverPath; - } -} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java index 9b9c5fe4..9ef955ef 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java @@ -28,13 +28,13 @@ public static String getBrokerList() { /** * Zookeeper list */ - public static String zookeeperList = "localhost:2181"; + public static String zookeeperList; // = "localhost:21811"; public static String getZookeeperList() { return zookeeperList; } - @Value("${mq.zookeeper.list}") + //@Value("${mq.zookeeper.list}") public void setZookeeperList(String _zookeeperList) { zookeeperList = _zookeeperList; } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java index 0722ca6f..460475c8 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java @@ -63,6 +63,4 @@ public static List stringDataToList(String data){ public static String base64encoding(String data){ return new String(Base64.encodeBase64(data.getBytes())); } - - } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java similarity index 55% rename from so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java rename to so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java index 84519549..9e82121d 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java @@ -1,11 +1,5 @@ package com.pineone.icbms.so.util.http; -import com.withwiz.beach.network.http.message.IHttpResponseMessage; -import com.withwiz.jellyfish.service.IGenericService; -import com.withwiz.jellyfish.service.ServiceException; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientService; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceRequestDeliveryMessage; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceResponseDeliveryMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -14,8 +8,6 @@ import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; /** * ClientService class @@ -24,162 +16,14 @@ */ @Service -public class ClientService +public class ClientServiceNoTimeout { public static final int DATA_TIMEOUT_VALUE = 90000; public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 - private final Logger log = LoggerFactory.getLogger(ClientService.class); - - /** - * request post service. - * - * @param serviceUrl - * @param body - * @return - * NOTE: URL 로 Body 내용 전송 - */ - public IHttpResponseMessage requestPostService(String serviceUrl, String body) - { - log.info("Client Service requestPostService uri " + serviceUrl); - log.info("Client Service requestPostService data " + body); - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - HashMap headerList = new HashMap(); - headerList.put("Content-Type", "application/json"); - // headerList.put("Content-Length", "238"); - - req.addValue(HttpClientService.KEY_HEADER_PARAMETERS, headerList); - req.addValue(HttpClientService.KEY_SERVICE_URL, serviceUrl); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT, 50000); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_POST); - // req.addValue(HttpClientService); - - // body data - // StringInputStream inputStream = new StringInputStream(body); - ByteArrayInputStream inputStream = new ByteArrayInputStream( - body.getBytes()); - req.addValue(HttpClientService.KEY_BODY_INPUT_STREAM, inputStream); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - IHttpResponseMessage httpResponseMessage = null; - // HttpClientService - IGenericService service = new HttpClientService(); - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - /** - * request get service. - * - * @param uri - * @return - NOTE: 외부에서 데이터를 조회하기 위함. Url 의 내용을 조회 - */ - public IHttpResponseMessage requestGetService(String uri) - { - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - req.addValue(HttpClientService.KEY_SERVICE_URL, uri); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT,DATA_TIMEOUT_VALUE); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_GET); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - - // HttpClientService - IGenericService service = new HttpClientService(); - // return IHttpResponseMessage - IHttpResponseMessage httpResponseMessage = null; - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - private IHttpResponseMessage getiHttpResponseMessage(HttpClientServiceRequestDeliveryMessage req, - HttpClientServiceResponseDeliveryMessage res, - IHttpResponseMessage httpResponseMessage, - IGenericService service) { - try - { - // execute a service - service.onService(req, res); - // get a service response - httpResponseMessage = res - .getValue(HttpClientService.KEY_HTTP_RESPONSE); - // print a response - //System.out.println(res); - } - catch (ServiceException e) - { - System.out.println("connection fail :" + e.getMessage()); - //e.printStackTrace(); - } - return httpResponseMessage; - } - - public String requestPostServiceReceiveString(String uri, String data) { - return requestPostServiceReceiveString(uri,data,false); - } - - public String requestPostServiceReceiveString(String uri, String data, boolean onlyResultValue) { - IHttpResponseMessage httpResponseMessage = requestPostService(uri, data); - String returnData = null; - if (onlyResultValue) { - returnData = String.valueOf(httpResponseMessage.getStatusCode()); - } else { - returnData = responseDataToString(httpResponseMessage); - } - return returnData; - } - - - public String requestGetServiceReceiveString(String uri) { - IHttpResponseMessage httpResponseMessage = requestGetService(uri); - String returnData = responseDataToString(httpResponseMessage); - return returnData; - } - - /** - * response Data to String. - * - * @param message - * @return String - */ - public String responseDataToString(IHttpResponseMessage message) - { - String result = null; - - BufferedReader reader = null; - try - { - reader = new BufferedReader(new InputStreamReader( - message.getBodyInputStream()), 8); - StringBuilder sb = new StringBuilder(); - String line = null; - while ((line = reader.readLine()) != null) - { - sb.append(line); - } - result = sb.toString(); - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return result; - } + private final Logger log = LoggerFactory.getLogger(ClientServiceNoTimeout.class); //======================================================================================================= public String requestPostServiceReceiveString2(String uri, String param) { diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java new file mode 100644 index 00000000..ab752483 --- /dev/null +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java @@ -0,0 +1,182 @@ +package com.pineone.icbms.so.util.http; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.io.*; +import java.net.ConnectException; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * ClientServiceTimeout class + * Created by use on 2015-10-12. + * NOTE: 외부 통신을 위해 사용 + */ + +@Service +public class ClientServiceTimeout +{ + public static final int DATA_TIMEOUT_VALUE = 90000; + + public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 + public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 + + private final Logger log = LoggerFactory.getLogger(ClientServiceTimeout.class); + + public String requestPostServiceReceiveString2(String uri, String param) { + return requestPostServiceReceiveString2(uri, param, false); + } + + public String requestPostServiceReceiveString2(String uri, String param, boolean timeOut) + { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestPostServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + //log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + conn.setRequestMethod("POST"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + OutputStream out_stream = conn.getOutputStream(); + out_stream.write( param.getBytes("UTF-8") ); + log.info("requestPostServiceReceiveString2:[{}]:[{}] ", uri, out_stream.toString()); + out_stream.flush(); + out_stream.close(); + + log.info("out_stream close.."); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + //log.info("getInputStream.."); + + InputStream is = conn.getInputStream(); + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + + String line = null; + StringBuffer buff = new StringBuffer(); + + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###1 POST Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###1 POST Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + + + public String requestGetServiceReceiveString2(String uri) { + return requestGetServiceReceiveString2(uri, false); + } + public String requestGetServiceReceiveString2(String uri, boolean timeOut) { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestGetServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + + conn.setRequestMethod("GET"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + // conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.connect(); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + + //log.info("getInputStream.."); + InputStream is = conn.getInputStream(); + + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + String line = null; + StringBuffer buff = new StringBuffer(); + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###2 GET Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###2 GET Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + +} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java index 8bff1204..548f0aad 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java @@ -30,7 +30,7 @@ public static Long createRandomLongValue() { * @param args */ public static void main(String[] args) { - System.out.println(IdUtils.createRandomUUID()); - System.out.println(IdUtils.createRandomLongValue()); + //System.out.println(IdUtils.createRandomUUID()); + //System.out.println(IdUtils.createRandomLongValue()); } } diff --git a/so-util/src/test/java/Jackson_Test.java b/so-util/src/test/java/Jackson_Test.java deleted file mode 100644 index a9f8b606..00000000 --- a/so-util/src/test/java/Jackson_Test.java +++ /dev/null @@ -1,62 +0,0 @@ -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by melvin on 2017. 4. 18.. - */ - -public class Jackson_Test { - - @Test - public void name() throws Exception { - List testObjectList = new ArrayList<>(); - - TestObject testObject1 = new TestObject("5", "5", "5"); - TestObject testObject2 = new TestObject("6", "6", "6"); - TestObject testObject3 = new TestObject("7", "7", "7"); - - testObjectList.add(testObject1); - testObjectList.add(testObject2); - testObjectList.add(testObject3); - - ObjectMapper objectMapper = new ObjectMapper(); - - // List --> String - String testObjListStr = objectMapper.writeValueAsString(testObjectList); - System.out.println("*******funcListStr******** " + testObjListStr); - - // String --> List - List testObjects = objectMapper.readValue(testObjListStr, new TypeReference>() { - }); - System.out.println("*******funcList******** " + testObjects); - - // Class --> String - TestObject testObject = testObjects.get(0); - String testObjStr = objectMapper.writeValueAsString(testObject); - System.out.println("*******funcStr******** " + testObjStr); - - // String --> Class - TestObject testClass = objectMapper.readValue(testObjStr, TestObject.class); - System.out.println("*******funcClass******** " + testClass); - System.out.println("*******funcClass.name******** " + testClass.getName()); - - - List test = new ArrayList<>(); - - test.add("testObject1"); - test.add("testObject2"); - test.add("testObject3"); - - objectMapper = new ObjectMapper(); - - // List --> String - testObjListStr = objectMapper.writeValueAsString(test); - System.out.println("*******string array******** " + testObjListStr); - } - -} - diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java index 40846e69..19ccbecf 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java @@ -12,7 +12,6 @@ import com.pineone.icbms.so.interfaces.database.ref.DataValidation; import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; import com.pineone.icbms.so.interfaces.messagequeue.model.ContextModelForMQ; -import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; import com.pineone.icbms.so.interfaces.sda.model.ContextModelForIf2; import com.pineone.icbms.so.interfaces.si.handle.DeviceManager; @@ -20,7 +19,6 @@ import com.pineone.icbms.so.util.messagequeue.producer.DefaultProducerHandler; import com.pineone.icbms.so.web.model.context.Content; import com.pineone.icbms.so.web.model.context.ContextModel; -import com.pineone.icbms.so.web.model.context.ContextModelTransFormObject; import com.pineone.icbms.so.web.model.context.ResponseMessage; import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; import com.pineone.icbms.so.web.util.ContextModelMapper2; @@ -56,34 +54,6 @@ public class ContextModelController { @Autowired DataBaseStore dataBaseStore; -// /** -// * response for request "/context/cm, HTTP-method:POST". -// * -// * @param contextModelForIf ContextModelForIf -// * @return created DeviceControlCallbackForDB id -// */ -// @RequestMapping(value = "/cm", method = RequestMethod.POST) -// public String injectContextModel(@RequestBody ContextModelForIf contextModelForIf) { -// log.debug("input:ContextModelForIf: {}", contextModelForIf); -// // create a message From ContextModelForMQ for messageQueue, publish to message queue -// // ContextModelForIf --> ContextModelForMQ -// ContextModelForMQ contextModelForMQ = ModelMapper.toContextModelForMQ(contextModelForIf); -// log.debug("converted:ContextModelForMQ: {}", contextModelForMQ); -// //object to json -// String contextModelForMqString = ModelMapper.writeJsonString(contextModelForMQ); -// log.debug("generated:ContextModelForMQ {}", contextModelForMqString); -// //context model producer handler -//// ContextModelProducerHandler producerHandler = new ContextModelProducerHandler(0); -//// Future future = producerHandler.send(contextModelForMqString); -// DefaultProducerHandler producerHandler = new DefaultProducerHandler(0, "contextmodel"); -// Future future = producerHandler.send(contextModelForMQ); -// log.debug("producer.send result: {}", future); -// producerHandler.close(); -// -// //TODO: 추후 처리 결과를 정의하여 리턴함. -// return contextModelForMqString; -// } - /** * response for request "/service/context/cm, HTTP-method:POST". * @@ -189,7 +159,7 @@ private ContextModelForMQ processContextModel(ContextModelForIf2 contextModelFor //@PostMapping(value = "/test") public void testCode(HttpServletRequest request) { - DeviceManager.testmain(null); + new DeviceManager().testmain(null); } /** @@ -296,34 +266,6 @@ public ResponseMessage emergencyContextModel(@RequestBody ContextModelForIf2 con return responseMessage; } - private DataValidation newDataValidation(){ - DataValidation dataValidation = new DataValidation(); - return dataValidation; - } - - private void inspectContextModel(ContextModel contextModel) throws DataLossException { - // - if(contextModel.getId() == null || contextModel.getContextType() == null || - contextModel.getDomainIdList() == null){ - throw new DataLossException(); - } - } - -/* - private ContextModel dataObjectToContextModel(ContextModelTransFormObject contextModelDataObject){ - if(contextModelDataObject == null) return null; - return new ContextModel(contextModelDataObject.getContextId(), contentsToStringList(contextModelDataObject.getContents()), - contextModelDataObject.getCmd(), contextModelDataObject.getTime()); - } -*/ - private List contentsToStringList(List contentsList){ - - List domains = new ArrayList<>(); - for(Content content : contentsList){ - domains.add(content.getLoc()); - } - return domains; - } public String useQueueSaveContextModel(ContextModel contextModel) { // diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java new file mode 100644 index 00000000..1ab2407f --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java @@ -0,0 +1,54 @@ +package com.pineone.icbms.so.web.interfaces.api; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import com.kastkode.springsandwich.filter.annotation.Before; +import com.kastkode.springsandwich.filter.annotation.BeforeElement; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; +import com.pineone.icbms.so.web.model.measure.ResMeasuring; +import com.pineone.icbms.so.web.service.IMeasuringService; +import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; + +@Before(@BeforeElement(BeforeTtrackingHandler.class)) +@CrossOrigin(origins = "*") +@RestController +@RequestMapping(value = "/servicemodel") +public class MeasuringController { + + @Autowired + IMeasuringService measuringService; + + @RequestMapping(value = "/measure",method = RequestMethod.POST) + @ResponseStatus(value = HttpStatus.OK) + @ResponseBody + public ResMeasuring getMeasuredData(@RequestBody ReqMeasuring req, HttpServletRequest request) { + + ResMeasuring res = new ResMeasuring(); + TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); + String sessionId = trackingEntity.getSessionId(); + res.setSessionId(sessionId); + + Object r = measuringService.getMeasuredData(req, request, trackingEntity); + if (r==null) { + String failMsg = "No service data"; + res.setResultMessage(failMsg); + res.setResultCode(404); // No Information + }else { + res.setResultMessage(r); + res.setResultCode(200); //SUCCESS + } + + return res; + } +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java index d15dd908..b9aa4b92 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java @@ -59,116 +59,6 @@ public class ProfileController { @Autowired DatabaseManager databaseManager; - /** - * response for request "/profile, HTTP-method:POST". - * scheduler가 특정 주기로 호출됨 - * - * @param profileTransFormData profile - * @return profile - */ - @RequestMapping(value = "/schedule1", method = RequestMethod.POST) - public IGenericProfile callFromScheduler(@RequestBody ProfileTransFormData profileTransFormData, HttpServletRequest request) { - - if (profileTransFormData==null) { - contextLog.warn("Input Profile is null"); - return null; - } - String inputProfileId = profileTransFormData.getId(); - contextLog.debug("Checking CM by schedule : input profile=[{}]", inputProfileId); - - ProfileForDB profileForDb = databaseManager.getProfileById(profileTransFormData.getId()); - IGenericProfile profile = ModelMapper.toProfile(profileForDb); - - SessionEntity sessionEntity = new SessionEntity(); - - if (profile==null) { - contextLog.warn("Profile is null"); - return null; - } - - IGenericContextModel contextModel = profile.getContextModel(); - if (contextModel == null) { - contextLog.warn( "contextModel is null"); - return null; - } - - String contextModelId = contextModel.getId(); - ContextModelForDB cm = databaseManager.getContextModelById(contextModelId); - String contextModelName = cm.getName(); - - TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); - String sessionId = trackingEntity.getSessionId(); - String priority = profileForDb.getPriority(); - - // grib session - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelKey(contextModelId); - sessionEntity.setContextmodelName(contextModelName); - sessionEntity.setContextmodelResult("NotHappen"); - sessionEntity.setPriorityKey(priority); - //contextLog.debug("session : {}", sessionEntity); - - // grib session profile - //SessionEntity sessionProfile = new SessionEntity(); - //sessionEntity.setId(sessionId); - sessionEntity.setProfileKey(profile.getId()); - sessionEntity.setProfileName(profile.getName()); - //contextLog.debug("session profile : {}", sessionEntity); - - databaseManager.createSessionData(sessionEntity); - - boolean isCmProceed = false; //CM 처리되었나? - - //SDA로 부터 CM발생 여부 체크 - List locationList = new SdaManager().retrieveEventLocationList(contextModelId); - - contextLog.debug("called SDA: cm={}, name={}, location={}", contextModelId, contextModelName, locationList.toString()); - - if (locationList != null && locationList.size() > 0) { - - for (String location : locationList) { - if (location.equals(profile.getLocation().getUri())) { - //scheduler 또는 에 의한 Profile 내 OS 구동임을 남겨야 함 - - ContextModelHandler contextModelHandler = new ContextModelHandler(databaseManager); - contextModelHandler.setTracking(trackingEntity); - contextModelHandler.profileHandle(profile); - isCmProceed = true; - - //sessionEntity.setContextmodelResult("Happen"); - //databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(location); - databaseManager.createSessionDataLocation(sessionLocation); - - contextLog.warn("O: result: Happen cm=[{}], Location={} , sessionId={}", contextModelId, location, sessionId); - //contextLog.debug("session location : {}", sessionLocation); - } - } - } - - //Location이 없거나 처리되지 않았을때 - if (isCmProceed == false) { - contextLog.warn("X: result: Not happened cm=[{}]", contextModelId); - - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelResult("NotHappen"); - databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(""); - databaseManager.createSessionDataLocation(sessionLocation); - - //contextLog.debug("session location : {}", sessionLocation); - } - return profile; - } - /** * response for request "/profile, HTTP-method:POST". * scheduler가 특정 주기로 호출됨 diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java index 295de4f1..128d5d94 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java @@ -25,16 +25,6 @@ @ResponseStatus(value = HttpStatus.OK) public class SessionController { -// @Autowired -// SessionStore sessionStore; -// -// @RequestMapping(value = "/{number}", method = RequestMethod.GET) -// @ResponseStatus(value = HttpStatus.OK) -// public List retrieveSessionData(@PathVariable int number){ -// List sessionList = sessionStore.retrieveRecentlyDataList(number); -// return sessionToTransFormObject(sessionList); -// } - @Autowired //TrackingDao trackingDao; SessionDao sessionDao; @@ -86,8 +76,10 @@ public List retrieveSessionData(@PathVariable Integer nu sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(entity.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", entity.getVirtualobjectResult()); - - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", entity.getDeviceResult()); @@ -145,7 +137,9 @@ public SessionTransFormObject retrieveSessionDataOne(@PathVariable String sessio sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(sessionDataDb.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", sessionDataDb.getVirtualobjectResult()); - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", sessionDataDb.getDeviceResult()); diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java new file mode 100644 index 00000000..257e98fa --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java @@ -0,0 +1,27 @@ +package com.pineone.icbms.so.web.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) +public class MeasuringData { + + @Getter@Setter + private String devId ; + + @Getter@Setter + private String devName ; + + @Getter@Setter + private String devTypeDesc; + + @Getter@Setter + private String aspectName; + + @Getter@Setter + private String measuringValue; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java new file mode 100644 index 00000000..a90b4164 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java @@ -0,0 +1,21 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ReqMeasuring { + @Getter@Setter + @JsonProperty("serviceName") + String serviceName; + + @Getter@Setter + @JsonProperty("location") + String location; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java new file mode 100644 index 00000000..a5921508 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java @@ -0,0 +1,26 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ResMeasuring { + @Getter@Setter + @JsonProperty("resultCode") + Integer resultCode; + + @Getter@Setter + @JsonProperty("resultMessage") + Object resultMessage; + + @Getter@Setter + @JsonProperty("sessionId") + String sessionId; +} + diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java new file mode 100644 index 00000000..da096394 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java @@ -0,0 +1,12 @@ +package com.pineone.icbms.so.web.service; + +import javax.servlet.http.HttpServletRequest; + +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +public interface IMeasuringService { + + Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity); + +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java new file mode 100644 index 00000000..a0d60a2c --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java @@ -0,0 +1,192 @@ +package com.pineone.icbms.so.web.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.pineone.icbms.so.interfaces.database.dao.OrchestrationServiceDao; +import com.pineone.icbms.so.interfaces.database.model.DeviceTypeForDB; +import com.pineone.icbms.so.interfaces.database.model.LocationForDB; +import com.pineone.icbms.so.interfaces.database.model.MeasuringVoForDB; +import com.pineone.icbms.so.interfaces.database.model.OrchestrationServiceForDB; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; +import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; +import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; +import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; +import com.pineone.icbms.so.web.model.MeasuringData; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +import lombok.Getter; +import lombok.Setter; + +@Service +public class MeasuringService implements IMeasuringService { + @Autowired + //IDataBaseStore dataBaseStore; + DataBaseStore dataBaseStore; + + //@Autowired + //protected DatabaseManager databaseManager; + + @Autowired + OrchestrationServiceDao orchestrationServiceDao; + + @Getter @Setter + TrackingEntity tracking; + + protected Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity) { + + //입력 파라미터 + String locId = req.getLocation(); //설치 위치 + String serviceName = req.getServiceName(); //OS 이름 + + //설치 장소 + LocationForDB locForDB = dataBaseStore.getLocationById(locId); + String locationUri = locForDB.getUri(); + String locName = locForDB.getName(); + + + //1) OS Name으로 osId얻기 + OrchestrationServiceForDB param = new OrchestrationServiceForDB(); + param.setName(serviceName); + + List osForDbList = orchestrationServiceDao.retrieve(param); + if (osForDbList==null || osForDbList.size()==0) { //일치되는 자료 없음 + log.error("Service Info ({}) not found", serviceName); //orchestration_service : name + return null; + } + OrchestrationServiceForDB osForDb = osForDbList.get(0); + String osId = osForDb.getId(); + + //2) os id 로 MeasuringVoForDB 목록을 조회한다 + // osId로 rule_body/rule_item에서 vo list 얻기 : (rule_item의 functionality_id가 FUNCTIONALITY_TYPE_MEASURING인 값만 선택) + // cvo_type이 NONDEVICE_CVO인 경우에는 noncvo테이블을 참조하여 확장 + log.debug("getRuleBodyListByOsId : {}", osId); + List measuringVoForDBList = dataBaseStore.getMeasuringVoList(osId); + + // 측정데이타를 저장할 변수 생성 + List measuringDataList = new ArrayList<>(); + + //3) MeasuringVoForDB의 item별로 동작 + for (MeasuringVoForDB measuringVoItem:measuringVoForDBList) { + + String cvoBaseId = measuringVoItem.getBaseCvoId(); + String cvoType = measuringVoItem.getCvoType(); + + // BaseCvoId 부터 유효 VO 목록을 가져온다. + List validVoList = dataBaseStore.getVirtualObjectListByCompositeVirtualObjectId(cvoBaseId); + if (validVoList.size()==0) { + log.error("Not exist vo list by cvoBase={}", cvoBaseId); + continue; + } + String vId = measuringVoItem.getVoId(); + String aspectUri = null; + String voDesc = null; + + //VO값이 유효한 Vo인지 검사한다. + for (VirtualObjectForDB validVo:validVoList) { + if (vId.equals(validVo.getId())){ + aspectUri = validVo.getAspectUri(); //첫번째 VO만 참조하여 URI를 가져옴 + voDesc = validVo.getDescription(); + break; + } + } + + //유효하지 않으면 + if (aspectUri == null ) { //SKIP + log.error("Not exist aspectUri by list by vId={}", vId); + continue; + } + + // 4) cvo_type별로 sda에서 값 읽기 + List contentList = null; + //4-1) CVO_TYPE_DEVICETYPE or CVO_TYPE_DEVICETYPE_ASPECT + if (cvoType.equals("CVO_TYPE_DEVICETYPE") || cvoType.equals("CVO_TYPE_DEVICETYPE_ASPECT")) { + String physicalDeviceTypeId = measuringVoItem.getPhysicalDeviceTypeId(); + + //PysicalDeviceTypeUri + DeviceTypeForDB typeDb = dataBaseStore.retrieveDeviceTypeById(physicalDeviceTypeId); + if (typeDb==null) { + log.error("error : Device Type info is not exist : physicalDeviceTypeId={}", physicalDeviceTypeId); + continue; + } + String physicalDeviceTypeUri = typeDb.getPhysicalDeviceTypeUri(); + + contentList = new SdaManager().getMeasuringValueByLocDeviceTypeAspect(locationUri, physicalDeviceTypeUri, aspectUri); + } + //4-2) CVO_TYPE_ASPECT + else if (cvoType.equals("CVO_TYPE_ASPECT")) { + + contentList = new SdaManager().getMeasuringValueByLocAspect(locationUri, aspectUri); + } + //4-3) CVO_TYPE_DEVICEID + else if (cvoType.equals("CVO_TYPE_DEVICEID")) { + + String deviceUri = measuringVoItem.getDeviceId(); + contentList = new SdaManager().getMeasuringValueByDevIdAspect(deviceUri, aspectUri); + + } else { + // SKIP + } + + if (contentList != null) { + for (ContextModelContent contentItem:contentList) { + + MeasuringData md = new MeasuringData(); + + md.setDevId(contentItem.getDeviceUri()); + md.setDevName(contentItem.getDeviceName()); + md.setDevTypeDesc(contentItem.getDeviceTypeDesc()); + md.setAspectName(voDesc); + md.setMeasuringValue(contentItem.getValue()); + + measuringDataList.add(md); + } + } + } + +/* + String contextModelId="measuring"; + String contextModelName="Measureing"; + + setTracking((TrackingEntity) request.getSession().getAttribute("tracking")); + String sessionId = trackingEntity.getSessionId(); + + // grib session + SessionEntity sessionEntity = new SessionEntity(); + sessionEntity.setId(sessionId); + sessionEntity.setContextmodelKey(contextModelId); + sessionEntity.setContextmodelName(contextModelName); + sessionEntity.setContextmodelResult("NotHappen"); + sessionEntity.setProfileName(serviceName); + //sessionEntity.setPriorityKey("LOW"); + log.debug("session : {}", sessionEntity); + dataBaseStore.createSessionData(sessionEntity); + + + // grib session location + SessionEntity sessionLocation = new SessionEntity(); + sessionLocation.setId(sessionId); + sessionLocation.setLocationId(locationUri); + log.debug("session location : {}", sessionLocation); + try { + dataBaseStore.createSessionDataLocation(sessionLocation); + }catch(Exception e) { + log.error("Error createSessionDataLocation : error={},\n sessionLocation={}", e.getMessage(), sessionLocation); + } +*/ + + return measuringDataList; + } + +}
- * Created by uni4love on 2016. 11. 24.. - */ -@Component -public final class ProcessorRouter { - /** - * logger - */ - private Logger log = LoggerFactory.getLogger(ProcessorRouter.class); - - /** - * process line - */ - private ProcessLine line = new ProcessLine(); - - /** - * serviceprocessor list, - * - * TODO: 추후 class loader를 이용하여 동적으로 구동하도록 처리 요망. - * TODO: 외부에서 inject할 수 있도록 함. - * TODO: filter class도 동일 라인에 추가 가능. - */ - static Class[] processorList = { - ContextModelProcessor.class, - OrchestrationServiceProcessor.class, - VirtualObjectProcessor.class, - DeviceControlProcessor.class - }; - - /** - * singleton instance holder - */ - private static final class SingletonHolder { - static final ProcessorRouter singleton = new ProcessorRouter(); - } - - /** - * constructor - */ - private ProcessorRouter() { - init(); - } - - /** - * return ProcessorRunner singleton instance. - * - * @return ProcessorRunner - */ - public static ProcessorRouter getInstance() { - return SingletonHolder.singleton; - } - - /** - * initialize - */ - private void init() { - //instance objects - reload(); - } - - /** - * reload environments - */ - public void reload() { - //load classes - loadClass(); - } - - /** - * load classes. - */ - private void loadClass() { - //temporary load static classes; - //serviceprocessor id is name. - for (Class clz : processorList) { - Class> cls = null; - Class[] args = new Class[]{String.class, String.class}; - try { - cls = Class.forName(clz.getName()); - Constructor constructor = cls.getConstructor(args); - //parameters: id, name - Object obj = constructor.newInstance(IdUtils.createRandomUUID(), cls.getName()); - addProcessor((IGenericProcessor) obj); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } - - /** - * add a serviceprocessor to registry. - * - * @param processor serviceprocessor - */ - public void addProcessor(IGenericProcessor processor) { - this.line.addProcessor(processor); - } - - /** - * return a serviceprocessor from registry. - * - * @param key key for finding a serviceprocessor. - * @return IGenericProcessor - */ - public IGenericProcessor getProcessor(String key) { - return this.line.getProcessor(key); - } - - /** - * return existence of serviceprocessor - * - * @param processorName name - */ - public boolean existProcess(String processorName) { - return line.existProcessor(processorName); - } - - /** - * print USAGE. - */ - public static void printUsage() { - StringBuilder sb = new StringBuilder("# Usage) java -jar so-serviceprocessor.jar -P[processor1,processor2,..]\n"); - sb.append("\n= current serviceprocessor name list:\n"); - for (Class cls : processorList) { - sb.append("+- " + cls.getName() + "\n"); - } - System.out.println(sb); - } - - /** - * run processors. - * - * @param args runnable serviceprocessor name - */ - public void run(String[] args) { -// log.info("user.dir: {}", System.getProperty("user.dir")); - log.debug("arguments[{}]: {}", args.length, Arrays.stream(args).toArray()); - // serviceprocessor name list from arguments - ArrayList processorNameListFromArguments = getProcessorNameListFromArguments(args); - // - if (processorNameListFromArguments == null || !checkExistProcessorNameList(processorNameListFromArguments)) { - //usage - ProcessorRouter.printUsage(); - } else { - ProcessorRouter processRouter = ProcessorRouter.getInstance(); - for (String processorName : processorNameListFromArguments) { - AGenericProcessor processor = (AGenericProcessor)processRouter.getProcessor(processorName); - new Thread(processor).start(); - } - } - } - - /** - * run parameter("serviceprocessor class name") list. - * - * @param processorNameList serviceprocessor name list - * @return result after checking - */ - private boolean checkExistProcessorNameList(ArrayList processorNameList) { - //check serviceprocessor class - ProcessorRouter processRouter = ProcessorRouter.getInstance(); - for (String processorName : processorNameList) { - log.info("Your serviceprocessor name: {}", processorName); - if (!processRouter.existProcess(processorName)) { - log.error("Your serviceprocessor NOT exist: {}", processorName); - return false; - } - } - return true; - } - - /** - * return serviceprocessor name list from arguments. - * - * @param args arguments - * @return serviceprocessor name list - */ - private ArrayList getProcessorNameListFromArguments(String[] args) { - ArrayList processorNameList = null; - for(String arg: args) { - if (arg.startsWith("-P")) { - if(processorNameList == null) - processorNameList = new ArrayList<>(); - String filteredArgs = StringUtil.getRight(arg, "-P"); - log.debug("filteredArgs: {}", filteredArgs); - String[] processorArray = filteredArgs.split(","); - processorNameList.addAll(Arrays.asList(processorArray)); - log.debug("current processorList: {}", processorNameList); - } - } - return processorNameList; - } - - - /** - * runner test main method. - * - * usage) java -j [jar file] [serviceprocessor name] - * - * @param args serviceprocessor name - */ -// public static void main(String[] args) { -// ProcessorRouter.getInstance().run(args); -// } -} \ No newline at end of file diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java deleted file mode 100644 index f5d16556..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -/** - * cut default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultCut extends AGenericIdentity implements ICut { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java deleted file mode 100644 index a1f79ccd..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenario; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * Scenario default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenario extends AGenericIdentity implements IScenario { - - /** - * scene list - */ - List sceneList = null; - - /** - * scenario context - */ - IScenarioContext scenarioContext = null; - - /** - * constructor - */ - public DefaultScenario() { - } - - /** - * return a ScenarioContext. - * - * @return ScenarioContext - */ - @Override - public IScenarioContext getScenarioContext() { - return scenarioContext; - } - - public void setScenarioContext(IScenarioContext scenarioContext) { - this.scenarioContext = scenarioContext; - } - - /** - * return scene list. - * - * @return List - */ - @Override - public List getSceneList() { - return null; - } - - public void setSceneList(List sceneList) { - this.sceneList = sceneList; - } - - public void addScene(IScene scene) { - this.sceneList.add(scene); - } - - -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java deleted file mode 100644 index be17afab..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.util.registry.AGenericKeyValueRegistry; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * scenario context default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenarioContext extends AGenericKeyValueRegistry implements IScenarioContext { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new LinkedHashMap(); - } - - /** - * return scenario id - * - * @return scenario id - */ - @Override - public String getScenarioId() { - return this.getValue("SCENARIO_ID"); - } - - public void setScenearioId(String id) { - this.addValue("SCENARIO_ID", id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java deleted file mode 100644 index 45023136..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * scene default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScene extends AGenericIdentity implements IScene { - /** - * cut list - */ - List cutList = null; - - /** - * constructor - */ - public DefaultScene() { - } - - /** - * return cut list. - * - * @return List - */ - @Override - public List getCutList() { - return null; - } - - public void setCutList(List cutList) { - this.cutList = cutList; - } - - public void addCut(DefaultCut cut) { - this.cutList.add(cut); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java deleted file mode 100644 index 90c7ea33..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.serviceprocessor.util.devicemapper.IDeviceMapper; -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mapper. - * - * Created by uni4love on 2016. 12. 30.. - */ -public class DeviceMapper implements IDeviceMapper { - - @Override - public List getDevices(IGenericVirtualObject virtualObject) { - return null; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java deleted file mode 100644 index 63bec3c3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mappe interface. - * - * Created by uni4love on 2016. 12. 30.. - */ -public interface IDeviceMapper { - /** - * from VirtualObject. - * - * @param virtualObject - */ - List getDevices(IGenericVirtualObject virtualObject); -} diff --git a/so-serviceprocessor/src/main/resources/banner.txt b/so-serviceprocessor/src/main/resources/banner.txt deleted file mode 100644 index 6dd56601..00000000 --- a/so-serviceprocessor/src/main/resources/banner.txt +++ /dev/null @@ -1,18 +0,0 @@ - _____ -/\ __`\ __ -\ \ \/\ \ __ ____/\_\ ____ - \ \ \ \ \ /'__`\ /',__\/\ \ /',__\ - \ \ \_\ \/\ \L\.\_/\__, `\ \ \/\__, `\ - \ \_____\ \__/.\_\/\____/\ \_\/\____/ - \/_____/\/__/\/_/\/___/ \/_/\/___/ - - - ____ _____ __ __ __ -/\ _`\ __ /\ __`\ /\ \ /\ \__ /\ \__ __ -\ \,\L\_\ __ _ __ __ __/\_\ ___ __ \ \ \/\ \ _ __ ___\ \ \___ __ ___\ \ ,_\ _ __ __ \ \ ,_\/\_\ ___ ___ - \/_\__ \ /'__`\/\`'__\/\ \/\ \/\ \ /'___\ /'__`\ \ \ \ \ \/\`'__\/'___\ \ _ `\ /'__`\ /',__\ \ \//\`'__\/'__`\\ \ \/\/\ \ / __`\ /' _ `\ - /\ \L\ \/\ __/\ \ \/ \ \ \_/ \ \ \/\ \__//\ __/ \ \ \_\ \ \ \//\ \__/\ \ \ \ \/\ __//\__, `\ \ \\ \ \//\ \L\.\\ \ \_\ \ \/\ \L\ \/\ \/\ \ - \ `\____\ \____\\ \_\ \ \___/ \ \_\ \____\ \____\ \ \_____\ \_\\ \____\\ \_\ \_\ \____\/\____/\ \__\ \_\\ \__/.\_\ \__\\ \_\ \____/\ \_\ \_\ - \/_____/\/____/ \/_/ \/__/ \/_/\/____/\/____/ \/_____/\/_/ \/____/ \/_/\/_/\/____/\/___/ \/__/\/_/ \/__/\/_/\/__/ \/_/\/___/ \/_/\/_/ - - \ No newline at end of file diff --git a/so-serviceutil/src/main/resources/application.properties b/so-serviceutil/src/main/resources/application.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/so-util/build.gradle b/so-util/build.gradle index 16cc6b36..f2fcb5a0 100644 --- a/so-util/build.gradle +++ b/so-util/build.gradle @@ -66,8 +66,8 @@ dependencies { //spring-kafka compile 'org.springframework.kafka:spring-kafka:1.2.0.RELEASE' - // http - compile "com.withwiz:httpclientservice:0.1.1" + //base64 + compile group: 'commons-codec', name: 'commons-codec', version: '1.10' //compile("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootVersion}") diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java deleted file mode 100644 index 8c89b3e4..00000000 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.pineone.icbms.so.util; - -import org.apache.kafka.common.serialization.StringDeserializer; -import org.apache.kafka.common.serialization.StringSerializer; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -/** - * settings for message queue. - * Created by uni4love on 2016. 12. 16.. - */ -@Configuration -public class Settings { - /** - * broker(kafka) list - */ - @Value("${mq.broker.list}") - public String brokerList = "localhost:9092"; - - /** - * Zookeeper list - */ - @Value("${mq.zookeeper.list}") - public String zookeeperList = "localhost:2181"; - - //----------------------------- consumer configs - /** - * consumer Poll timeout - */ - @Value("${mq.consumer.pool_timeout}") - public long pollTimeout = 3000L; - - /** - * ENABLE_AUTO_COMMIT_CONFIG - */ - @Value("${mq.consumer.enable_auto_commit}") - public String enableAutoCommitConfig = "true"; - - /** - * AUTO_COMMIT_INTERVAL_MS_CONFIG - */ - @Value("${mq.consumer.auto_commit_interval_ms}") - public String autoCommitIntervalMsConfig = "1000"; - - /** - * SESSION_TIMEOUT_MS_CONFIG - */ - @Value("${mq.consumer.session_timeout_ms}") - public String sessionTimeoutMsConfig= "15000"; - - /** - * AUTO_OFFSET_RESET_CONFIG - */ - @Value("${mq.consumer.auto_offset_reset}") - public String autoOffsetResetConfig= "earliest"; - - /** - * KEY_DESERIALIZER_CLASS_CONFIG - */ - public static String KEY_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - /** - * VALUE_DESERIALIZER_CLASS_CONFIG - */ - public static String VALUE_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - //----------------------------- producer configs - /** - * ACKS_CONFIG - */ - @Value("${mq.producer.acks}") - public String acksConfig= "1"; - - /** - * RETRIES_CONFIG - */ - @Value("${mq.producer.retries}") - public int retriesConfig = 0; - - /** - * BATCH_SIZE_CONFIG - */ - @Value("${mq.producer.batch_size}") - public int batchSizeConfig= 16384; - - /** - * LINGER_MS_CONFIG - */ - @Value("${mq.producer.linger_ms}") - public int lingerMsConfig= 1; - - /** - * BUFFER_MEMORY_CONFIG - */ - @Value("${mq.producer.buffer_memory}") - public int bufferMemoryConfig= 33554432; - - /** - * KEY_SERIALIZER_CLASS_CONFIG - */ - public static String KEY_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - /** - * VALUE_SERIALIZER_CLASS_CONFIG - */ - public static String VALUE_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - - //----------------------------- common configs - /** - * kafka topic: contextmodel - */ - public static String TOPIC_CONTEXT_MODEL = "contextmodel"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_ORCHESTRATION_SERVICE = "orchestrationservice"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_COMPOSITE_VIRTUAL_OBJECT = "compositevirtualobject"; - - /** - * kafka topic: virtual object - */ - public static String TOPIC_VIRTUAL_OBJECT = "virtualobject"; - - /** - * kafka topic: devicecontrol - */ - public static String TOPIC_DEVICE_CONTROL = "devicecontrol"; - - /** - * kafka topic: logging - */ - public static String TOPIC_TRACKING = "tracking"; - - /** - * each serviceprocessor handler count - */ - public static int HANDLER_COUNT = 1; - - /** - * CONTEXTMODEL serviceprocessor handler count - */ - public int HANDLER_CONTEXTMODEL_COUNT = HANDLER_COUNT; - - /** - * ORCHESTRATIONSERVICE serviceprocessor handler count - */ - public int HANDLER_ORCHESTRATIONSERVICE_COUNT = HANDLER_COUNT; - - /** - * VIRTUALOBJECT serviceprocessor handler count - */ - public int HANDELR_VIRTUALOBJECT_COUNT = HANDLER_COUNT; - - /** - * DEVICECONTROL serviceprocessor handler count - */ - public int HANDLER_DEVICECONTROL_COUNT = HANDLER_COUNT; - - /** - * class path for class loader - */ - @Value("${so.device.driver.path}") - public String deviceDriverPath= "/"; - - public String getBrokerList() { - return brokerList; - } - - public void setBrokerList(String brokerList) { - this.brokerList = brokerList; - } - - public String getZookeeperList() { - return zookeeperList; - } - - public void setZookeeperList(String zookeeperList) { - this.zookeeperList = zookeeperList; - } - - public long getPollTimeout() { - return pollTimeout; - } - - public void setPollTimeout(long pollTimeout) { - this.pollTimeout = pollTimeout; - } - - public String getEnableAutoCommitConfig() { - return enableAutoCommitConfig; - } - - public void setEnableAutoCommitConfig(String enableAutoCommitConfig) { - this.enableAutoCommitConfig = enableAutoCommitConfig; - } - - public String getAutoCommitIntervalMsConfig() { - return autoCommitIntervalMsConfig; - } - - public void setAutoCommitIntervalMsConfig(String autoCommitIntervalMsConfig) { - this.autoCommitIntervalMsConfig = autoCommitIntervalMsConfig; - } - - public String getSessionTimeoutMsConfig() { - return sessionTimeoutMsConfig; - } - - public void setSessionTimeoutMsConfig(String sessionTimeoutMsConfig) { - this.sessionTimeoutMsConfig = sessionTimeoutMsConfig; - } - - public String getAutoOffsetResetConfig() { - return autoOffsetResetConfig; - } - - public void setAutoOffsetResetConfig(String autoOffsetResetConfig) { - this.autoOffsetResetConfig = autoOffsetResetConfig; - } - - public String getAcksConfig() { - return acksConfig; - } - - public void setAcksConfig(String acksConfig) { - this.acksConfig = acksConfig; - } - - public int getRetriesConfig() { - return retriesConfig; - } - - public void setRetriesConfig(int retriesConfig) { - this.retriesConfig = retriesConfig; - } - - public int getBatchSizeConfig() { - return batchSizeConfig; - } - - public void setBatchSizeConfig(int batchSizeConfig) { - this.batchSizeConfig = batchSizeConfig; - } - - public int getLingerMsConfig() { - return lingerMsConfig; - } - - public void setLingerMsConfig(int lingerMsConfig) { - this.lingerMsConfig = lingerMsConfig; - } - - public int getBufferMemoryConfig() { - return bufferMemoryConfig; - } - - public void setBufferMemoryConfig(int bufferMemoryConfig) { - this.bufferMemoryConfig = bufferMemoryConfig; - } - - public String getDeviceDriverPath() { - return deviceDriverPath; - } - - public void setDeviceDriverPath(String deviceDriverPath) { - this.deviceDriverPath = deviceDriverPath; - } -} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java index 9b9c5fe4..9ef955ef 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java @@ -28,13 +28,13 @@ public static String getBrokerList() { /** * Zookeeper list */ - public static String zookeeperList = "localhost:2181"; + public static String zookeeperList; // = "localhost:21811"; public static String getZookeeperList() { return zookeeperList; } - @Value("${mq.zookeeper.list}") + //@Value("${mq.zookeeper.list}") public void setZookeeperList(String _zookeeperList) { zookeeperList = _zookeeperList; } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java index 0722ca6f..460475c8 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java @@ -63,6 +63,4 @@ public static List stringDataToList(String data){ public static String base64encoding(String data){ return new String(Base64.encodeBase64(data.getBytes())); } - - } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java similarity index 55% rename from so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java rename to so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java index 84519549..9e82121d 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java @@ -1,11 +1,5 @@ package com.pineone.icbms.so.util.http; -import com.withwiz.beach.network.http.message.IHttpResponseMessage; -import com.withwiz.jellyfish.service.IGenericService; -import com.withwiz.jellyfish.service.ServiceException; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientService; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceRequestDeliveryMessage; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceResponseDeliveryMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -14,8 +8,6 @@ import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; /** * ClientService class @@ -24,162 +16,14 @@ */ @Service -public class ClientService +public class ClientServiceNoTimeout { public static final int DATA_TIMEOUT_VALUE = 90000; public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 - private final Logger log = LoggerFactory.getLogger(ClientService.class); - - /** - * request post service. - * - * @param serviceUrl - * @param body - * @return - * NOTE: URL 로 Body 내용 전송 - */ - public IHttpResponseMessage requestPostService(String serviceUrl, String body) - { - log.info("Client Service requestPostService uri " + serviceUrl); - log.info("Client Service requestPostService data " + body); - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - HashMap headerList = new HashMap(); - headerList.put("Content-Type", "application/json"); - // headerList.put("Content-Length", "238"); - - req.addValue(HttpClientService.KEY_HEADER_PARAMETERS, headerList); - req.addValue(HttpClientService.KEY_SERVICE_URL, serviceUrl); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT, 50000); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_POST); - // req.addValue(HttpClientService); - - // body data - // StringInputStream inputStream = new StringInputStream(body); - ByteArrayInputStream inputStream = new ByteArrayInputStream( - body.getBytes()); - req.addValue(HttpClientService.KEY_BODY_INPUT_STREAM, inputStream); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - IHttpResponseMessage httpResponseMessage = null; - // HttpClientService - IGenericService service = new HttpClientService(); - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - /** - * request get service. - * - * @param uri - * @return - NOTE: 외부에서 데이터를 조회하기 위함. Url 의 내용을 조회 - */ - public IHttpResponseMessage requestGetService(String uri) - { - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - req.addValue(HttpClientService.KEY_SERVICE_URL, uri); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT,DATA_TIMEOUT_VALUE); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_GET); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - - // HttpClientService - IGenericService service = new HttpClientService(); - // return IHttpResponseMessage - IHttpResponseMessage httpResponseMessage = null; - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - private IHttpResponseMessage getiHttpResponseMessage(HttpClientServiceRequestDeliveryMessage req, - HttpClientServiceResponseDeliveryMessage res, - IHttpResponseMessage httpResponseMessage, - IGenericService service) { - try - { - // execute a service - service.onService(req, res); - // get a service response - httpResponseMessage = res - .getValue(HttpClientService.KEY_HTTP_RESPONSE); - // print a response - //System.out.println(res); - } - catch (ServiceException e) - { - System.out.println("connection fail :" + e.getMessage()); - //e.printStackTrace(); - } - return httpResponseMessage; - } - - public String requestPostServiceReceiveString(String uri, String data) { - return requestPostServiceReceiveString(uri,data,false); - } - - public String requestPostServiceReceiveString(String uri, String data, boolean onlyResultValue) { - IHttpResponseMessage httpResponseMessage = requestPostService(uri, data); - String returnData = null; - if (onlyResultValue) { - returnData = String.valueOf(httpResponseMessage.getStatusCode()); - } else { - returnData = responseDataToString(httpResponseMessage); - } - return returnData; - } - - - public String requestGetServiceReceiveString(String uri) { - IHttpResponseMessage httpResponseMessage = requestGetService(uri); - String returnData = responseDataToString(httpResponseMessage); - return returnData; - } - - /** - * response Data to String. - * - * @param message - * @return String - */ - public String responseDataToString(IHttpResponseMessage message) - { - String result = null; - - BufferedReader reader = null; - try - { - reader = new BufferedReader(new InputStreamReader( - message.getBodyInputStream()), 8); - StringBuilder sb = new StringBuilder(); - String line = null; - while ((line = reader.readLine()) != null) - { - sb.append(line); - } - result = sb.toString(); - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return result; - } + private final Logger log = LoggerFactory.getLogger(ClientServiceNoTimeout.class); //======================================================================================================= public String requestPostServiceReceiveString2(String uri, String param) { diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java new file mode 100644 index 00000000..ab752483 --- /dev/null +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java @@ -0,0 +1,182 @@ +package com.pineone.icbms.so.util.http; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.io.*; +import java.net.ConnectException; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * ClientServiceTimeout class + * Created by use on 2015-10-12. + * NOTE: 외부 통신을 위해 사용 + */ + +@Service +public class ClientServiceTimeout +{ + public static final int DATA_TIMEOUT_VALUE = 90000; + + public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 + public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 + + private final Logger log = LoggerFactory.getLogger(ClientServiceTimeout.class); + + public String requestPostServiceReceiveString2(String uri, String param) { + return requestPostServiceReceiveString2(uri, param, false); + } + + public String requestPostServiceReceiveString2(String uri, String param, boolean timeOut) + { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestPostServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + //log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + conn.setRequestMethod("POST"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + OutputStream out_stream = conn.getOutputStream(); + out_stream.write( param.getBytes("UTF-8") ); + log.info("requestPostServiceReceiveString2:[{}]:[{}] ", uri, out_stream.toString()); + out_stream.flush(); + out_stream.close(); + + log.info("out_stream close.."); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + //log.info("getInputStream.."); + + InputStream is = conn.getInputStream(); + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + + String line = null; + StringBuffer buff = new StringBuffer(); + + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###1 POST Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###1 POST Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + + + public String requestGetServiceReceiveString2(String uri) { + return requestGetServiceReceiveString2(uri, false); + } + public String requestGetServiceReceiveString2(String uri, boolean timeOut) { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestGetServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + + conn.setRequestMethod("GET"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + // conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.connect(); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + + //log.info("getInputStream.."); + InputStream is = conn.getInputStream(); + + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + String line = null; + StringBuffer buff = new StringBuffer(); + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###2 GET Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###2 GET Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + +} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java index 8bff1204..548f0aad 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java @@ -30,7 +30,7 @@ public static Long createRandomLongValue() { * @param args */ public static void main(String[] args) { - System.out.println(IdUtils.createRandomUUID()); - System.out.println(IdUtils.createRandomLongValue()); + //System.out.println(IdUtils.createRandomUUID()); + //System.out.println(IdUtils.createRandomLongValue()); } } diff --git a/so-util/src/test/java/Jackson_Test.java b/so-util/src/test/java/Jackson_Test.java deleted file mode 100644 index a9f8b606..00000000 --- a/so-util/src/test/java/Jackson_Test.java +++ /dev/null @@ -1,62 +0,0 @@ -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by melvin on 2017. 4. 18.. - */ - -public class Jackson_Test { - - @Test - public void name() throws Exception { - List testObjectList = new ArrayList<>(); - - TestObject testObject1 = new TestObject("5", "5", "5"); - TestObject testObject2 = new TestObject("6", "6", "6"); - TestObject testObject3 = new TestObject("7", "7", "7"); - - testObjectList.add(testObject1); - testObjectList.add(testObject2); - testObjectList.add(testObject3); - - ObjectMapper objectMapper = new ObjectMapper(); - - // List --> String - String testObjListStr = objectMapper.writeValueAsString(testObjectList); - System.out.println("*******funcListStr******** " + testObjListStr); - - // String --> List - List testObjects = objectMapper.readValue(testObjListStr, new TypeReference>() { - }); - System.out.println("*******funcList******** " + testObjects); - - // Class --> String - TestObject testObject = testObjects.get(0); - String testObjStr = objectMapper.writeValueAsString(testObject); - System.out.println("*******funcStr******** " + testObjStr); - - // String --> Class - TestObject testClass = objectMapper.readValue(testObjStr, TestObject.class); - System.out.println("*******funcClass******** " + testClass); - System.out.println("*******funcClass.name******** " + testClass.getName()); - - - List test = new ArrayList<>(); - - test.add("testObject1"); - test.add("testObject2"); - test.add("testObject3"); - - objectMapper = new ObjectMapper(); - - // List --> String - testObjListStr = objectMapper.writeValueAsString(test); - System.out.println("*******string array******** " + testObjListStr); - } - -} - diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java index 40846e69..19ccbecf 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java @@ -12,7 +12,6 @@ import com.pineone.icbms.so.interfaces.database.ref.DataValidation; import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; import com.pineone.icbms.so.interfaces.messagequeue.model.ContextModelForMQ; -import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; import com.pineone.icbms.so.interfaces.sda.model.ContextModelForIf2; import com.pineone.icbms.so.interfaces.si.handle.DeviceManager; @@ -20,7 +19,6 @@ import com.pineone.icbms.so.util.messagequeue.producer.DefaultProducerHandler; import com.pineone.icbms.so.web.model.context.Content; import com.pineone.icbms.so.web.model.context.ContextModel; -import com.pineone.icbms.so.web.model.context.ContextModelTransFormObject; import com.pineone.icbms.so.web.model.context.ResponseMessage; import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; import com.pineone.icbms.so.web.util.ContextModelMapper2; @@ -56,34 +54,6 @@ public class ContextModelController { @Autowired DataBaseStore dataBaseStore; -// /** -// * response for request "/context/cm, HTTP-method:POST". -// * -// * @param contextModelForIf ContextModelForIf -// * @return created DeviceControlCallbackForDB id -// */ -// @RequestMapping(value = "/cm", method = RequestMethod.POST) -// public String injectContextModel(@RequestBody ContextModelForIf contextModelForIf) { -// log.debug("input:ContextModelForIf: {}", contextModelForIf); -// // create a message From ContextModelForMQ for messageQueue, publish to message queue -// // ContextModelForIf --> ContextModelForMQ -// ContextModelForMQ contextModelForMQ = ModelMapper.toContextModelForMQ(contextModelForIf); -// log.debug("converted:ContextModelForMQ: {}", contextModelForMQ); -// //object to json -// String contextModelForMqString = ModelMapper.writeJsonString(contextModelForMQ); -// log.debug("generated:ContextModelForMQ {}", contextModelForMqString); -// //context model producer handler -//// ContextModelProducerHandler producerHandler = new ContextModelProducerHandler(0); -//// Future future = producerHandler.send(contextModelForMqString); -// DefaultProducerHandler producerHandler = new DefaultProducerHandler(0, "contextmodel"); -// Future future = producerHandler.send(contextModelForMQ); -// log.debug("producer.send result: {}", future); -// producerHandler.close(); -// -// //TODO: 추후 처리 결과를 정의하여 리턴함. -// return contextModelForMqString; -// } - /** * response for request "/service/context/cm, HTTP-method:POST". * @@ -189,7 +159,7 @@ private ContextModelForMQ processContextModel(ContextModelForIf2 contextModelFor //@PostMapping(value = "/test") public void testCode(HttpServletRequest request) { - DeviceManager.testmain(null); + new DeviceManager().testmain(null); } /** @@ -296,34 +266,6 @@ public ResponseMessage emergencyContextModel(@RequestBody ContextModelForIf2 con return responseMessage; } - private DataValidation newDataValidation(){ - DataValidation dataValidation = new DataValidation(); - return dataValidation; - } - - private void inspectContextModel(ContextModel contextModel) throws DataLossException { - // - if(contextModel.getId() == null || contextModel.getContextType() == null || - contextModel.getDomainIdList() == null){ - throw new DataLossException(); - } - } - -/* - private ContextModel dataObjectToContextModel(ContextModelTransFormObject contextModelDataObject){ - if(contextModelDataObject == null) return null; - return new ContextModel(contextModelDataObject.getContextId(), contentsToStringList(contextModelDataObject.getContents()), - contextModelDataObject.getCmd(), contextModelDataObject.getTime()); - } -*/ - private List contentsToStringList(List contentsList){ - - List domains = new ArrayList<>(); - for(Content content : contentsList){ - domains.add(content.getLoc()); - } - return domains; - } public String useQueueSaveContextModel(ContextModel contextModel) { // diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java new file mode 100644 index 00000000..1ab2407f --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java @@ -0,0 +1,54 @@ +package com.pineone.icbms.so.web.interfaces.api; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import com.kastkode.springsandwich.filter.annotation.Before; +import com.kastkode.springsandwich.filter.annotation.BeforeElement; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; +import com.pineone.icbms.so.web.model.measure.ResMeasuring; +import com.pineone.icbms.so.web.service.IMeasuringService; +import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; + +@Before(@BeforeElement(BeforeTtrackingHandler.class)) +@CrossOrigin(origins = "*") +@RestController +@RequestMapping(value = "/servicemodel") +public class MeasuringController { + + @Autowired + IMeasuringService measuringService; + + @RequestMapping(value = "/measure",method = RequestMethod.POST) + @ResponseStatus(value = HttpStatus.OK) + @ResponseBody + public ResMeasuring getMeasuredData(@RequestBody ReqMeasuring req, HttpServletRequest request) { + + ResMeasuring res = new ResMeasuring(); + TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); + String sessionId = trackingEntity.getSessionId(); + res.setSessionId(sessionId); + + Object r = measuringService.getMeasuredData(req, request, trackingEntity); + if (r==null) { + String failMsg = "No service data"; + res.setResultMessage(failMsg); + res.setResultCode(404); // No Information + }else { + res.setResultMessage(r); + res.setResultCode(200); //SUCCESS + } + + return res; + } +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java index d15dd908..b9aa4b92 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java @@ -59,116 +59,6 @@ public class ProfileController { @Autowired DatabaseManager databaseManager; - /** - * response for request "/profile, HTTP-method:POST". - * scheduler가 특정 주기로 호출됨 - * - * @param profileTransFormData profile - * @return profile - */ - @RequestMapping(value = "/schedule1", method = RequestMethod.POST) - public IGenericProfile callFromScheduler(@RequestBody ProfileTransFormData profileTransFormData, HttpServletRequest request) { - - if (profileTransFormData==null) { - contextLog.warn("Input Profile is null"); - return null; - } - String inputProfileId = profileTransFormData.getId(); - contextLog.debug("Checking CM by schedule : input profile=[{}]", inputProfileId); - - ProfileForDB profileForDb = databaseManager.getProfileById(profileTransFormData.getId()); - IGenericProfile profile = ModelMapper.toProfile(profileForDb); - - SessionEntity sessionEntity = new SessionEntity(); - - if (profile==null) { - contextLog.warn("Profile is null"); - return null; - } - - IGenericContextModel contextModel = profile.getContextModel(); - if (contextModel == null) { - contextLog.warn( "contextModel is null"); - return null; - } - - String contextModelId = contextModel.getId(); - ContextModelForDB cm = databaseManager.getContextModelById(contextModelId); - String contextModelName = cm.getName(); - - TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); - String sessionId = trackingEntity.getSessionId(); - String priority = profileForDb.getPriority(); - - // grib session - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelKey(contextModelId); - sessionEntity.setContextmodelName(contextModelName); - sessionEntity.setContextmodelResult("NotHappen"); - sessionEntity.setPriorityKey(priority); - //contextLog.debug("session : {}", sessionEntity); - - // grib session profile - //SessionEntity sessionProfile = new SessionEntity(); - //sessionEntity.setId(sessionId); - sessionEntity.setProfileKey(profile.getId()); - sessionEntity.setProfileName(profile.getName()); - //contextLog.debug("session profile : {}", sessionEntity); - - databaseManager.createSessionData(sessionEntity); - - boolean isCmProceed = false; //CM 처리되었나? - - //SDA로 부터 CM발생 여부 체크 - List locationList = new SdaManager().retrieveEventLocationList(contextModelId); - - contextLog.debug("called SDA: cm={}, name={}, location={}", contextModelId, contextModelName, locationList.toString()); - - if (locationList != null && locationList.size() > 0) { - - for (String location : locationList) { - if (location.equals(profile.getLocation().getUri())) { - //scheduler 또는 에 의한 Profile 내 OS 구동임을 남겨야 함 - - ContextModelHandler contextModelHandler = new ContextModelHandler(databaseManager); - contextModelHandler.setTracking(trackingEntity); - contextModelHandler.profileHandle(profile); - isCmProceed = true; - - //sessionEntity.setContextmodelResult("Happen"); - //databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(location); - databaseManager.createSessionDataLocation(sessionLocation); - - contextLog.warn("O: result: Happen cm=[{}], Location={} , sessionId={}", contextModelId, location, sessionId); - //contextLog.debug("session location : {}", sessionLocation); - } - } - } - - //Location이 없거나 처리되지 않았을때 - if (isCmProceed == false) { - contextLog.warn("X: result: Not happened cm=[{}]", contextModelId); - - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelResult("NotHappen"); - databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(""); - databaseManager.createSessionDataLocation(sessionLocation); - - //contextLog.debug("session location : {}", sessionLocation); - } - return profile; - } - /** * response for request "/profile, HTTP-method:POST". * scheduler가 특정 주기로 호출됨 diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java index 295de4f1..128d5d94 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java @@ -25,16 +25,6 @@ @ResponseStatus(value = HttpStatus.OK) public class SessionController { -// @Autowired -// SessionStore sessionStore; -// -// @RequestMapping(value = "/{number}", method = RequestMethod.GET) -// @ResponseStatus(value = HttpStatus.OK) -// public List retrieveSessionData(@PathVariable int number){ -// List sessionList = sessionStore.retrieveRecentlyDataList(number); -// return sessionToTransFormObject(sessionList); -// } - @Autowired //TrackingDao trackingDao; SessionDao sessionDao; @@ -86,8 +76,10 @@ public List retrieveSessionData(@PathVariable Integer nu sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(entity.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", entity.getVirtualobjectResult()); - - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", entity.getDeviceResult()); @@ -145,7 +137,9 @@ public SessionTransFormObject retrieveSessionDataOne(@PathVariable String sessio sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(sessionDataDb.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", sessionDataDb.getVirtualobjectResult()); - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", sessionDataDb.getDeviceResult()); diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java new file mode 100644 index 00000000..257e98fa --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java @@ -0,0 +1,27 @@ +package com.pineone.icbms.so.web.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) +public class MeasuringData { + + @Getter@Setter + private String devId ; + + @Getter@Setter + private String devName ; + + @Getter@Setter + private String devTypeDesc; + + @Getter@Setter + private String aspectName; + + @Getter@Setter + private String measuringValue; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java new file mode 100644 index 00000000..a90b4164 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java @@ -0,0 +1,21 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ReqMeasuring { + @Getter@Setter + @JsonProperty("serviceName") + String serviceName; + + @Getter@Setter + @JsonProperty("location") + String location; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java new file mode 100644 index 00000000..a5921508 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java @@ -0,0 +1,26 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ResMeasuring { + @Getter@Setter + @JsonProperty("resultCode") + Integer resultCode; + + @Getter@Setter + @JsonProperty("resultMessage") + Object resultMessage; + + @Getter@Setter + @JsonProperty("sessionId") + String sessionId; +} + diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java new file mode 100644 index 00000000..da096394 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java @@ -0,0 +1,12 @@ +package com.pineone.icbms.so.web.service; + +import javax.servlet.http.HttpServletRequest; + +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +public interface IMeasuringService { + + Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity); + +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java new file mode 100644 index 00000000..a0d60a2c --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java @@ -0,0 +1,192 @@ +package com.pineone.icbms.so.web.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.pineone.icbms.so.interfaces.database.dao.OrchestrationServiceDao; +import com.pineone.icbms.so.interfaces.database.model.DeviceTypeForDB; +import com.pineone.icbms.so.interfaces.database.model.LocationForDB; +import com.pineone.icbms.so.interfaces.database.model.MeasuringVoForDB; +import com.pineone.icbms.so.interfaces.database.model.OrchestrationServiceForDB; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; +import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; +import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; +import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; +import com.pineone.icbms.so.web.model.MeasuringData; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +import lombok.Getter; +import lombok.Setter; + +@Service +public class MeasuringService implements IMeasuringService { + @Autowired + //IDataBaseStore dataBaseStore; + DataBaseStore dataBaseStore; + + //@Autowired + //protected DatabaseManager databaseManager; + + @Autowired + OrchestrationServiceDao orchestrationServiceDao; + + @Getter @Setter + TrackingEntity tracking; + + protected Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity) { + + //입력 파라미터 + String locId = req.getLocation(); //설치 위치 + String serviceName = req.getServiceName(); //OS 이름 + + //설치 장소 + LocationForDB locForDB = dataBaseStore.getLocationById(locId); + String locationUri = locForDB.getUri(); + String locName = locForDB.getName(); + + + //1) OS Name으로 osId얻기 + OrchestrationServiceForDB param = new OrchestrationServiceForDB(); + param.setName(serviceName); + + List osForDbList = orchestrationServiceDao.retrieve(param); + if (osForDbList==null || osForDbList.size()==0) { //일치되는 자료 없음 + log.error("Service Info ({}) not found", serviceName); //orchestration_service : name + return null; + } + OrchestrationServiceForDB osForDb = osForDbList.get(0); + String osId = osForDb.getId(); + + //2) os id 로 MeasuringVoForDB 목록을 조회한다 + // osId로 rule_body/rule_item에서 vo list 얻기 : (rule_item의 functionality_id가 FUNCTIONALITY_TYPE_MEASURING인 값만 선택) + // cvo_type이 NONDEVICE_CVO인 경우에는 noncvo테이블을 참조하여 확장 + log.debug("getRuleBodyListByOsId : {}", osId); + List measuringVoForDBList = dataBaseStore.getMeasuringVoList(osId); + + // 측정데이타를 저장할 변수 생성 + List measuringDataList = new ArrayList<>(); + + //3) MeasuringVoForDB의 item별로 동작 + for (MeasuringVoForDB measuringVoItem:measuringVoForDBList) { + + String cvoBaseId = measuringVoItem.getBaseCvoId(); + String cvoType = measuringVoItem.getCvoType(); + + // BaseCvoId 부터 유효 VO 목록을 가져온다. + List validVoList = dataBaseStore.getVirtualObjectListByCompositeVirtualObjectId(cvoBaseId); + if (validVoList.size()==0) { + log.error("Not exist vo list by cvoBase={}", cvoBaseId); + continue; + } + String vId = measuringVoItem.getVoId(); + String aspectUri = null; + String voDesc = null; + + //VO값이 유효한 Vo인지 검사한다. + for (VirtualObjectForDB validVo:validVoList) { + if (vId.equals(validVo.getId())){ + aspectUri = validVo.getAspectUri(); //첫번째 VO만 참조하여 URI를 가져옴 + voDesc = validVo.getDescription(); + break; + } + } + + //유효하지 않으면 + if (aspectUri == null ) { //SKIP + log.error("Not exist aspectUri by list by vId={}", vId); + continue; + } + + // 4) cvo_type별로 sda에서 값 읽기 + List contentList = null; + //4-1) CVO_TYPE_DEVICETYPE or CVO_TYPE_DEVICETYPE_ASPECT + if (cvoType.equals("CVO_TYPE_DEVICETYPE") || cvoType.equals("CVO_TYPE_DEVICETYPE_ASPECT")) { + String physicalDeviceTypeId = measuringVoItem.getPhysicalDeviceTypeId(); + + //PysicalDeviceTypeUri + DeviceTypeForDB typeDb = dataBaseStore.retrieveDeviceTypeById(physicalDeviceTypeId); + if (typeDb==null) { + log.error("error : Device Type info is not exist : physicalDeviceTypeId={}", physicalDeviceTypeId); + continue; + } + String physicalDeviceTypeUri = typeDb.getPhysicalDeviceTypeUri(); + + contentList = new SdaManager().getMeasuringValueByLocDeviceTypeAspect(locationUri, physicalDeviceTypeUri, aspectUri); + } + //4-2) CVO_TYPE_ASPECT + else if (cvoType.equals("CVO_TYPE_ASPECT")) { + + contentList = new SdaManager().getMeasuringValueByLocAspect(locationUri, aspectUri); + } + //4-3) CVO_TYPE_DEVICEID + else if (cvoType.equals("CVO_TYPE_DEVICEID")) { + + String deviceUri = measuringVoItem.getDeviceId(); + contentList = new SdaManager().getMeasuringValueByDevIdAspect(deviceUri, aspectUri); + + } else { + // SKIP + } + + if (contentList != null) { + for (ContextModelContent contentItem:contentList) { + + MeasuringData md = new MeasuringData(); + + md.setDevId(contentItem.getDeviceUri()); + md.setDevName(contentItem.getDeviceName()); + md.setDevTypeDesc(contentItem.getDeviceTypeDesc()); + md.setAspectName(voDesc); + md.setMeasuringValue(contentItem.getValue()); + + measuringDataList.add(md); + } + } + } + +/* + String contextModelId="measuring"; + String contextModelName="Measureing"; + + setTracking((TrackingEntity) request.getSession().getAttribute("tracking")); + String sessionId = trackingEntity.getSessionId(); + + // grib session + SessionEntity sessionEntity = new SessionEntity(); + sessionEntity.setId(sessionId); + sessionEntity.setContextmodelKey(contextModelId); + sessionEntity.setContextmodelName(contextModelName); + sessionEntity.setContextmodelResult("NotHappen"); + sessionEntity.setProfileName(serviceName); + //sessionEntity.setPriorityKey("LOW"); + log.debug("session : {}", sessionEntity); + dataBaseStore.createSessionData(sessionEntity); + + + // grib session location + SessionEntity sessionLocation = new SessionEntity(); + sessionLocation.setId(sessionId); + sessionLocation.setLocationId(locationUri); + log.debug("session location : {}", sessionLocation); + try { + dataBaseStore.createSessionDataLocation(sessionLocation); + }catch(Exception e) { + log.error("Error createSessionDataLocation : error={},\n sessionLocation={}", e.getMessage(), sessionLocation); + } +*/ + + return measuringDataList; + } + +}
- * usage) java -j [jar file] [serviceprocessor name] - * - * @param args serviceprocessor name - */ -// public static void main(String[] args) { -// ProcessorRouter.getInstance().run(args); -// } -} \ No newline at end of file diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java deleted file mode 100644 index f5d16556..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultCut.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -/** - * cut default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultCut extends AGenericIdentity implements ICut { -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java deleted file mode 100644 index a1f79ccd..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenario.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenario; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * Scenario default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenario extends AGenericIdentity implements IScenario { - - /** - * scene list - */ - List sceneList = null; - - /** - * scenario context - */ - IScenarioContext scenarioContext = null; - - /** - * constructor - */ - public DefaultScenario() { - } - - /** - * return a ScenarioContext. - * - * @return ScenarioContext - */ - @Override - public IScenarioContext getScenarioContext() { - return scenarioContext; - } - - public void setScenarioContext(IScenarioContext scenarioContext) { - this.scenarioContext = scenarioContext; - } - - /** - * return scene list. - * - * @return List - */ - @Override - public List getSceneList() { - return null; - } - - public void setSceneList(List sceneList) { - this.sceneList = sceneList; - } - - public void addScene(IScene scene) { - this.sceneList.add(scene); - } - - -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java deleted file mode 100644 index be17afab..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScenarioContext.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScenarioContext; -import com.pineone.icbms.so.util.registry.AGenericKeyValueRegistry; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * scenario context default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScenarioContext extends AGenericKeyValueRegistry implements IScenarioContext { - /** - * return interface for returning Store - * - * @return Map - */ - @Override - protected Map createStore() { - return new LinkedHashMap(); - } - - /** - * return scenario id - * - * @return scenario id - */ - @Override - public String getScenarioId() { - return this.getValue("SCENARIO_ID"); - } - - public void setScenearioId(String id) { - this.addValue("SCENARIO_ID", id); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java deleted file mode 100644 index 45023136..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/scenario/DefaultScene.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.scenario; - -import com.pineone.icbms.so.serviceutil.interfaces.scenario.ICut; -import com.pineone.icbms.so.serviceutil.interfaces.scenario.IScene; -import com.pineone.icbms.so.virtualobject.common.AGenericIdentity; - -import java.util.List; - -/** - * scene default class. - * - * Created by uni4love on 2017. 1. 12.. - */ -public class DefaultScene extends AGenericIdentity implements IScene { - /** - * cut list - */ - List cutList = null; - - /** - * constructor - */ - public DefaultScene() { - } - - /** - * return cut list. - * - * @return List - */ - @Override - public List getCutList() { - return null; - } - - public void setCutList(List cutList) { - this.cutList = cutList; - } - - public void addCut(DefaultCut cut) { - this.cutList.add(cut); - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java deleted file mode 100644 index 90c7ea33..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/DeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.serviceprocessor.util.devicemapper.IDeviceMapper; -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mapper. - * - * Created by uni4love on 2016. 12. 30.. - */ -public class DeviceMapper implements IDeviceMapper { - - @Override - public List getDevices(IGenericVirtualObject virtualObject) { - return null; - } -} diff --git a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java b/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java deleted file mode 100644 index 63bec3c3..00000000 --- a/so-serviceprocessor/src/main/java/com/pineone/icbms/so/serviceprocessor/util/devicemapper/IDeviceMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pineone.icbms.so.serviceprocessor.util.devicemapper; - -import com.pineone.icbms.so.virtualobject.virtualdevice.IGenericVirtualDevice; -import com.pineone.icbms.so.virtualobject.IGenericVirtualObject; - -import java.util.List; - -/** - * VirtualObject-VirtualDevice mappe interface. - * - * Created by uni4love on 2016. 12. 30.. - */ -public interface IDeviceMapper { - /** - * from VirtualObject. - * - * @param virtualObject - */ - List getDevices(IGenericVirtualObject virtualObject); -} diff --git a/so-serviceprocessor/src/main/resources/banner.txt b/so-serviceprocessor/src/main/resources/banner.txt deleted file mode 100644 index 6dd56601..00000000 --- a/so-serviceprocessor/src/main/resources/banner.txt +++ /dev/null @@ -1,18 +0,0 @@ - _____ -/\ __`\ __ -\ \ \/\ \ __ ____/\_\ ____ - \ \ \ \ \ /'__`\ /',__\/\ \ /',__\ - \ \ \_\ \/\ \L\.\_/\__, `\ \ \/\__, `\ - \ \_____\ \__/.\_\/\____/\ \_\/\____/ - \/_____/\/__/\/_/\/___/ \/_/\/___/ - - - ____ _____ __ __ __ -/\ _`\ __ /\ __`\ /\ \ /\ \__ /\ \__ __ -\ \,\L\_\ __ _ __ __ __/\_\ ___ __ \ \ \/\ \ _ __ ___\ \ \___ __ ___\ \ ,_\ _ __ __ \ \ ,_\/\_\ ___ ___ - \/_\__ \ /'__`\/\`'__\/\ \/\ \/\ \ /'___\ /'__`\ \ \ \ \ \/\`'__\/'___\ \ _ `\ /'__`\ /',__\ \ \//\`'__\/'__`\\ \ \/\/\ \ / __`\ /' _ `\ - /\ \L\ \/\ __/\ \ \/ \ \ \_/ \ \ \/\ \__//\ __/ \ \ \_\ \ \ \//\ \__/\ \ \ \ \/\ __//\__, `\ \ \\ \ \//\ \L\.\\ \ \_\ \ \/\ \L\ \/\ \/\ \ - \ `\____\ \____\\ \_\ \ \___/ \ \_\ \____\ \____\ \ \_____\ \_\\ \____\\ \_\ \_\ \____\/\____/\ \__\ \_\\ \__/.\_\ \__\\ \_\ \____/\ \_\ \_\ - \/_____/\/____/ \/_/ \/__/ \/_/\/____/\/____/ \/_____/\/_/ \/____/ \/_/\/_/\/____/\/___/ \/__/\/_/ \/__/\/_/\/__/ \/_/\/___/ \/_/\/_/ - - \ No newline at end of file diff --git a/so-serviceutil/src/main/resources/application.properties b/so-serviceutil/src/main/resources/application.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/so-util/build.gradle b/so-util/build.gradle index 16cc6b36..f2fcb5a0 100644 --- a/so-util/build.gradle +++ b/so-util/build.gradle @@ -66,8 +66,8 @@ dependencies { //spring-kafka compile 'org.springframework.kafka:spring-kafka:1.2.0.RELEASE' - // http - compile "com.withwiz:httpclientservice:0.1.1" + //base64 + compile group: 'commons-codec', name: 'commons-codec', version: '1.10' //compile("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootVersion}") diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java deleted file mode 100644 index 8c89b3e4..00000000 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.pineone.icbms.so.util; - -import org.apache.kafka.common.serialization.StringDeserializer; -import org.apache.kafka.common.serialization.StringSerializer; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -/** - * settings for message queue. - * Created by uni4love on 2016. 12. 16.. - */ -@Configuration -public class Settings { - /** - * broker(kafka) list - */ - @Value("${mq.broker.list}") - public String brokerList = "localhost:9092"; - - /** - * Zookeeper list - */ - @Value("${mq.zookeeper.list}") - public String zookeeperList = "localhost:2181"; - - //----------------------------- consumer configs - /** - * consumer Poll timeout - */ - @Value("${mq.consumer.pool_timeout}") - public long pollTimeout = 3000L; - - /** - * ENABLE_AUTO_COMMIT_CONFIG - */ - @Value("${mq.consumer.enable_auto_commit}") - public String enableAutoCommitConfig = "true"; - - /** - * AUTO_COMMIT_INTERVAL_MS_CONFIG - */ - @Value("${mq.consumer.auto_commit_interval_ms}") - public String autoCommitIntervalMsConfig = "1000"; - - /** - * SESSION_TIMEOUT_MS_CONFIG - */ - @Value("${mq.consumer.session_timeout_ms}") - public String sessionTimeoutMsConfig= "15000"; - - /** - * AUTO_OFFSET_RESET_CONFIG - */ - @Value("${mq.consumer.auto_offset_reset}") - public String autoOffsetResetConfig= "earliest"; - - /** - * KEY_DESERIALIZER_CLASS_CONFIG - */ - public static String KEY_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - /** - * VALUE_DESERIALIZER_CLASS_CONFIG - */ - public static String VALUE_DESERIALIZER_CLASS_CONFIG = StringDeserializer.class.getName(); - - //----------------------------- producer configs - /** - * ACKS_CONFIG - */ - @Value("${mq.producer.acks}") - public String acksConfig= "1"; - - /** - * RETRIES_CONFIG - */ - @Value("${mq.producer.retries}") - public int retriesConfig = 0; - - /** - * BATCH_SIZE_CONFIG - */ - @Value("${mq.producer.batch_size}") - public int batchSizeConfig= 16384; - - /** - * LINGER_MS_CONFIG - */ - @Value("${mq.producer.linger_ms}") - public int lingerMsConfig= 1; - - /** - * BUFFER_MEMORY_CONFIG - */ - @Value("${mq.producer.buffer_memory}") - public int bufferMemoryConfig= 33554432; - - /** - * KEY_SERIALIZER_CLASS_CONFIG - */ - public static String KEY_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - /** - * VALUE_SERIALIZER_CLASS_CONFIG - */ - public static String VALUE_SERIALIZER_CLASS_CONFIG = StringSerializer.class.getName(); - - - //----------------------------- common configs - /** - * kafka topic: contextmodel - */ - public static String TOPIC_CONTEXT_MODEL = "contextmodel"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_ORCHESTRATION_SERVICE = "orchestrationservice"; - - /** - * kafka topic: orchestrationservice - */ - public static String TOPIC_COMPOSITE_VIRTUAL_OBJECT = "compositevirtualobject"; - - /** - * kafka topic: virtual object - */ - public static String TOPIC_VIRTUAL_OBJECT = "virtualobject"; - - /** - * kafka topic: devicecontrol - */ - public static String TOPIC_DEVICE_CONTROL = "devicecontrol"; - - /** - * kafka topic: logging - */ - public static String TOPIC_TRACKING = "tracking"; - - /** - * each serviceprocessor handler count - */ - public static int HANDLER_COUNT = 1; - - /** - * CONTEXTMODEL serviceprocessor handler count - */ - public int HANDLER_CONTEXTMODEL_COUNT = HANDLER_COUNT; - - /** - * ORCHESTRATIONSERVICE serviceprocessor handler count - */ - public int HANDLER_ORCHESTRATIONSERVICE_COUNT = HANDLER_COUNT; - - /** - * VIRTUALOBJECT serviceprocessor handler count - */ - public int HANDELR_VIRTUALOBJECT_COUNT = HANDLER_COUNT; - - /** - * DEVICECONTROL serviceprocessor handler count - */ - public int HANDLER_DEVICECONTROL_COUNT = HANDLER_COUNT; - - /** - * class path for class loader - */ - @Value("${so.device.driver.path}") - public String deviceDriverPath= "/"; - - public String getBrokerList() { - return brokerList; - } - - public void setBrokerList(String brokerList) { - this.brokerList = brokerList; - } - - public String getZookeeperList() { - return zookeeperList; - } - - public void setZookeeperList(String zookeeperList) { - this.zookeeperList = zookeeperList; - } - - public long getPollTimeout() { - return pollTimeout; - } - - public void setPollTimeout(long pollTimeout) { - this.pollTimeout = pollTimeout; - } - - public String getEnableAutoCommitConfig() { - return enableAutoCommitConfig; - } - - public void setEnableAutoCommitConfig(String enableAutoCommitConfig) { - this.enableAutoCommitConfig = enableAutoCommitConfig; - } - - public String getAutoCommitIntervalMsConfig() { - return autoCommitIntervalMsConfig; - } - - public void setAutoCommitIntervalMsConfig(String autoCommitIntervalMsConfig) { - this.autoCommitIntervalMsConfig = autoCommitIntervalMsConfig; - } - - public String getSessionTimeoutMsConfig() { - return sessionTimeoutMsConfig; - } - - public void setSessionTimeoutMsConfig(String sessionTimeoutMsConfig) { - this.sessionTimeoutMsConfig = sessionTimeoutMsConfig; - } - - public String getAutoOffsetResetConfig() { - return autoOffsetResetConfig; - } - - public void setAutoOffsetResetConfig(String autoOffsetResetConfig) { - this.autoOffsetResetConfig = autoOffsetResetConfig; - } - - public String getAcksConfig() { - return acksConfig; - } - - public void setAcksConfig(String acksConfig) { - this.acksConfig = acksConfig; - } - - public int getRetriesConfig() { - return retriesConfig; - } - - public void setRetriesConfig(int retriesConfig) { - this.retriesConfig = retriesConfig; - } - - public int getBatchSizeConfig() { - return batchSizeConfig; - } - - public void setBatchSizeConfig(int batchSizeConfig) { - this.batchSizeConfig = batchSizeConfig; - } - - public int getLingerMsConfig() { - return lingerMsConfig; - } - - public void setLingerMsConfig(int lingerMsConfig) { - this.lingerMsConfig = lingerMsConfig; - } - - public int getBufferMemoryConfig() { - return bufferMemoryConfig; - } - - public void setBufferMemoryConfig(int bufferMemoryConfig) { - this.bufferMemoryConfig = bufferMemoryConfig; - } - - public String getDeviceDriverPath() { - return deviceDriverPath; - } - - public void setDeviceDriverPath(String deviceDriverPath) { - this.deviceDriverPath = deviceDriverPath; - } -} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java index 9b9c5fe4..9ef955ef 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/Settings2.java @@ -28,13 +28,13 @@ public static String getBrokerList() { /** * Zookeeper list */ - public static String zookeeperList = "localhost:2181"; + public static String zookeeperList; // = "localhost:21811"; public static String getZookeeperList() { return zookeeperList; } - @Value("${mq.zookeeper.list}") + //@Value("${mq.zookeeper.list}") public void setZookeeperList(String _zookeeperList) { zookeeperList = _zookeeperList; } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java index 0722ca6f..460475c8 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/conversion/DataConversion.java @@ -63,6 +63,4 @@ public static List stringDataToList(String data){ public static String base64encoding(String data){ return new String(Base64.encodeBase64(data.getBytes())); } - - } diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java similarity index 55% rename from so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java rename to so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java index 84519549..9e82121d 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientService.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceNoTimeout.java @@ -1,11 +1,5 @@ package com.pineone.icbms.so.util.http; -import com.withwiz.beach.network.http.message.IHttpResponseMessage; -import com.withwiz.jellyfish.service.IGenericService; -import com.withwiz.jellyfish.service.ServiceException; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientService; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceRequestDeliveryMessage; -import com.withwiz.service.network.http.client.httpclientservice.HttpClientServiceResponseDeliveryMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -14,8 +8,6 @@ import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; /** * ClientService class @@ -24,162 +16,14 @@ */ @Service -public class ClientService +public class ClientServiceNoTimeout { public static final int DATA_TIMEOUT_VALUE = 90000; public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 - private final Logger log = LoggerFactory.getLogger(ClientService.class); - - /** - * request post service. - * - * @param serviceUrl - * @param body - * @return - * NOTE: URL 로 Body 내용 전송 - */ - public IHttpResponseMessage requestPostService(String serviceUrl, String body) - { - log.info("Client Service requestPostService uri " + serviceUrl); - log.info("Client Service requestPostService data " + body); - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - HashMap headerList = new HashMap(); - headerList.put("Content-Type", "application/json"); - // headerList.put("Content-Length", "238"); - - req.addValue(HttpClientService.KEY_HEADER_PARAMETERS, headerList); - req.addValue(HttpClientService.KEY_SERVICE_URL, serviceUrl); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT, 50000); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_POST); - // req.addValue(HttpClientService); - - // body data - // StringInputStream inputStream = new StringInputStream(body); - ByteArrayInputStream inputStream = new ByteArrayInputStream( - body.getBytes()); - req.addValue(HttpClientService.KEY_BODY_INPUT_STREAM, inputStream); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - IHttpResponseMessage httpResponseMessage = null; - // HttpClientService - IGenericService service = new HttpClientService(); - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - /** - * request get service. - * - * @param uri - * @return - NOTE: 외부에서 데이터를 조회하기 위함. Url 의 내용을 조회 - */ - public IHttpResponseMessage requestGetService(String uri) - { - // request delivery message - HttpClientServiceRequestDeliveryMessage req = new HttpClientServiceRequestDeliveryMessage(); - // add key-value list. - req.addValue(HttpClientService.KEY_SERVICE_URL, uri); - req.addValue(HttpClientService.KEY_CONNECTION_TIMEOUT,DATA_TIMEOUT_VALUE); - req.addValue(HttpClientService.KEY_HTTP_METHOD, - HttpClientService.VALUE_HTTP_METHOD_GET); - - // response delivery message - HttpClientServiceResponseDeliveryMessage res = new HttpClientServiceResponseDeliveryMessage(); - - // HttpClientService - IGenericService service = new HttpClientService(); - // return IHttpResponseMessage - IHttpResponseMessage httpResponseMessage = null; - httpResponseMessage = getiHttpResponseMessage(req, res, httpResponseMessage, service); - return httpResponseMessage; - } - - private IHttpResponseMessage getiHttpResponseMessage(HttpClientServiceRequestDeliveryMessage req, - HttpClientServiceResponseDeliveryMessage res, - IHttpResponseMessage httpResponseMessage, - IGenericService service) { - try - { - // execute a service - service.onService(req, res); - // get a service response - httpResponseMessage = res - .getValue(HttpClientService.KEY_HTTP_RESPONSE); - // print a response - //System.out.println(res); - } - catch (ServiceException e) - { - System.out.println("connection fail :" + e.getMessage()); - //e.printStackTrace(); - } - return httpResponseMessage; - } - - public String requestPostServiceReceiveString(String uri, String data) { - return requestPostServiceReceiveString(uri,data,false); - } - - public String requestPostServiceReceiveString(String uri, String data, boolean onlyResultValue) { - IHttpResponseMessage httpResponseMessage = requestPostService(uri, data); - String returnData = null; - if (onlyResultValue) { - returnData = String.valueOf(httpResponseMessage.getStatusCode()); - } else { - returnData = responseDataToString(httpResponseMessage); - } - return returnData; - } - - - public String requestGetServiceReceiveString(String uri) { - IHttpResponseMessage httpResponseMessage = requestGetService(uri); - String returnData = responseDataToString(httpResponseMessage); - return returnData; - } - - /** - * response Data to String. - * - * @param message - * @return String - */ - public String responseDataToString(IHttpResponseMessage message) - { - String result = null; - - BufferedReader reader = null; - try - { - reader = new BufferedReader(new InputStreamReader( - message.getBodyInputStream()), 8); - StringBuilder sb = new StringBuilder(); - String line = null; - while ((line = reader.readLine()) != null) - { - sb.append(line); - } - result = sb.toString(); - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return result; - } + private final Logger log = LoggerFactory.getLogger(ClientServiceNoTimeout.class); //======================================================================================================= public String requestPostServiceReceiveString2(String uri, String param) { diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java new file mode 100644 index 00000000..ab752483 --- /dev/null +++ b/so-util/src/main/java/com/pineone/icbms/so/util/http/ClientServiceTimeout.java @@ -0,0 +1,182 @@ +package com.pineone.icbms.so.util.http; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.io.*; +import java.net.ConnectException; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * ClientServiceTimeout class + * Created by use on 2015-10-12. + * NOTE: 외부 통신을 위해 사용 + */ + +@Service +public class ClientServiceTimeout +{ + public static final int DATA_TIMEOUT_VALUE = 90000; + + public static final int CONNECTION_TIMEOUT_VALUE = 2000; // 연결 + public static final int READ_TIMEOUT_VALUE = 5000; // 읽기 + + private final Logger log = LoggerFactory.getLogger(ClientServiceTimeout.class); + + public String requestPostServiceReceiveString2(String uri, String param) { + return requestPostServiceReceiveString2(uri, param, false); + } + + public String requestPostServiceReceiveString2(String uri, String param, boolean timeOut) + { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestPostServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + //log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + conn.setRequestMethod("POST"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + OutputStream out_stream = conn.getOutputStream(); + out_stream.write( param.getBytes("UTF-8") ); + log.info("requestPostServiceReceiveString2:[{}]:[{}] ", uri, out_stream.toString()); + out_stream.flush(); + out_stream.close(); + + log.info("out_stream close.."); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + //log.info("getInputStream.."); + + InputStream is = conn.getInputStream(); + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + + String line = null; + StringBuffer buff = new StringBuffer(); + + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###1 POST Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###1 POST Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + + + public String requestGetServiceReceiveString2(String uri) { + return requestGetServiceReceiveString2(uri, false); + } + public String requestGetServiceReceiveString2(String uri, boolean timeOut) { + String responseString = null; + HttpURLConnection conn = null; + BufferedReader in = null; + try { + log.info("requestGetServiceReceiveString2:[{}]", uri); + + URL url = new URL(uri); + log.info("openConnection.."); + conn = (HttpURLConnection)url.openConnection(); + + if (timeOut) { + conn.setConnectTimeout(CONNECTION_TIMEOUT_VALUE); + conn.setReadTimeout(READ_TIMEOUT_VALUE); + } + + conn.setRequestMethod("GET"); // 전달 방식을 설정한다. POST or GET, 기본값은 GET 이다. + conn.setDoInput(true); // 서버로부터 메세지를 받을 수 있도록 한다. 기본값은 true이다. + // conn.setDoOutput(true); // 서버로 데이터를 전송할 수 있도록 한다. GET방식이면 사용될 일이 없으나, true로 설정하면 자동으로 POST로 설정된다. 기본값은 false이다. + //conn.setRequestProperty("Accept-Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.connect(); + + int statusCode = conn.getResponseCode(); + if (statusCode != HttpURLConnection.HTTP_OK) { + if (statusCode == HttpURLConnection.HTTP_NOT_FOUND) { //SDA에서 쿼리 data가 없는 경우에 404리턴 + log.info("statusCode=[{}], uri={}", statusCode, uri); + }else { + log.error("error statusCode=[{}], uri={}", statusCode, uri); + } + return null; + } + //log.info(" == ok uri={}", uri); + + //log.info("getInputStream.."); + InputStream is = conn.getInputStream(); + + //log.info("new BufferedReader.."); + in = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8 * 1024); + String line = null; + StringBuffer buff = new StringBuffer(); + //log.info("reading.."); + + while ( ( line = in.readLine() ) != null ) + { + buff.append(line + "\n"); + } + responseString = buff.toString().trim(); + + log.info("response=[{}]", responseString); + } catch (ConnectException e) { + log.error(" !###2 GET Error ConnectException: uri=[{}]", uri); + log.debug("error msg={}",e.getMessage()); + } catch (Exception e) { + log.error(" !###2 GET Exception: uri=[{}, response=[{}]", uri, responseString); + log.debug("error {},msg={}",e.getClass().getName(), e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + } + } + if (conn != null) + conn.disconnect(); + } + + return responseString; + } + +} diff --git a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java index 8bff1204..548f0aad 100644 --- a/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java +++ b/so-util/src/main/java/com/pineone/icbms/so/util/id/IdUtils.java @@ -30,7 +30,7 @@ public static Long createRandomLongValue() { * @param args */ public static void main(String[] args) { - System.out.println(IdUtils.createRandomUUID()); - System.out.println(IdUtils.createRandomLongValue()); + //System.out.println(IdUtils.createRandomUUID()); + //System.out.println(IdUtils.createRandomLongValue()); } } diff --git a/so-util/src/test/java/Jackson_Test.java b/so-util/src/test/java/Jackson_Test.java deleted file mode 100644 index a9f8b606..00000000 --- a/so-util/src/test/java/Jackson_Test.java +++ /dev/null @@ -1,62 +0,0 @@ -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by melvin on 2017. 4. 18.. - */ - -public class Jackson_Test { - - @Test - public void name() throws Exception { - List testObjectList = new ArrayList<>(); - - TestObject testObject1 = new TestObject("5", "5", "5"); - TestObject testObject2 = new TestObject("6", "6", "6"); - TestObject testObject3 = new TestObject("7", "7", "7"); - - testObjectList.add(testObject1); - testObjectList.add(testObject2); - testObjectList.add(testObject3); - - ObjectMapper objectMapper = new ObjectMapper(); - - // List --> String - String testObjListStr = objectMapper.writeValueAsString(testObjectList); - System.out.println("*******funcListStr******** " + testObjListStr); - - // String --> List - List testObjects = objectMapper.readValue(testObjListStr, new TypeReference>() { - }); - System.out.println("*******funcList******** " + testObjects); - - // Class --> String - TestObject testObject = testObjects.get(0); - String testObjStr = objectMapper.writeValueAsString(testObject); - System.out.println("*******funcStr******** " + testObjStr); - - // String --> Class - TestObject testClass = objectMapper.readValue(testObjStr, TestObject.class); - System.out.println("*******funcClass******** " + testClass); - System.out.println("*******funcClass.name******** " + testClass.getName()); - - - List test = new ArrayList<>(); - - test.add("testObject1"); - test.add("testObject2"); - test.add("testObject3"); - - objectMapper = new ObjectMapper(); - - // List --> String - testObjListStr = objectMapper.writeValueAsString(test); - System.out.println("*******string array******** " + testObjListStr); - } - -} - diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java index 40846e69..19ccbecf 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ContextModelController.java @@ -12,7 +12,6 @@ import com.pineone.icbms.so.interfaces.database.ref.DataValidation; import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; import com.pineone.icbms.so.interfaces.messagequeue.model.ContextModelForMQ; -import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; import com.pineone.icbms.so.interfaces.sda.model.ContextModelForIf2; import com.pineone.icbms.so.interfaces.si.handle.DeviceManager; @@ -20,7 +19,6 @@ import com.pineone.icbms.so.util.messagequeue.producer.DefaultProducerHandler; import com.pineone.icbms.so.web.model.context.Content; import com.pineone.icbms.so.web.model.context.ContextModel; -import com.pineone.icbms.so.web.model.context.ContextModelTransFormObject; import com.pineone.icbms.so.web.model.context.ResponseMessage; import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; import com.pineone.icbms.so.web.util.ContextModelMapper2; @@ -56,34 +54,6 @@ public class ContextModelController { @Autowired DataBaseStore dataBaseStore; -// /** -// * response for request "/context/cm, HTTP-method:POST". -// * -// * @param contextModelForIf ContextModelForIf -// * @return created DeviceControlCallbackForDB id -// */ -// @RequestMapping(value = "/cm", method = RequestMethod.POST) -// public String injectContextModel(@RequestBody ContextModelForIf contextModelForIf) { -// log.debug("input:ContextModelForIf: {}", contextModelForIf); -// // create a message From ContextModelForMQ for messageQueue, publish to message queue -// // ContextModelForIf --> ContextModelForMQ -// ContextModelForMQ contextModelForMQ = ModelMapper.toContextModelForMQ(contextModelForIf); -// log.debug("converted:ContextModelForMQ: {}", contextModelForMQ); -// //object to json -// String contextModelForMqString = ModelMapper.writeJsonString(contextModelForMQ); -// log.debug("generated:ContextModelForMQ {}", contextModelForMqString); -// //context model producer handler -//// ContextModelProducerHandler producerHandler = new ContextModelProducerHandler(0); -//// Future future = producerHandler.send(contextModelForMqString); -// DefaultProducerHandler producerHandler = new DefaultProducerHandler(0, "contextmodel"); -// Future future = producerHandler.send(contextModelForMQ); -// log.debug("producer.send result: {}", future); -// producerHandler.close(); -// -// //TODO: 추후 처리 결과를 정의하여 리턴함. -// return contextModelForMqString; -// } - /** * response for request "/service/context/cm, HTTP-method:POST". * @@ -189,7 +159,7 @@ private ContextModelForMQ processContextModel(ContextModelForIf2 contextModelFor //@PostMapping(value = "/test") public void testCode(HttpServletRequest request) { - DeviceManager.testmain(null); + new DeviceManager().testmain(null); } /** @@ -296,34 +266,6 @@ public ResponseMessage emergencyContextModel(@RequestBody ContextModelForIf2 con return responseMessage; } - private DataValidation newDataValidation(){ - DataValidation dataValidation = new DataValidation(); - return dataValidation; - } - - private void inspectContextModel(ContextModel contextModel) throws DataLossException { - // - if(contextModel.getId() == null || contextModel.getContextType() == null || - contextModel.getDomainIdList() == null){ - throw new DataLossException(); - } - } - -/* - private ContextModel dataObjectToContextModel(ContextModelTransFormObject contextModelDataObject){ - if(contextModelDataObject == null) return null; - return new ContextModel(contextModelDataObject.getContextId(), contentsToStringList(contextModelDataObject.getContents()), - contextModelDataObject.getCmd(), contextModelDataObject.getTime()); - } -*/ - private List contentsToStringList(List contentsList){ - - List domains = new ArrayList<>(); - for(Content content : contentsList){ - domains.add(content.getLoc()); - } - return domains; - } public String useQueueSaveContextModel(ContextModel contextModel) { // diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java new file mode 100644 index 00000000..1ab2407f --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/MeasuringController.java @@ -0,0 +1,54 @@ +package com.pineone.icbms.so.web.interfaces.api; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import com.kastkode.springsandwich.filter.annotation.Before; +import com.kastkode.springsandwich.filter.annotation.BeforeElement; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; +import com.pineone.icbms.so.web.model.measure.ResMeasuring; +import com.pineone.icbms.so.web.service.IMeasuringService; +import com.pineone.icbms.so.web.tracking.BeforeTtrackingHandler; + +@Before(@BeforeElement(BeforeTtrackingHandler.class)) +@CrossOrigin(origins = "*") +@RestController +@RequestMapping(value = "/servicemodel") +public class MeasuringController { + + @Autowired + IMeasuringService measuringService; + + @RequestMapping(value = "/measure",method = RequestMethod.POST) + @ResponseStatus(value = HttpStatus.OK) + @ResponseBody + public ResMeasuring getMeasuredData(@RequestBody ReqMeasuring req, HttpServletRequest request) { + + ResMeasuring res = new ResMeasuring(); + TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); + String sessionId = trackingEntity.getSessionId(); + res.setSessionId(sessionId); + + Object r = measuringService.getMeasuredData(req, request, trackingEntity); + if (r==null) { + String failMsg = "No service data"; + res.setResultMessage(failMsg); + res.setResultCode(404); // No Information + }else { + res.setResultMessage(r); + res.setResultCode(200); //SUCCESS + } + + return res; + } +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java index d15dd908..b9aa4b92 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/ProfileController.java @@ -59,116 +59,6 @@ public class ProfileController { @Autowired DatabaseManager databaseManager; - /** - * response for request "/profile, HTTP-method:POST". - * scheduler가 특정 주기로 호출됨 - * - * @param profileTransFormData profile - * @return profile - */ - @RequestMapping(value = "/schedule1", method = RequestMethod.POST) - public IGenericProfile callFromScheduler(@RequestBody ProfileTransFormData profileTransFormData, HttpServletRequest request) { - - if (profileTransFormData==null) { - contextLog.warn("Input Profile is null"); - return null; - } - String inputProfileId = profileTransFormData.getId(); - contextLog.debug("Checking CM by schedule : input profile=[{}]", inputProfileId); - - ProfileForDB profileForDb = databaseManager.getProfileById(profileTransFormData.getId()); - IGenericProfile profile = ModelMapper.toProfile(profileForDb); - - SessionEntity sessionEntity = new SessionEntity(); - - if (profile==null) { - contextLog.warn("Profile is null"); - return null; - } - - IGenericContextModel contextModel = profile.getContextModel(); - if (contextModel == null) { - contextLog.warn( "contextModel is null"); - return null; - } - - String contextModelId = contextModel.getId(); - ContextModelForDB cm = databaseManager.getContextModelById(contextModelId); - String contextModelName = cm.getName(); - - TrackingEntity trackingEntity = (TrackingEntity) request.getSession().getAttribute("tracking"); - String sessionId = trackingEntity.getSessionId(); - String priority = profileForDb.getPriority(); - - // grib session - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelKey(contextModelId); - sessionEntity.setContextmodelName(contextModelName); - sessionEntity.setContextmodelResult("NotHappen"); - sessionEntity.setPriorityKey(priority); - //contextLog.debug("session : {}", sessionEntity); - - // grib session profile - //SessionEntity sessionProfile = new SessionEntity(); - //sessionEntity.setId(sessionId); - sessionEntity.setProfileKey(profile.getId()); - sessionEntity.setProfileName(profile.getName()); - //contextLog.debug("session profile : {}", sessionEntity); - - databaseManager.createSessionData(sessionEntity); - - boolean isCmProceed = false; //CM 처리되었나? - - //SDA로 부터 CM발생 여부 체크 - List locationList = new SdaManager().retrieveEventLocationList(contextModelId); - - contextLog.debug("called SDA: cm={}, name={}, location={}", contextModelId, contextModelName, locationList.toString()); - - if (locationList != null && locationList.size() > 0) { - - for (String location : locationList) { - if (location.equals(profile.getLocation().getUri())) { - //scheduler 또는 에 의한 Profile 내 OS 구동임을 남겨야 함 - - ContextModelHandler contextModelHandler = new ContextModelHandler(databaseManager); - contextModelHandler.setTracking(trackingEntity); - contextModelHandler.profileHandle(profile); - isCmProceed = true; - - //sessionEntity.setContextmodelResult("Happen"); - //databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(location); - databaseManager.createSessionDataLocation(sessionLocation); - - contextLog.warn("O: result: Happen cm=[{}], Location={} , sessionId={}", contextModelId, location, sessionId); - //contextLog.debug("session location : {}", sessionLocation); - } - } - } - - //Location이 없거나 처리되지 않았을때 - if (isCmProceed == false) { - contextLog.warn("X: result: Not happened cm=[{}]", contextModelId); - - sessionEntity.setId(sessionId); - sessionEntity.setContextmodelResult("NotHappen"); - databaseManager.updateSessionData(sessionEntity); - - // grib session location - SessionEntity sessionLocation = new SessionEntity(); - sessionLocation.setId(sessionId); - sessionLocation.setLocationId(""); - databaseManager.createSessionDataLocation(sessionLocation); - - //contextLog.debug("session location : {}", sessionLocation); - } - return profile; - } - /** * response for request "/profile, HTTP-method:POST". * scheduler가 특정 주기로 호출됨 diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java index 295de4f1..128d5d94 100644 --- a/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java +++ b/so-web/src/main/java/com/pineone/icbms/so/web/interfaces/api/admin/controller/SessionController.java @@ -25,16 +25,6 @@ @ResponseStatus(value = HttpStatus.OK) public class SessionController { -// @Autowired -// SessionStore sessionStore; -// -// @RequestMapping(value = "/{number}", method = RequestMethod.GET) -// @ResponseStatus(value = HttpStatus.OK) -// public List retrieveSessionData(@PathVariable int number){ -// List sessionList = sessionStore.retrieveRecentlyDataList(number); -// return sessionToTransFormObject(sessionList); -// } - @Autowired //TrackingDao trackingDao; SessionDao sessionDao; @@ -86,8 +76,10 @@ public List retrieveSessionData(@PathVariable Integer nu sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(entity.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", entity.getVirtualobjectResult()); - - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", entity.getDeviceResult()); @@ -145,7 +137,9 @@ public SessionTransFormObject retrieveSessionDataOne(@PathVariable String sessio sessionData.put("VIRTUALOBJECT_KEY", listToJacksonString(sessionDao.retrieveSessionDataVo(sessionDataDb.getId()))); sessionData.put("VIRTUALOBJECT_RESULT", sessionDataDb.getVirtualobjectResult()); - sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + if (deviceKeys.size()>0) { + sessionData.put("DEVICE_KEY", listToJacksonString(deviceKeys)); + } sessionData.put("DEVICE_LOCATION", listToJacksonString(deviceLocs)); sessionData.put("DEVICE_RESULT", sessionDataDb.getDeviceResult()); diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java new file mode 100644 index 00000000..257e98fa --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/MeasuringData.java @@ -0,0 +1,27 @@ +package com.pineone.icbms.so.web.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) +public class MeasuringData { + + @Getter@Setter + private String devId ; + + @Getter@Setter + private String devName ; + + @Getter@Setter + private String devTypeDesc; + + @Getter@Setter + private String aspectName; + + @Getter@Setter + private String measuringValue; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java new file mode 100644 index 00000000..a90b4164 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ReqMeasuring.java @@ -0,0 +1,21 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ReqMeasuring { + @Getter@Setter + @JsonProperty("serviceName") + String serviceName; + + @Getter@Setter + @JsonProperty("location") + String location; +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java new file mode 100644 index 00000000..a5921508 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/model/measure/ResMeasuring.java @@ -0,0 +1,26 @@ +package com.pineone.icbms.so.web.model.measure; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Getter; +import lombok.Setter; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.NON_EMPTY) + +public class ResMeasuring { + @Getter@Setter + @JsonProperty("resultCode") + Integer resultCode; + + @Getter@Setter + @JsonProperty("resultMessage") + Object resultMessage; + + @Getter@Setter + @JsonProperty("sessionId") + String sessionId; +} + diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java new file mode 100644 index 00000000..da096394 --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/IMeasuringService.java @@ -0,0 +1,12 @@ +package com.pineone.icbms.so.web.service; + +import javax.servlet.http.HttpServletRequest; + +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +public interface IMeasuringService { + + Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity); + +} diff --git a/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java new file mode 100644 index 00000000..a0d60a2c --- /dev/null +++ b/so-web/src/main/java/com/pineone/icbms/so/web/service/MeasuringService.java @@ -0,0 +1,192 @@ +package com.pineone.icbms.so.web.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.pineone.icbms.so.interfaces.database.dao.OrchestrationServiceDao; +import com.pineone.icbms.so.interfaces.database.model.DeviceTypeForDB; +import com.pineone.icbms.so.interfaces.database.model.LocationForDB; +import com.pineone.icbms.so.interfaces.database.model.MeasuringVoForDB; +import com.pineone.icbms.so.interfaces.database.model.OrchestrationServiceForDB; +import com.pineone.icbms.so.interfaces.database.model.TrackingEntity; +import com.pineone.icbms.so.interfaces.database.model.VirtualObjectForDB; +import com.pineone.icbms.so.interfaces.database.service.DataBaseStore; +import com.pineone.icbms.so.interfaces.sda.handle.SdaManager; +import com.pineone.icbms.so.interfaces.sda.model.ContextModelContent; +import com.pineone.icbms.so.web.model.MeasuringData; +import com.pineone.icbms.so.web.model.measure.ReqMeasuring; + +import lombok.Getter; +import lombok.Setter; + +@Service +public class MeasuringService implements IMeasuringService { + @Autowired + //IDataBaseStore dataBaseStore; + DataBaseStore dataBaseStore; + + //@Autowired + //protected DatabaseManager databaseManager; + + @Autowired + OrchestrationServiceDao orchestrationServiceDao; + + @Getter @Setter + TrackingEntity tracking; + + protected Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public Object getMeasuredData(ReqMeasuring req, HttpServletRequest request, TrackingEntity trackingEntity) { + + //입력 파라미터 + String locId = req.getLocation(); //설치 위치 + String serviceName = req.getServiceName(); //OS 이름 + + //설치 장소 + LocationForDB locForDB = dataBaseStore.getLocationById(locId); + String locationUri = locForDB.getUri(); + String locName = locForDB.getName(); + + + //1) OS Name으로 osId얻기 + OrchestrationServiceForDB param = new OrchestrationServiceForDB(); + param.setName(serviceName); + + List osForDbList = orchestrationServiceDao.retrieve(param); + if (osForDbList==null || osForDbList.size()==0) { //일치되는 자료 없음 + log.error("Service Info ({}) not found", serviceName); //orchestration_service : name + return null; + } + OrchestrationServiceForDB osForDb = osForDbList.get(0); + String osId = osForDb.getId(); + + //2) os id 로 MeasuringVoForDB 목록을 조회한다 + // osId로 rule_body/rule_item에서 vo list 얻기 : (rule_item의 functionality_id가 FUNCTIONALITY_TYPE_MEASURING인 값만 선택) + // cvo_type이 NONDEVICE_CVO인 경우에는 noncvo테이블을 참조하여 확장 + log.debug("getRuleBodyListByOsId : {}", osId); + List measuringVoForDBList = dataBaseStore.getMeasuringVoList(osId); + + // 측정데이타를 저장할 변수 생성 + List measuringDataList = new ArrayList<>(); + + //3) MeasuringVoForDB의 item별로 동작 + for (MeasuringVoForDB measuringVoItem:measuringVoForDBList) { + + String cvoBaseId = measuringVoItem.getBaseCvoId(); + String cvoType = measuringVoItem.getCvoType(); + + // BaseCvoId 부터 유효 VO 목록을 가져온다. + List validVoList = dataBaseStore.getVirtualObjectListByCompositeVirtualObjectId(cvoBaseId); + if (validVoList.size()==0) { + log.error("Not exist vo list by cvoBase={}", cvoBaseId); + continue; + } + String vId = measuringVoItem.getVoId(); + String aspectUri = null; + String voDesc = null; + + //VO값이 유효한 Vo인지 검사한다. + for (VirtualObjectForDB validVo:validVoList) { + if (vId.equals(validVo.getId())){ + aspectUri = validVo.getAspectUri(); //첫번째 VO만 참조하여 URI를 가져옴 + voDesc = validVo.getDescription(); + break; + } + } + + //유효하지 않으면 + if (aspectUri == null ) { //SKIP + log.error("Not exist aspectUri by list by vId={}", vId); + continue; + } + + // 4) cvo_type별로 sda에서 값 읽기 + List contentList = null; + //4-1) CVO_TYPE_DEVICETYPE or CVO_TYPE_DEVICETYPE_ASPECT + if (cvoType.equals("CVO_TYPE_DEVICETYPE") || cvoType.equals("CVO_TYPE_DEVICETYPE_ASPECT")) { + String physicalDeviceTypeId = measuringVoItem.getPhysicalDeviceTypeId(); + + //PysicalDeviceTypeUri + DeviceTypeForDB typeDb = dataBaseStore.retrieveDeviceTypeById(physicalDeviceTypeId); + if (typeDb==null) { + log.error("error : Device Type info is not exist : physicalDeviceTypeId={}", physicalDeviceTypeId); + continue; + } + String physicalDeviceTypeUri = typeDb.getPhysicalDeviceTypeUri(); + + contentList = new SdaManager().getMeasuringValueByLocDeviceTypeAspect(locationUri, physicalDeviceTypeUri, aspectUri); + } + //4-2) CVO_TYPE_ASPECT + else if (cvoType.equals("CVO_TYPE_ASPECT")) { + + contentList = new SdaManager().getMeasuringValueByLocAspect(locationUri, aspectUri); + } + //4-3) CVO_TYPE_DEVICEID + else if (cvoType.equals("CVO_TYPE_DEVICEID")) { + + String deviceUri = measuringVoItem.getDeviceId(); + contentList = new SdaManager().getMeasuringValueByDevIdAspect(deviceUri, aspectUri); + + } else { + // SKIP + } + + if (contentList != null) { + for (ContextModelContent contentItem:contentList) { + + MeasuringData md = new MeasuringData(); + + md.setDevId(contentItem.getDeviceUri()); + md.setDevName(contentItem.getDeviceName()); + md.setDevTypeDesc(contentItem.getDeviceTypeDesc()); + md.setAspectName(voDesc); + md.setMeasuringValue(contentItem.getValue()); + + measuringDataList.add(md); + } + } + } + +/* + String contextModelId="measuring"; + String contextModelName="Measureing"; + + setTracking((TrackingEntity) request.getSession().getAttribute("tracking")); + String sessionId = trackingEntity.getSessionId(); + + // grib session + SessionEntity sessionEntity = new SessionEntity(); + sessionEntity.setId(sessionId); + sessionEntity.setContextmodelKey(contextModelId); + sessionEntity.setContextmodelName(contextModelName); + sessionEntity.setContextmodelResult("NotHappen"); + sessionEntity.setProfileName(serviceName); + //sessionEntity.setPriorityKey("LOW"); + log.debug("session : {}", sessionEntity); + dataBaseStore.createSessionData(sessionEntity); + + + // grib session location + SessionEntity sessionLocation = new SessionEntity(); + sessionLocation.setId(sessionId); + sessionLocation.setLocationId(locationUri); + log.debug("session location : {}", sessionLocation); + try { + dataBaseStore.createSessionDataLocation(sessionLocation); + }catch(Exception e) { + log.error("Error createSessionDataLocation : error={},\n sessionLocation={}", e.getMessage(), sessionLocation); + } +*/ + + return measuringDataList; + } + +}