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 java.util.Date;
|
13
|
|
14
|
import javax.wsdl.WSDLException;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
18
|
import org.springframework.stereotype.Service;
|
19
|
import org.springframework.transaction.annotation.Transactional;
|
20
|
|
21
|
import com.ibm.lsid.ExpiringResponse;
|
22
|
import com.ibm.lsid.LSIDException;
|
23
|
import com.ibm.lsid.server.LSIDServerException;
|
24
|
import com.ibm.lsid.server.LSIDServiceConfig;
|
25
|
import com.ibm.lsid.wsdl.HTTPLocation;
|
26
|
import com.ibm.lsid.wsdl.LSIDDataPort;
|
27
|
import com.ibm.lsid.wsdl.LSIDMetadataPort;
|
28
|
|
29
|
import eu.etaxonomy.cdm.api.service.lsid.LSIDAuthorityService;
|
30
|
import eu.etaxonomy.cdm.api.service.lsid.LSIDRegistry;
|
31
|
import eu.etaxonomy.cdm.api.service.lsid.LSIDWSDLWrapper;
|
32
|
import eu.etaxonomy.cdm.api.service.lsid.LSIDWSDLWrapperFactory;
|
33
|
import eu.etaxonomy.cdm.model.common.LSID;
|
34
|
import eu.etaxonomy.cdm.model.common.LSIDAuthority;
|
35
|
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
|
36
|
/**
|
37
|
*
|
38
|
* @author Ben Szekely (<a href="mailto:bhszekel@us.ibm.com">bhszekel@us.ibm.com</a>)
|
39
|
* @author ben
|
40
|
*
|
41
|
*/
|
42
|
@Service("lsidAuthorityService")
|
43
|
@Transactional
|
44
|
public class LsidAuthorityServiceImpl implements LSIDAuthorityService {
|
45
|
@SuppressWarnings("unused")
|
46
|
private static Logger logger = Logger.getLogger(LsidAuthorityServiceImpl.class);
|
47
|
private String lsidDomain;
|
48
|
private Integer lsidPort;
|
49
|
private LSIDRegistry lsidRegistry;
|
50
|
private LSIDWSDLWrapperFactory lsidWSDLWrapperFactory;
|
51
|
|
52
|
public void setLsidDomain(String lsidDomain) {
|
53
|
this.lsidDomain = lsidDomain;
|
54
|
}
|
55
|
|
56
|
public void setLsidPort(Integer lsidPort) {
|
57
|
this.lsidPort = lsidPort;
|
58
|
}
|
59
|
|
60
|
@Autowired
|
61
|
public void setLsidRegistry(LSIDRegistry lsidRegistry) {
|
62
|
this.lsidRegistry = lsidRegistry;
|
63
|
}
|
64
|
|
65
|
@Autowired
|
66
|
public void setLsidWSDLWrapperFactory(LSIDWSDLWrapperFactory lsidWSDLWrapperFactory) {
|
67
|
this.lsidWSDLWrapperFactory = lsidWSDLWrapperFactory;
|
68
|
}
|
69
|
|
70
|
protected LSIDDataPort[] getDataLocations(LSID lsid) throws LSIDServerException {
|
71
|
IIdentifiableDao identfiableDAO = lsidRegistry.lookupDAO(lsid);
|
72
|
if(identfiableDAO == null) { // we do not have a mapping for lsids with this authority or namespace
|
73
|
throw new LSIDServerException(LSIDException.UNKNOWN_LSID, "Unknown LSID");
|
74
|
}
|
75
|
|
76
|
try {
|
77
|
if(identfiableDAO.find(lsid) == null) { // we have a mapping for lsids with this authority and namespace, but no lsid stored
|
78
|
throw new LSIDServerException(LSIDException.UNKNOWN_LSID, "Unknown LSID");
|
79
|
}
|
80
|
} catch (LSIDException e) {
|
81
|
throw new LSIDServerException(e, e.getErrorCode(),e.getMessage());
|
82
|
}
|
83
|
return new LSIDDataPort[] {
|
84
|
//new SOAPLocation("CATEDataSOAPPort", "http://"+ lsidDomain + ":" + lsidPort + "/authority/data/soap/"),
|
85
|
new HTTPLocation("CATEDataHTTPPort", lsidDomain, lsidPort, "/authority/data.do") };
|
86
|
}
|
87
|
|
88
|
protected LSIDMetadataPort[] getMetadataLocations(LSID lsid) {
|
89
|
return new LSIDMetadataPort[] {
|
90
|
new HTTPLocation("CATEMetadataHTTPPort", lsidDomain, lsidPort, "/authority/metadata.do")
|
91
|
};
|
92
|
}
|
93
|
|
94
|
@Override
|
95
|
public void initService(LSIDServiceConfig arg0) throws LSIDServerException {
|
96
|
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* Get the expiration date/time of the available operations. By default, returns null, indicating no expiration.
|
101
|
* Implementing classes should override this method if they want to include expiration information.
|
102
|
* @return Date the date/time at which the available operations will expire.
|
103
|
*/
|
104
|
protected Date getExpiration() {
|
105
|
return null;
|
106
|
}
|
107
|
|
108
|
@Override
|
109
|
public ExpiringResponse getAvailableServices(LSID lsid) throws LSIDServerException {
|
110
|
try {
|
111
|
LSIDWSDLWrapper wsdl = lsidWSDLWrapperFactory.getLSIDWSDLWrapper(lsid);
|
112
|
|
113
|
for (LSIDDataPort lsidDataPort : getDataLocations(lsid)) {
|
114
|
wsdl.setDataLocation(lsidDataPort);
|
115
|
}
|
116
|
|
117
|
for (LSIDMetadataPort lsidMetadataPort : getMetadataLocations(lsid)) {
|
118
|
wsdl.setMetadataLocation(lsidMetadataPort);
|
119
|
}
|
120
|
|
121
|
|
122
|
return new ExpiringResponse(wsdl.getWSDLSource(), getExpiration());
|
123
|
} catch (LSIDException e) {
|
124
|
throw new LSIDServerException(e, e.getErrorCode(), "LSIDAuthorityServiceImpl Error in getAvailableOperations");
|
125
|
} catch (WSDLException e) {
|
126
|
throw new LSIDServerException(e, LSIDServerException.INTERNAL_PROCESSING_ERROR, "LSIDAuthorityServiceImpl Error in getAvailableOperations");
|
127
|
}
|
128
|
}
|
129
|
|
130
|
@Override
|
131
|
public void notifyForeignAuthority(LSID lsid, LSIDAuthority arg1) throws LSIDServerException {
|
132
|
throw new LSIDServerException(LSIDServerException.METHOD_NOT_IMPLEMENTED, "FAN service not available");
|
133
|
}
|
134
|
|
135
|
@Override
|
136
|
public void revokeNotificationForeignAuthority(LSID lsid, LSIDAuthority arg1) throws LSIDServerException {
|
137
|
throw new LSIDServerException(LSIDServerException.METHOD_NOT_IMPLEMENTED, "FAN service not available");
|
138
|
}
|
139
|
|
140
|
@Override
|
141
|
public ExpiringResponse getAuthorityWSDL() throws LSIDServerException {
|
142
|
LSID lsid = null;
|
143
|
LSIDWSDLWrapper wsdl = lsidWSDLWrapperFactory.getLSIDWSDLWrapper(lsid);
|
144
|
|
145
|
try {
|
146
|
wsdl.setAuthorityLocation(new HTTPLocation("AuthorityServiceHTTP", "HTTPPort", lsidDomain, lsidPort, null));
|
147
|
//lsidWSDLWrapperFactory.setAuthorityLocation(new SOAPLocation("AuthorityServiceSOAP", "SOAPPort", "http://" + lsidDomain + ":" + lsidPort + "/authority/soap/"), wsdl);
|
148
|
return new ExpiringResponse(wsdl.getWSDLSource(), getExpiration());
|
149
|
} catch (LSIDException e) {
|
150
|
throw new LSIDServerException(e, e.getErrorCode(), "LSIDAuthorityServiceImpl Error in getAuthorityWSDL");
|
151
|
} catch (WSDLException e) {
|
152
|
throw new LSIDServerException(e, LSIDServerException.INTERNAL_PROCESSING_ERROR, "LSIDAuthorityServiceImpl Error in getAuthorityWSDL");
|
153
|
}
|
154
|
|
155
|
|
156
|
}
|
157
|
}
|