1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.gwe.persistence.model;
18
19 import javax.persistence.Entity;
20 import javax.persistence.FetchType;
21 import javax.persistence.Id;
22 import javax.persistence.OneToOne;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.gwe.api.ServerAPILink;
27 import org.gwe.app.Distribution;
28 import org.gwe.drivers.netAccess.HostHandle;
29 import org.gwe.drivers.netAccess.tunneling.TunneledSocketFactory;
30 import org.gwe.utils.security.KeyStore;
31 import org.gwe.utils.security.ResourceLink;
32
33
34
35
36
37 @Entity
38 public class DaemonConfigDesc extends BaseModelInfo<Integer> {
39
40 private static Log log = LogFactory.getLog(DaemonConfigDesc.class);
41
42 @Id
43 private Integer id;
44
45 private Distribution distribution;
46
47 private String email;
48 private KeyStore keys;
49
50
51
52 @OneToOne(fetch = FetchType.EAGER)
53 private HeadResourceInfo headResource;
54
55 @OneToOne(fetch = FetchType.EAGER)
56 private OrderExecutionProfileInfo defaultExecutionProfile = new OrderExecutionProfileInfo();
57
58 public DaemonConfigDesc() {}
59
60 public DaemonConfigDesc(HeadResourceInfo headResource, KeyStore keys, Distribution distribution) {
61 setHeadResource(headResource);
62 setKeys(keys);
63 setDistribution(distribution);
64 }
65
66 public Integer getId() {
67 return id;
68 }
69
70 public String getEmail() {
71 return email;
72 }
73
74 public void setEmail(String email) {
75 this.email = email;
76 }
77
78 public Distribution getDistribution() {
79 return distribution;
80 }
81
82 public void setDistribution(Distribution distribution) {
83 this.distribution = distribution;
84 }
85
86 public OrderExecutionProfileInfo getDefaultExecutionProfile() {
87 return defaultExecutionProfile;
88 }
89
90 public void setDefaultExecutionProfile(OrderExecutionProfileInfo defaultExecutionProfile) {
91 this.defaultExecutionProfile = defaultExecutionProfile;
92 }
93
94 public HeadResourceInfo getHeadResource() {
95 return headResource;
96 }
97
98 public void setHeadResource(HeadResourceInfo headResource) {
99 this.headResource = headResource;
100 }
101
102 public KeyStore getKeys() {
103 return keys;
104 }
105
106 public void setKeys(KeyStore keys) {
107 this.keys = keys;
108 initializeServices();
109 }
110
111 public String getConnectionURL() {
112 return headResource.getConnectionURL(keys);
113 }
114
115 public ResourceLink<HostHandle> getDaemonHostLink() {
116 return getKeys().createHostLink(headResource.getCompURI());
117 }
118
119 public ServerAPILink createAPILink() {
120 return new ServerAPILink(headResource, getDaemonHostLink());
121 }
122
123 public String getAllocWorkspace(int allocId) {
124 return headResource.getInstallation().getAllocsWorkspacePath(allocId);
125 }
126
127
128 public void initializeServices() {
129 TunneledSocketFactory.setKeys(keys);
130 }
131 }
132