1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.api.service.lsid.impl;
|
11
|
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
13
|
import org.springframework.stereotype.Service;
|
14
|
import org.springframework.transaction.annotation.Transactional;
|
15
|
|
16
|
import com.ibm.lsid.LSIDException;
|
17
|
import com.ibm.lsid.server.LSIDServerException;
|
18
|
import com.ibm.lsid.server.LSIDServiceConfig;
|
19
|
|
20
|
import eu.etaxonomy.cdm.api.service.lsid.LSIDMetadataService;
|
21
|
import eu.etaxonomy.cdm.api.service.lsid.LSIDRegistry;
|
22
|
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
|
23
|
import eu.etaxonomy.cdm.model.common.LSID;
|
24
|
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
|
25
|
|
26
|
@Service("lsidMetadataService")
|
27
|
@Transactional
|
28
|
public class LsidMetadataServiceImpl implements LSIDMetadataService {
|
29
|
|
30
|
private LSIDRegistry lsidRegistry;
|
31
|
|
32
|
@Autowired
|
33
|
public void setLsidRegistry(LSIDRegistry lsidRegistry) {
|
34
|
this.lsidRegistry = lsidRegistry;
|
35
|
}
|
36
|
|
37
|
public IIdentifiableEntity getMetadata(LSID lsid) throws LSIDServerException {
|
38
|
IIdentifiableDao identfiableDAO = lsidRegistry.lookupDAO(lsid);
|
39
|
if(identfiableDAO == null) { // we do not have a mapping for lsids with this authority or namespace
|
40
|
throw new LSIDServerException(LSIDException.UNKNOWN_LSID, "Unknown LSID");
|
41
|
}
|
42
|
|
43
|
try {
|
44
|
IIdentifiableEntity identifiable = identfiableDAO.find(lsid);
|
45
|
if(identifiable == null) { // we have a mapping for lsids with this authority and namespace, but no lsid stored
|
46
|
throw new LSIDServerException(LSIDException.UNKNOWN_LSID, "Unknown LSID");
|
47
|
}
|
48
|
|
49
|
return identifiable;
|
50
|
} catch (LSIDException e) {
|
51
|
throw new LSIDServerException(e, e.getErrorCode(),e.getMessage());
|
52
|
}
|
53
|
}
|
54
|
|
55
|
public void initService(LSIDServiceConfig arg0) throws LSIDServerException {
|
56
|
|
57
|
}
|
58
|
|
59
|
}
|