Project

General

Profile

« Previous | Next » 

Revision 49662

Work in progress

View differences:

modules/dnet-openaireplus-datasource-manager/trunk/src/main/java/eu/dnetlib/enabling/datasources/DatasourceParams.java
1
package eu.dnetlib.enabling.datasources;
2

  
3
public enum DatasourceParams {
4
	baseUrl, iis_processing_workflow, metadata_identifier_path
5
}
modules/dnet-openaireplus-datasource-manager/trunk/src/main/java/eu/dnetlib/enabling/datasources/LocalOpenaireDatasourceManager.java
23 23
import com.google.common.collect.Lists;
24 24
import com.google.common.collect.Maps;
25 25

  
26
import eu.dnetlib.enabling.datasources.common.BrowsableField;
26
import eu.dnetlib.enabling.datasources.common.Api;
27 27
import eu.dnetlib.enabling.datasources.common.BrowseTerm;
28
import eu.dnetlib.enabling.datasources.common.DatasourceConstants;
29
import eu.dnetlib.enabling.datasources.common.DatasourceDesc;
28
import eu.dnetlib.enabling.datasources.common.Datasource;
30 29
import eu.dnetlib.enabling.datasources.common.DatasourceManager;
31
import eu.dnetlib.enabling.datasources.common.DatasourceManagerServiceException;
32
import eu.dnetlib.enabling.datasources.common.IfaceDesc;
33
import eu.dnetlib.enabling.datasources.common.RepositoryMapEntry;
34
import eu.dnetlib.enabling.datasources.common.SearchInterfacesEntry;
35
import eu.dnetlib.enabling.datasources.common.SimpleDatasourceDesc;
30
import eu.dnetlib.enabling.datasources.common.DatasourceManagerException;
36 31

  
37
public class LocalOpenaireDatasourceManager implements DatasourceManager {
32
public class LocalOpenaireDatasourceManager implements DatasourceManager<Datasource<?, ?>, Api> {
38 33

  
39 34
	private DatasourceManagerClients datasourceManagerClients;
40 35

  
......
43 38
	private static final Log log = LogFactory.getLog(LocalOpenaireDatasourceManager.class);
44 39

  
45 40
	@Override
46
	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
41
	public void saveDs(final Datasource<?, ?> ds) throws DatasourceManagerException {
47 42
		if (StringUtils.isBlank(ds.getAggregator())) {
48 43
			ds.setAggregator("OPENAIRE");
49 44
		}
50 45

  
51 46
		final Map<String, Object> params = DatasourceFunctions.asMapOfSqlValues(ds);
52 47

  
53
		if ((ds.getOrganization() != null) && !ds.getOrganization().trim().isEmpty()) {
48
		if ((ds.getOrganizations() != null) && !ds.getOrganizations().isEmpty()) {
54 49
			params.put("hasOrganization", 1);
55 50
		}
56
		return datasourceManagerClients.updateSQL(ds.getId(), "addDatasource.sql.st", params, false, true);
51

  
52
		datasourceManagerClients.updateSQL(ds.getId(), "addDatasource.sql.st", params, false, true);
57 53
	}
58 54

  
59 55
	@Override
60
	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
56
	public void deleteDs(final String dsId) throws DatasourceManagerException {
61 57
		final Map<String, Object> params = Maps.newHashMap();
62 58

  
63 59
		params.put("dsId", DatasourceFunctions.asSqlValue(dsId));
64 60

  
65
		return datasourceManagerClients.updateSQL(dsId, "deleteDatasource.sql.st", params, true, true);
61
		datasourceManagerClients.updateSQL(dsId, "deleteDatasource.sql.st", params, true, true);
66 62
	}
67 63

  
68 64
	@Override
69
	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
70
		final List<DatasourceDesc> list = datasourceManagerClients.getDatasourcesByCondition("ds.id = " + DatasourceFunctions.asSqlValue(dsId));
71
		if (list.size() != 1) { throw new DatasourceManagerServiceException("Datasource not found, id=" + dsId); }
65
	public Datasource<?, ?> getDs(final String dsId) throws DatasourceManagerException {
66
		final List<Datasource<?, ?>> list = datasourceManagerClients.getDatasourcesByCondition("ds.id = " + DatasourceFunctions.asSqlValue(dsId));
67
		if (list.size() != 1) { throw new DatasourceManagerException("Datasource not found, id=" + dsId); }
72 68

  
73 69
		return list.get(0);
74 70
	}
75 71

  
76 72
	@Override
77
	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
73
	public void updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerException {
78 74
		final Map<String, Object> params = Maps.newHashMap();
79 75

  
80 76
		params.put("active", DatasourceFunctions.asSqlValue(active));
81 77
		params.put("ifaceId", DatasourceFunctions.asSqlValue(ifaceId));
82 78
		params.put("dsId", DatasourceFunctions.asSqlValue(dsId));
83 79

  
84
		return datasourceManagerClients.updateSQL(dsId, "updateActivationStatus.sql.st", params, false, true);
80
		datasourceManagerClients.updateSQL(dsId, "updateActivationStatus.sql.st", params, false, true);
85 81
	}
86 82

  
87 83
	@Override
88
	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
84
	public void updateCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerException {
89 85
		final Map<String, Object> params = Maps.newHashMap();
90 86

  
91 87
		params.put("level", DatasourceFunctions.asSqlValue(level));
92 88
		params.put("ifaceId", DatasourceFunctions.asSqlValue(ifaceId));
93 89
		params.put("dsId", DatasourceFunctions.asSqlValue(dsId));
94 90

  
95
		return datasourceManagerClients.updateSQL(dsId, "updateLevelOfCompliance.sql.st", params, false, true);
91
		datasourceManagerClients.updateSQL(dsId, "updateLevelOfCompliance.sql.st", params, false, true);
96 92
	}
97 93

  
98 94
	@Override
99
	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
100
		return updateAccessParam(dsId, ifaceId, DatasourceParams.baseUrl.toString(), baseUrl);
95
	public void updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerException {
96
		updateAccessParam(dsId, ifaceId, DatasourceParams.baseUrl.toString(), baseUrl);
101 97
	}
102 98

  
103 99
	@Override
104
	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
100
	public void addApi(final Api iface) throws DatasourceManagerException {
105 101
		final Map<String, Object> params = Maps.newHashMap();
106
		params.put("desc", DatasourceFunctions.asSqlValue(desc));
107
		params.put("ifaceId", DatasourceFunctions.asSqlValue(ifaceId));
108
		params.put("dsId", DatasourceFunctions.asSqlValue(dsId));
109 102

  
110
		return datasourceManagerClients.updateSQL(dsId, "updateContentDescription.sql.st", params, false, true);
111
	}
112

  
113
	@Override
114
	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
115
		final Map<String, Object> params = Maps.newHashMap();
116

  
117
		params.put("datasource", DatasourceFunctions.asSqlValue(dsId));
103
		params.put("datasource", DatasourceFunctions.asSqlValue(iface.getDatasource()));
118 104
		params.put("id", DatasourceFunctions.asSqlValue(iface.getId()));
119 105
		params.put("typology", DatasourceFunctions.asSqlValue(iface.getTypology()));
120 106
		params.put("protocol", DatasourceFunctions.asSqlValue(iface.getAccessProtocol()));
......
138 124
		}
139 125
		params.put("extraFields", extraFields);
140 126

  
141
		return datasourceManagerClients.updateSQL(dsId, "insertInterface.sql.st", params, false, true);
127
		datasourceManagerClients.updateSQL(dsId, "insertInterface.sql.st", params, false, true);
142 128
	}
143 129

  
144 130
	@Override
145
	public boolean deleteInterface(final String dsId, final String ifcId) throws DatasourceManagerServiceException {
131
	public void deleteApi(String dsId, final String ifcId) throws DatasourceManagerException {
146 132
		final Map<String, Object> params = Maps.newHashMap();
147 133

  
148 134
		params.put("datasource", DatasourceFunctions.asSqlValue(dsId));
149 135
		params.put("id", DatasourceFunctions.asSqlValue(ifcId));
150 136

  
151
		return datasourceManagerClients.updateSQL(dsId, "deleteInterface.sql.st", params, false, true);
137
		datasourceManagerClients.updateSQL(dsId, "deleteInterface.sql.st", params, false, true);
152 138
	}
153 139

  
154 140
	@Override
155
	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value) throws DatasourceManagerServiceException {
141
	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value) throws DatasourceManagerException {
156 142

  
157 143
		final String openaireDsId = datasourceManagerClients.findDatasourceId(dsId);
158 144

  
......
175 161
	}
176 162

  
177 163
	@Override
178
	public boolean deleteAccessParam(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
164
	public boolean deleteAccessParam(final String dsId, final String ifaceId, final String field) throws DatasourceManagerException {
179 165
		final Map<String, Object> params = Maps.newHashMap();
180 166

  
181 167
		params.put("dsId", DatasourceFunctions.asSqlValue(dsId));
......
186 172
	}
187 173

  
188 174
	@Override
189
	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
175
	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerException {
190 176
		return datasourceManagerClients.updateSQL(dsId, sql, delete, true);
191 177
	}
192 178

  
193 179
	@Override
194 180
	public Date findNextScheduledExecution(final String dsId, final String ifaceId)
195
			throws DatasourceManagerServiceException {
181
			throws DatasourceManagerException {
196 182
		return datasourceManagerClients.findNextScheduledExecution(dsId, ifaceId);
197 183
	}
198 184

  
199 185
	@Override
200 186
	public boolean bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
201
			throws DatasourceManagerServiceException {
187
			throws DatasourceManagerException {
202 188
		return performUpdate(repoId, ifaceId, params, true);
203 189
	}
204 190

  
205 191
	private boolean performUpdate(final String repoId, final String ifaceId, final Map<String, String> params, final boolean accessParam)
206
			throws DatasourceManagerServiceException {
192
			throws DatasourceManagerException {
207 193
		final String dsId = datasourceManagerClients.findDatasourceId(repoId);
208 194

  
209 195
		if (!accessParam) {
......
217 203
		return true;
218 204
	}
219 205

  
220
	private boolean deleteOldExtraFields(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
206
	private boolean deleteOldExtraFields(final String dsId, final String ifaceId) throws DatasourceManagerException {
221 207
		final Map<String, Object> params = Maps.newHashMap();
222 208

  
223 209
		params.put("dsId", DatasourceFunctions.asSqlValue(dsId));
......
227 213
	}
228 214

  
229 215
	private boolean performSingleUpdate(final String dsId, final String ifaceId, final String field, final String value, final boolean accessParam)
230
			throws DatasourceManagerServiceException {
216
			throws DatasourceManagerException {
231 217
		final Map<String, Object> params = Maps.newHashMap();
232 218

  
233 219
		params.put("dsId", DatasourceFunctions.asSqlValue(dsId));
......
257 243
	}
258 244

  
259 245
	@Override
260
	public boolean overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
246
	public boolean overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerException {
261 247

  
262 248
		final String dsId = datasourceManagerClients.findDatasourceId(repoId);
263 249

  
......
283 269
	}
284 270

  
285 271
	@Override
286
	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
272
	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerException {
287 273
		return Lists.transform(getBrowsableFields(), new Function<DbBrowsableField, BrowsableField>() {
288 274

  
289 275
			@Override
......
294 280
	}
295 281

  
296 282
	@Override
297
	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
283
	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerException {
298 284
		final List<BrowseTerm> list = Lists.newArrayList();
299 285

  
300 286
		try {
......
319 305
	}
320 306

  
321 307
	@Override
322
	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
308
	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerException {
323 309
		try {
324 310
			final Map<String, Object> params = Maps.newHashMap();
325 311
			params.put("value", value);
......
375 361
	}
376 362

  
377 363
	@Override
378
	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
364
	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerException {
379 365
		final SAXReader reader = new SAXReader();
380 366

  
381 367
		try {
......
400 386
	}
401 387

  
402 388
	@Override
403
	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
389
	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerException {
404 390
		final Map<String, Object> params = Maps.newHashMap();
405 391
		params.put("type", type);
406 392
		final List<SimpleDatasourceDesc> list = Lists.newArrayList();
modules/dnet-openaireplus-datasource-manager/trunk/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerClients.java
25 25

  
26 26
import eu.dnetlib.enabling.database.rmi.DatabaseException;
27 27
import eu.dnetlib.enabling.database.rmi.DatabaseService;
28
import eu.dnetlib.enabling.datasources.common.DatasourceDesc;
29
import eu.dnetlib.enabling.datasources.common.DatasourceManagerServiceException;
28
import eu.dnetlib.enabling.datasources.common.DatasourceManagerException;
30 29
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
31 30
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
32 31
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
......
46 45
	private UniqueServiceLocator serviceLocator;
47 46
	private ResultSetClientFactory resultSetClientFactory;
48 47

  
49
	public String findDatasourceId(final String profileId) throws DatasourceManagerServiceException {
48
	public String findDatasourceId(final String profileId) throws DatasourceManagerException {
50 49
		try {
51 50
			return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
52 51
					"/*[.//RESOURCE_IDENTIFIER/@value='" + profileId + "']//EXTRA_FIELDS/FIELD[./key='OpenAireDataSourceId']/value/text()");
53 52
		} catch (final Exception e) {
54 53
			log.error("Error finding dsId of profile " + profileId, e);
55
			throw new DatasourceManagerServiceException("Error finding dsId of profile " + profileId, e);
54
			throw new DatasourceManagerException(-1, "Error finding dsId of profile " + profileId, e);
56 55
		}
57 56
	}
58 57

  
59
	public String getDatasourceProfile(final String dsId) throws DatasourceManagerServiceException {
58
	public String getDatasourceProfile(final String dsId) throws DatasourceManagerException {
60 59
		try {
61 60
			return serviceLocator.getService(ISLookUpService.class)
62 61
					.getResourceProfileByQuery(
......
67 66
		}
68 67
	}
69 68

  
70
	public boolean deleteProfile(final String dsId) throws DatasourceManagerServiceException {
69
	public boolean deleteProfile(final String dsId) throws DatasourceManagerException {
71 70
		try {
72 71
			final SAXReader reader = new SAXReader();
73 72

  
......
81 80
			return true;
82 81
		} catch (final Exception e) {
83 82
			log.error("Error deleting profile", e);
84
			throw new DatasourceManagerServiceException("Error deleting profile", e);
83
			throw new DatasourceManagerException(-1, "Error deleting profile", e);
85 84
		}
86 85
	}
87 86

  
88
	public boolean regenerateProfile(final String dsId) throws DatasourceManagerServiceException {
87
	public boolean regenerateProfile(final String dsId) throws DatasourceManagerException {
89 88

  
90 89
		try {
91 90
			final SAXReader reader = new SAXReader();
92 91

  
93 92
			final List<String> list = getTransformedDatasourcesByCondition("ds.id= '" + dsId + "'", new ApplyXslt(xslt));
94 93

  
95
			if (list.size() != 1) { throw new DatasourceManagerServiceException("Illegal number of datasource with id " + dsId + ", size: " + list.size()); }
94
			if (list.size() != 1) { throw new DatasourceManagerException(-1, "Illegal number of datasource with id " + dsId + ", size: " + list.size()); }
96 95

  
97 96
			final Document doc = reader.read(new StringReader(list.get(0)));
98 97

  
......
115 114
			return true;
116 115
		} catch (final Exception e) {
117 116
			log.error("Error saving profile, id: " + dsId, e);
118
			throw new DatasourceManagerServiceException("Error regenerating profile", e);
117
			throw new DatasourceManagerException(-1, "Error regenerating profile", e);
119 118
		}
120 119
	}
121 120

  
......
124 123
		return resultSetClientFactory.getClient(epr);
125 124
	}
126 125

  
127
	public boolean updateSQL(final String dsId, final String sql, final boolean delete, final boolean updateprofile) throws DatasourceManagerServiceException {
126
	public boolean updateSQL(final String dsId, final String sql, final boolean delete, final boolean updateprofile) throws DatasourceManagerException {
128 127
		log.debug("Executing query SQL: " + sql);
129 128

  
130 129
		try {
131 130
			serviceLocator.getService(DatabaseService.class).updateSQL(getDb(), sql);
132 131
		} catch (final DatabaseException e) {
133
			throw new DatasourceManagerServiceException(e);
132
			throw new DatasourceManagerException(-1, "Error in SQL query", e);
134 133
		}
135 134

  
136 135
		if (updateprofile) {
......
144 143
	}
145 144

  
146 145
	public boolean updateSQL(final String dsId, final String sqlTemplate, final Map<String, Object> params, final boolean delete, final boolean updateProfile)
147
			throws DatasourceManagerServiceException {
146
			throws DatasourceManagerException {
148 147

  
149 148
		verifyParams(params.values());
150 149
		verifyParams(params.keySet().toArray());
......
156 155
			return updateSQL(dsId, st.toString(), delete, updateProfile);
157 156
		} catch (final Exception e) {
158 157
			log.error("Error in updateSQL", e);
159
			throw new DatasourceManagerServiceException("Error in updateSQL", e);
158
			throw new DatasourceManagerException(-1, "Error in updateSQL", e);
160 159
		}
161 160
	}
162 161

  
163
	public List<DatasourceDesc> getDatasourcesByCondition(final String condition) throws DatasourceManagerServiceException {
164
		final SAXReader reader = new SAXReader();
165
		final List<DatasourceDesc> list = Lists.newArrayList();
166
		try {
167
			for (final String s : getXmlDatasourcesByCondition(condition)) {
168
				final Document doc = reader.read(new StringReader(s));
169
				list.add(DatasourceFunctions.xmlToDatasourceDesc(doc));
170
			}
171
		} catch (final Exception e) {
172
			log.error("Error obtaining datasources from db", e);
173
			throw new DatasourceManagerServiceException("Error obtaining datasources from db", e);
174
		}
175
		return list;
162
	private void verifyParams(final Object... params) throws DatasourceManagerException {
176 163

  
177
	}
178

  
179
	private void verifyParams(final Object... params) throws DatasourceManagerServiceException {
180

  
181 164
		final Pattern pattern = Pattern.compile("\\n");
182 165

  
183 166
		for (final Object p : params) {
184 167
			log.debug("TESTING SQL PARAM:" + p);
185 168
			if ((p == null) || p.toString().isEmpty()) {
186 169
				log.error("Parameter null or empty");
187
				throw new DatasourceManagerServiceException("Parameter null or empty");
170
				throw new DatasourceManagerException(-1, "Parameter null or empty");
188 171
			} else if (pattern.matcher(p.toString()).matches()) {
189 172
				log.error("Parameter [" + p + "] contains an invalid character");
190
				throw new DatasourceManagerServiceException("Parameter [" + p + "] contains an invalid character");
173
				throw new DatasourceManagerException(-1, "Parameter [" + p + "] contains an invalid character");
191 174
			} else {
192 175
				log.debug("TEST OK");
193 176
			}
......
195 178
	}
196 179

  
197 180
	private List<String> getTransformedDatasourcesByCondition(final String condition, final UnaryFunction<String, String> function)
198
			throws DatasourceManagerServiceException {
181
			throws DatasourceManagerException {
199 182
		final List<String> list = Lists.newArrayList();
200 183
		try {
201 184
			for (final String s : getXmlDatasourcesByCondition(condition)) {
......
203 186
			}
204 187
		} catch (final Exception e) {
205 188
			log.error("Error obtaining datasources from db", e);
206
			throw new DatasourceManagerServiceException("Error obtaining datasources from db", e);
189
			throw new DatasourceManagerException(-1, "Error obtaining datasources from db", e);
207 190
		}
208 191
		return list;
209 192
	}
210 193

  
211
	private Iterable<String> getXmlDatasourcesByCondition(final String condition) throws DatasourceManagerServiceException {
194
	private Iterable<String> getXmlDatasourcesByCondition(final String condition) throws DatasourceManagerException {
212 195
		try {
213 196
			final Map<String, Object> params = Maps.newHashMap();
214 197

  
......
218 201
			return searchSQL("getDatasources.sql.st", params);
219 202
		} catch (final Exception e) {
220 203
			log.error("Error obtaining datasources from db", e);
221
			throw new DatasourceManagerServiceException("Error obtaining datasources from db", e);
204
			throw new DatasourceManagerException(-1, "Error obtaining datasources from db", e);
222 205
		}
223 206
	}
224 207

  
225
	public Iterable<String> searchSQL(final String sqlTemplate, final Map<String, Object> params) throws DatasourceManagerServiceException {
208
	public Iterable<String> searchSQL(final String sqlTemplate, final Map<String, Object> params) throws DatasourceManagerException {
226 209
		try {
227 210
			final Resource resource = new ClassPathResource(TMPLS_BASEDIR + sqlTemplate);
228 211
			final StringTemplate st = new StringTemplate(IOUtils.toString(resource.getInputStream()));
......
238 221
		} catch (final Exception e) {
239 222
			log.error("Error executing sql", e);
240 223

  
241
			throw new DatasourceManagerServiceException("Error obtaining datasources from db", e);
224
			throw new DatasourceManagerException(-1, "Error obtaining datasources from db", e);
242 225
		}
243 226
	}
244 227

  
245
	public boolean isDefinedParam(final String ifaceId, final String field) throws DatasourceManagerServiceException {
228
	public boolean isDefinedParam(final String ifaceId, final String field) throws DatasourceManagerException {
246 229
		final Map<String, Object> params = Maps.newHashMap();
247 230
		params.put("ifaceId", DatasourceFunctions.asSqlValue(ifaceId));
248 231
		params.put("field", DatasourceFunctions.asSqlValue(field));
......
252 235
		return !list.isEmpty();
253 236
	}
254 237

  
255
	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
238
	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerException {
256 239
		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
257 240
		try {
258 241
			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
......
263 246
			return null;
264 247
		} catch (final ISLookUpException e) {
265 248
			log.error("Error in xquery: " + xquery, e);
266
			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
249
			throw new DatasourceManagerException(-1, "Error in xquery: " + xquery, e);
267 250
		} catch (final ParseException e) {
268 251
			log.error("Error parsing cron expression", e);
269
			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
252
			throw new DatasourceManagerException(-1, "Error parsing cron expression", e);
270 253
		}
271 254
	}
272 255

  
modules/dnet-openaireplus-datasource-manager/trunk/src/main/java/eu/dnetlib/enabling/datasources/DbBrowsableField.java
1 1
package eu.dnetlib.enabling.datasources;
2 2

  
3
import eu.dnetlib.enabling.datasources.common.BrowsableField;
3
public class DbBrowsableField {
4 4

  
5
public class DbBrowsableField extends BrowsableField {
6

  
5
	private String id;
6
	private String label;
7 7
	private String sql;
8

  
9 8
	private boolean text = true;
10 9

  
11 10
	public DbBrowsableField() {
12 11
		super();
13 12
	}
14 13

  
15
	public DbBrowsableField(final String id, final String label) {
16
		super(id, label);
17
	}
18

  
19 14
	public DbBrowsableField(final String id, final String label, final String sql) {
20
		super(id, label);
15
		this.id = id;
16
		this.label = label;
21 17
		this.sql = sql;
22 18
	}
23 19

  
20
	public String getId() {
21
		return id;
22
	}
23

  
24
	public void setId(String id) {
25
		this.id = id;
26
	}
27

  
28
	public String getLabel() {
29
		return label;
30
	}
31

  
32
	public void setLabel(String label) {
33
		this.label = label;
34
	}
35

  
24 36
	public String getSql() {
25 37
		return sql;
26 38
	}
27 39

  
28
	public void setSql(final String sql) {
40
	public void setSql(String sql) {
29 41
		this.sql = sql;
30 42
	}
31 43

  
modules/dnet-openaireplus-datasource-manager/trunk/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-dnet-openaireplus-datasource-manager-service.xml
13 13
                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
14 14
                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
15 15

  
16
	<bean id="datasourceManagerService" 
17
		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl"
16
	<bean id="localOpenaireDatasourceManager" 
17
		class="eu.dnetlib.enabling.datasources.LocalOpenaireDatasourceManager"
18 18
		p:datasourceManagerClients-ref="datasourceManagerClients">
19 19
		<property name="browsableFields">
20 20
		<list>
......
48 48
		p:db="${dnet.openaire.db.name}"
49 49
		p:serviceLocator-ref="uniqueServiceLocator"
50 50
		p:resultSetClientFactory-ref="resultSetClientFactory" />
51

  
52
	<!-- endpoints -->
53
	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
54
		implementor="#datasourceManagerService"
55
		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
56
		address="/datasourceManager" />
57

  
58
	<template:instance name="serviceRegistrationManager"
59
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
60
		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
61
		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
62 51
		
63 52
</beans>

Also available in: Unified diff