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