/web/DRCP/src/com/bluesky/drcp/business/service/ClientConfigService.java
http://drcp.googlecode.com/ · Java · 64 lines · 50 code · 13 blank · 1 comment · 5 complexity · cc52ffbee1b538d5d48d2c71451419c9 MD5 · raw file
- package com.bluesky.drcp.business.service;
-
- import com.bluesky.drcp.business.ClientConfig;
- import com.bluesky.drcp.persistence.dao.ClientConfigDao;
-
- public class ClientConfigService {
- private ClientConfigDao clientConfigDao;
-
- public ClientConfigDao getClientConfigDao() {
- return clientConfigDao;
- }
-
- public void setClientConfigDao(ClientConfigDao clientConfigDao) {
- this.clientConfigDao = clientConfigDao;
- }
-
- public String getContentById(String id) {
- ClientConfig cc = clientConfigDao.getById(id);
- if(cc==null)
- return null;
- else
- return cc.getContent();
- }
-
- public String getContent(String host, String module) {
-
- String id = clientConfigDao.getId(host, module);
- if(id==null)
- return null;
- else
- return getContentById(id);
-
- }
-
- public void delete(String id)
- {
- clientConfigDao.deleteById(id);
- }
-
- public void setContent(String host, String module, String content) {
- String id;
-
- id = clientConfigDao.getId(host, module);
- if(id==null)
- id="";
- ClientConfig cc = clientConfigDao.getById(id);
-
- if(cc != null)
- {
- cc.setContent(content);
- clientConfigDao.update(cc);
- }
- else
- {
- cc = new ClientConfig();
- //cc.Id is uuid
- cc.setHost(host);
- cc.setModule(module);
- cc.setContent(content);
-
- clientConfigDao.insert(cc);
- }
- }
- }