Revision 47797
Added by Claudio Atzori almost 7 years ago
modules/cnr-enabling-services/trunk/src/main/java/eu/dnetlib/enabling/is/lookup/ISLookUpServiceImpl.java | ||
---|---|---|
4 | 4 |
import java.io.StringReader; |
5 | 5 |
import java.util.ArrayList; |
6 | 6 |
import java.util.List; |
7 |
|
|
7 |
import java.util.regex.Matcher; |
|
8 |
import java.util.regex.Pattern; |
|
8 | 9 |
import javax.jws.WebService; |
9 | 10 |
import javax.xml.parsers.ParserConfigurationException; |
10 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
11 | 11 |
import javax.xml.xpath.XPathExpressionException; |
12 | 12 |
|
13 |
import com.sun.xml.messaging.saaj.util.Base64; |
|
14 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException; |
|
15 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
16 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
17 |
import eu.dnetlib.enabling.is.store.rmi.ISStoreException; |
|
18 |
import eu.dnetlib.enabling.is.store.rmi.ISStoreService; |
|
19 |
import eu.dnetlib.enabling.tools.*; |
|
20 |
import org.apache.commons.lang3.StringUtils; |
|
13 | 21 |
import org.apache.commons.logging.Log; |
14 | 22 |
import org.apache.commons.logging.LogFactory; |
15 | 23 |
import org.dom4j.Document; |
... | ... | |
18 | 26 |
import org.springframework.beans.factory.annotation.Required; |
19 | 27 |
import org.xml.sax.SAXException; |
20 | 28 |
|
21 |
import com.sun.xml.messaging.saaj.util.Base64; |
|
22 |
|
|
23 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException; |
|
24 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
25 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
26 |
import eu.dnetlib.enabling.is.store.rmi.ISStoreException; |
|
27 |
import eu.dnetlib.enabling.is.store.rmi.ISStoreService; |
|
28 |
import eu.dnetlib.enabling.tools.AbstractBaseService; |
|
29 |
import eu.dnetlib.enabling.tools.CompatResourceIdentifierResolverImpl; |
|
30 |
import eu.dnetlib.enabling.tools.OpaqueResource; |
|
31 |
import eu.dnetlib.enabling.tools.ResourceIdentifierResolver; |
|
32 |
import eu.dnetlib.enabling.tools.ResourceType; |
|
33 |
import eu.dnetlib.enabling.tools.StringOpaqueResource; |
|
34 |
import eu.dnetlib.enabling.tools.XQueryUtils; |
|
35 |
|
|
36 | 29 |
/** |
37 | 30 |
* ISLookUpService implementation. |
38 | 31 |
* |
... | ... | |
208 | 201 |
@Override |
209 | 202 |
public String getResourceProfileByQuery(final String xquery) throws ISLookUpException { |
210 | 203 |
String resource; |
204 |
//TODO remove following hack as soon as https://issue.openaire.research-infrastructures.eu/issues/2774 is closed. |
|
205 |
if (StringUtils.isNotBlank(xquery) && xquery.trim().startsWith("//*[local-name() = 'complexType'")) { |
|
206 |
final Pattern p = Pattern.compile(".*value = '([a-zA-z]+)']"); |
|
207 |
final Matcher m = p.matcher(xquery); |
|
208 |
if (m.matches()) { |
|
209 |
final String serviceName = m.group(1); |
|
210 |
log.debug(String.format("found service '%s', hacking response for xquery: %s", serviceName, xquery)); |
|
211 |
return getResourceTypeSchema(serviceName); |
|
212 |
} |
|
213 |
} |
|
211 | 214 |
try { |
212 | 215 |
resource = isStore.getXMLbyQuery(xquery); |
213 | 216 |
if (resource == null || resource.isEmpty()) { throw new ISLookUpDocumentNotFoundException(PROFILE_NOT_FOUND); } |
Also available in: Unified diff
integrated hack to cope with https://issue.openaire.research-infrastructures.eu/issues/2774