2 package eu
.etaxonomy
.cdm
.remote
.view
;
4 import java
.util
.HashMap
;
7 import javax
.servlet
.http
.HttpServletRequest
;
8 import javax
.servlet
.http
.HttpServletResponse
;
9 import javax
.xml
.transform
.stream
.StreamResult
;
11 import net
.sf
.dozer
.util
.mapping
.MapperIF
;
13 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
14 import org
.springframework
.oxm
.Marshaller
;
15 import org
.springframework
.web
.servlet
.view
.AbstractView
;
17 import com
.ibm
.lsid
.MetadataResponse
;
18 import com
.ibm
.lsid
.http
.HTTPConstants
;
20 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.cdm
.remote
.dto
.tdwg
.BaseThing
;
23 import eu
.etaxonomy
.cdm
.remote
.dto
.tdwg
.voc
.TaxonConcept
;
24 import eu
.etaxonomy
.remote
.dto
.rdf
.Rdf
;
27 * View class which takes a MetadataResponse and returns the Source for serialization
29 * @see javax.xml.transform.Source
30 * @see com.ibm.lsid.MetadataResponse
32 public class RdfView
extends AbstractView
{
34 private Marshaller marshaller
;
36 private MapperIF mapper
;
38 private Map
<Class
<?
extends CdmBase
>,Class
<?
extends BaseThing
>> classMap
= new HashMap
<Class
<?
extends CdmBase
>,Class
<?
extends BaseThing
>>();
41 classMap
.put(Taxon
.class, TaxonConcept
.class);
45 public void setMarshaller(Marshaller marshaller
) {
46 this.marshaller
= marshaller
;
50 public void setMapper(MapperIF mapper
) {
55 protected void renderMergedOutputModel(Map model
,HttpServletRequest request
, HttpServletResponse response
)
57 MetadataResponse metadataResponse
= (MetadataResponse
)model
.get("metadataResponse");
58 if(metadataResponse
.getExpires() != null) {
59 response
.setHeader(HTTPConstants
.EXPIRES_HEADER
, HTTPConstants
.HTTP_DATE_FORMAT
.format(metadataResponse
.getExpires()));
62 CdmBase object
= (CdmBase
)metadataResponse
.getValue();
63 Class clazz
= classMap
.get(object
.getClass());
65 rdf
.addThing((BaseThing
)mapper
.map(object
, clazz
));
66 marshaller
.marshal(rdf
, new StreamResult(response
.getOutputStream()));