PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1package com.bluesky.drcp.business.service;
 2
 3import com.bluesky.drcp.business.ClientConfig;
 4import com.bluesky.drcp.persistence.dao.ClientConfigDao;
 5
 6public class ClientConfigService {
 7	private ClientConfigDao clientConfigDao;
 8
 9	public ClientConfigDao getClientConfigDao() {
10		return clientConfigDao;
11	}
12
13	public void setClientConfigDao(ClientConfigDao clientConfigDao) {
14		this.clientConfigDao = clientConfigDao;
15	}
16
17	public String getContentById(String id) {
18		ClientConfig cc = clientConfigDao.getById(id);
19		if(cc==null)
20			return null;
21		else
22			return cc.getContent();
23	}
24
25	public String getContent(String host, String module) {
26
27		String id = clientConfigDao.getId(host, module);
28		if(id==null)
29			return null;
30		else
31			return getContentById(id);
32
33	}
34	
35	public void delete(String id)
36	{
37		clientConfigDao.deleteById(id);
38	}
39
40	public void setContent(String host, String module, String content) {
41		String id;
42
43		id = clientConfigDao.getId(host, module);
44		if(id==null)
45			id="";
46		ClientConfig cc = clientConfigDao.getById(id);
47
48		if(cc != null)
49		{
50			cc.setContent(content);
51			clientConfigDao.update(cc);
52		}
53		else
54		{
55			cc = new ClientConfig();
56			//cc.Id is uuid
57			cc.setHost(host);
58			cc.setModule(module);
59			cc.setContent(content);
60						
61			clientConfigDao.insert(cc);
62		}
63	}
64}