1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 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
|
package eu.etaxonomy.cdm.remote.dto.assembler.converter;
|
11
|
|
12
|
import net.sf.dozer.util.mapping.MappingException;
|
13
|
import net.sf.dozer.util.mapping.converters.CustomConverter;
|
14
|
import eu.etaxonomy.cdm.model.common.LSID;
|
15
|
|
16
|
public class LsidProxyConverter implements CustomConverter {
|
17
|
|
18
|
private String lsidProxyServiceUrl;
|
19
|
|
20
|
private String authorityPart;
|
21
|
|
22
|
public void setLsidProxyServiceUrl(String lsidProxyServiceUrl) {
|
23
|
this.lsidProxyServiceUrl = lsidProxyServiceUrl;
|
24
|
}
|
25
|
|
26
|
public void setAuthorityPart(String authorityPart) {
|
27
|
this.authorityPart = authorityPart;
|
28
|
}
|
29
|
|
30
|
public Object convert(Object destination, Object source, Class destClass, Class sourceClass) {
|
31
|
if (source == null || ((LSID)source).toString() == null || ((LSID)source).toString().equals("")) {
|
32
|
return null;
|
33
|
}
|
34
|
String dest = null;
|
35
|
if (source instanceof LSID) {
|
36
|
if(((LSID)source).getAuthority().equals(this.authorityPart)) {
|
37
|
dest = this.lsidProxyServiceUrl + ((LSID)source).getLsid();
|
38
|
}
|
39
|
return dest;
|
40
|
} else {
|
41
|
throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
|
42
|
+ destination + " and " + source);
|
43
|
}
|
44
|
}
|
45
|
|
46
|
}
|