Project

General

Profile

« Previous | Next » 

Revision 02a7041f

Added by Andreas Kohlbecker about 14 years ago

fixing problem with content negotiation in views & oai-pmh controller for references

View differences:

.gitattributes
2501 2501
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/interceptor/ContentNegociationHandlerInterceptor.java -text
2502 2502
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/interceptor/DatasourceContextHandlerInterceptor.java -text
2503 2503
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/interceptor/LocaleContextHandlerInterceptor.java -text
2504
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/oaipmh/ReferenceOaiPmhController.java -text
2504 2505
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/oaipmh/TaxonOaiPmhController.java -text
2505 2506
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/TagEnum.java -text
2506 2507
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/TaggedText.java -text
......
2514 2515
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/assembler/converter/PreferLsidToUriConverter.java -text
2515 2516
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/assembler/converter/RemoveHTMLReader.java -text
2516 2517
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/assembler/converter/StripTagsConverter.java -text
2518
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/assembler/converter/TimePeriodConverter.java -text
2517 2519
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/dc/Relation.java -text
2518 2520
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/oaipmh/About.java -text
2519 2521
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/oaipmh/DeletedRecord.java -text
......
2655 2657
cdmlib-remote/src/main/webapp/WEB-INF/datasources/example.cdmlibrary/use-B-set.sh -text
2656 2658
cdmlib-remote/src/main/webapp/WEB-INF/datasources/p6spy.xml -text
2657 2659
cdmlib-remote/src/main/webapp/WEB-INF/datasources/routing-datasource.xml -text
2660
cdmlib-remote/src/main/webapp/WEB-INF/json-views.xml -text
2658 2661
cdmlib-remote/src/main/webapp/WEB-INF/jsonConfigurations.xml -text
2662
cdmlib-remote/src/main/webapp/WEB-INF/oai-views.xml -text
2659 2663
cdmlib-remote/src/main/webapp/WEB-INF/views.xml -text
2660 2664
cdmlib-remote/src/main/webapp/WEB-INF/web.xml -text
2665
cdmlib-remote/src/main/webapp/WEB-INF/xml-views.xml -text
2661 2666
cdmlib-remote/src/main/webapp/human.xsl -text
2662 2667
cdmlib-remote/src/main/webapp/oai2.xsl -text
2663 2668
cdmlib-remote/src/site/site.xml -text
.gitignore
25 25
app-import/src/main/resources/arecaceae_short.rdf
26 26
app-import/src/main/resources/tmp
27 27
app-import/target
28
cdm-server/.classpath
29
cdm-server/.project
30
cdm-server/target
28 31
cdmlib-commons/.classpath
29 32
cdmlib-commons/.project
30 33
cdmlib-commons/.settings
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/AbstractOaiPmhController.java
181 181
 
182 182
        ModelAndView modelAndView = new ModelAndView("oai/listMetadataFormats");
183 183
        
184
        T object = service.find(UUID.fromString("c34eb662-6bba-4ad7-b84e-dd98f2fd9788"));
185
        if(false && identifier != null) {
186
        	object = service.find(identifier);
184
        if(identifier != null) {
185
        	T  object = service.find(identifier);
187 186
	        if(object == null) {
188 187
		        throw new IdDoesNotExistException(identifier);
189 188
	        }
......
247 246
        }
248 247
        
249 248
        List<AuditCriterion> criteria = new ArrayList<AuditCriterion>();
250
        criteria.add(AuditEntity.property("lsid_lsid").isNotNull());
251
        Pager<AuditEventRecord<T>> results = service.pageAuditEvents(clazz,fromAuditEvent,untilAuditEvent,criteria, pageSize, 0, AuditEventSort.FORWARDS,null); 
249
        //criteria.add(AuditEntity.property("lsid_lsid").isNotNull()); 
250
        //TODO this isNotNull criterion did not work with mysql, so using a like statement as interim solution
251
        criteria.add(AuditEntity.property("lsid_lsid").like("urn:lsid:%"));
252
        Pager<AuditEventRecord<T>> results = service.pageAuditEvents(clazz, fromAuditEvent, untilAuditEvent, criteria, pageSize, 0, AuditEventSort.FORWARDS, null); 
252 253
        
253 254
        if(results.getCount() == 0) {
254 255
        	throw new NoRecordsMatchException("No records match");
......
292 293
            }
293 294
            
294 295
            List<AuditCriterion> criteria = new ArrayList<AuditCriterion>();
295
            criteria.add(AuditEntity.property("lsid_lsid").isNotNull());
296
            //criteria.add(AuditEntity.property("lsid_lsid").isNotNull()); 
297
            //TODO this isNotNull criterion did not work with mysql, so using a like statement as interim solution
298
            criteria.add(AuditEntity.property("lsid_lsid").like("urn:lsid:%"));
296 299
            Pager<AuditEventRecord<T>> results = service.pageAuditEvents(clazz,fromAuditEvent,untilAuditEvent,criteria, pageSize, (resumptionToken.getCursor().intValue() / pageSize) + 1, AuditEventSort.FORWARDS,null); 
297 300
        
298 301
            if(results.getCount() == 0) {
......
318 321
    }
319 322

  
320 323
    @RequestMapping(method = RequestMethod.GET, params = {"verb=ListRecords", "!resumptionToken"})
321
    public ModelAndView listRecords(@RequestParam(value = "from", required = false) DateTime from, @RequestParam(value = "until", required = false) DateTime until,@RequestParam(value = "metadataPrefix", required = true) MetadataPrefix metadataPrefix, @RequestParam(value = "set", required = false) SetSpec set) {
324
    public ModelAndView listRecords(@RequestParam(value = "from", required = false) DateTime from, 
325
    		@RequestParam(value = "until", required = false) DateTime until,
326
    		@RequestParam(value = "metadataPrefix", required = true) MetadataPrefix metadataPrefix, 
327
    		@RequestParam(value = "set", required = false) SetSpec set) {
322 328
 
323 329
        ModelAndView modelAndView = new ModelAndView();
324 330
        modelAndView.addObject("metadataPrefix",metadataPrefix);
......
351 357
        }
352 358
        
353 359
        List<AuditCriterion> criteria = new ArrayList<AuditCriterion>();
354
        criteria.add(AuditEntity.property("lsid_lsid").isNotNull());
355
        Pager<AuditEventRecord<T>> results = service.pageAuditEvents(clazz,fromAuditEvent,untilAuditEvent,criteria, pageSize, 0, AuditEventSort.FORWARDS,getPropertyPaths()); 
360
        //criteria.add(AuditEntity.property("lsid_lsid").isNotNull()); 
361
        //TODO this isNotNull criterion did not work with mysql, so using a like statement as interim solution
362
        criteria.add(AuditEntity.property("lsid_lsid").like("urn:lsid:%"));
363
        Pager<AuditEventRecord<T>> results = service.pageAuditEvents(clazz, fromAuditEvent, untilAuditEvent, criteria, pageSize, 0, AuditEventSort.FORWARDS, getPropertyPaths()); 
356 364
        
357 365
        if(results.getCount() == 0) {
358 366
        	throw new NoRecordsMatchException("No records match");
......
363 371
        if(results.getCount() > results.getRecords().size() && cacheProviderFacade != null) {
364 372
	        ResumptionToken resumptionToken = new ResumptionToken(results, from, until, metadataPrefix, set);
365 373
            modelAndView.addObject("resumptionToken",resumptionToken);
366
            cacheProviderFacade.putInCache(resumptionToken.getValue(),cachingModel,resumptionToken);
374
            cacheProviderFacade.putInCache(resumptionToken.getValue(), cachingModel, resumptionToken);
367 375
        }
368 376

  
369 377
        return modelAndView;
......
405 413
              clazz = (Class)resumptionToken.getSet().getSetClass();
406 414
            }
407 415
            List<AuditCriterion> criteria = new ArrayList<AuditCriterion>();
408
            criteria.add(AuditEntity.property("lsid_lsid").isNotNull());
416
            //criteria.add(AuditEntity.property("lsid_lsid").isNotNull()); 
417
            //TODO this isNotNull criterion did not work with mysql, so using a like statement as interim solution
418
            criteria.add(AuditEntity.property("lsid_lsid").like("urn:lsid:%"));
409 419
            Pager<AuditEventRecord<T>> results = service.pageAuditEvents(clazz,fromAuditEvent,untilAuditEvent,criteria, pageSize, (resumptionToken.getCursor().intValue()  / pageSize) + 1, AuditEventSort.FORWARDS,getPropertyPaths()); 
410 420
        
411 421
            if(results.getCount() == 0) {
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/oaipmh/ReferenceOaiPmhController.java
1
package eu.etaxonomy.cdm.remote.controller.oaipmh;
2

  
3
import java.util.ArrayList;
4
import java.util.Arrays;
5
import java.util.HashSet;
6
import java.util.List;
7
import java.util.Set;
8

  
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.stereotype.Controller;
11
import org.springframework.web.bind.annotation.RequestMapping;
12
import org.springframework.web.servlet.ModelAndView;
13

  
14
import eu.etaxonomy.cdm.api.service.IReferenceService;
15
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
16
import eu.etaxonomy.cdm.remote.controller.AbstractOaiPmhController;
17
import eu.etaxonomy.cdm.remote.dto.oaipmh.SetSpec;
18

  
19
@Controller
20
@RequestMapping(value = "/reference/oai", params = "verb")
21
public class ReferenceOaiPmhController extends AbstractOaiPmhController<ReferenceBase, IReferenceService> {
22

  
23
	@Override
24
	protected List<String> getPropertyPaths() {
25
		return Arrays.asList(new String []{
26
				"$",
27
				"inBook.authorTeam",
28
				"inJournal",
29
				"inProceedings",
30
		});
31
	}
32

  
33
    @Override
34
    protected void addSets(ModelAndView modelAndView) {
35
    	Set<SetSpec> sets = new HashSet<SetSpec>();
36
    	sets.add(SetSpec.REFERENCE);
37
    	modelAndView.addObject("sets",sets);
38
    }
39
	
40
    @Override
41
    @Autowired
42
	public void setService(IReferenceService service) {
43
		this.service = service;
44
	}
45
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/assembler/converter/TimePeriodConverter.java
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

  
15
import org.joda.time.DateTime;
16

  
17
import eu.etaxonomy.cdm.model.common.TimePeriod;
18

  
19
public class TimePeriodConverter implements CustomConverter {
20

  
21
	/* (non-Javadoc)
22
	 * @see net.sf.dozer.util.mapping.converters.CustomConverter#convert(java.lang.Object, java.lang.Object, java.lang.Class, java.lang.Class)
23
	 */
24
	public Object convert(Object destination, Object source, Class destClass, Class sourceClass) {
25
		if (source == null) {
26
			return null;
27
		}
28
		if (source instanceof TimePeriod) {	   
29
			
30
			//convert from TimePeriod -> DateTime
31
			//FIXME .toDateTime(null) most probably not correct
32
			return ((TimePeriod)source).getStart().toDateTime(null); 
33
			
34
		} else if (source instanceof DateTime) {
35
			
36
			//convert from DateTime -> TimePeriod
37
			//FIXME implement
38
			return null; 
39
			
40
		} else {
41
			
42
			throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
43
					+ destination + " and " + source);
44
		}
45
	}
46

  
47
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/oaipmh/SetSpec.java
8 8
import eu.etaxonomy.cdm.model.agent.Team;
9 9
import eu.etaxonomy.cdm.model.agent.Institution;
10 10
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
11
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
11 12
import eu.etaxonomy.cdm.model.taxon.Taxon;
12 13
import eu.etaxonomy.cdm.model.taxon.Synonym;
13 14
import eu.etaxonomy.cdm.model.name.BacterialName;
......
36 37
	VIRAL_NAME("viralName","Scientific Names governed by the ICTV",ViralName.class,null),
37 38
	TAXON_DESCRIPTION("taxonDescription","Descriptions of taxonomic concepts",TaxonDescription.class,null),
38 39
	TAXON_NAME_DESCRIPTION("taxonNameDescription","Descriptions of scientific names",TaxonNameDescription.class,null),
39
	SPECIMEN_DESCRIPTION("specimenDescription","Descriptions of specimens and occurrences",SpecimenDescription.class,null);
40
	SPECIMEN_DESCRIPTION("specimenDescription","Descriptions of specimens and occurrences",SpecimenDescription.class,null),
41
	REFERENCE("reference","Any kind of Reference",ReferenceBase.class,null);
40 42

  
41 43
	private String spec;
42 44
	private String name;
......
65 67
    public String getSpec() {
66 68
    	return spec;
67 69
    }
70
    
71
    public static SetSpec bySpec(String spec){
72
    	for(SetSpec setSpec : SetSpec.values()) {
73
			if(setSpec.getSpec().equals(spec)) {
74
				return setSpec;
75
			}
76
		}
77
    	return null;
78
    }
68 79
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/editor/SetSpecEditor.java
10 10
		if(text == null) {
11 11
			throw new IllegalArgumentException("null is not an acceptable set spec");
12 12
		} else {
13
			boolean matched = false;
14
			for(SetSpec setSpec : SetSpec.values()) {
15
				if(setSpec.name().equals(text)) {
16
					setValue(setSpec);
17
					break;
18
				}
19
			}
20
			if(!matched) {
21
			    throw new IllegalArgumentException(text + " is not an acceptable set spec");
13
			SetSpec setSpec = SetSpec.bySpec(text);
14
			if(setSpec != null){
15
				setValue(setSpec);
16
			} else {				
17
				throw new IllegalArgumentException(text + " is not an acceptable set spec");
22 18
			}
23 19
		}
24 20
	}
......
27 23
		if(getValue() == null) {
28 24
			return null;
29 25
		} else {
30
		    return ((SetSpec)getValue()).name();
26
		    return ((SetSpec)getValue()).getSpec();
31 27
		}
32 28
	}
33 29
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/CalendarJSONValueProcessor.java
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

  
11
package eu.etaxonomy.cdm.remote.json.processor;
12

  
13
import java.text.DateFormat;
14
import java.text.SimpleDateFormat;
15
import java.util.Calendar;
16

  
17
import net.sf.json.JsonConfig;
18
import net.sf.json.processors.JsonValueProcessor;
19

  
20
import org.apache.log4j.Logger;
21

  
22

  
23
/**
24
 * @author a.kohlbecker
25
 * @created 20.01.2009
26
 * @version 1.0
27
 */
28
public class CalendarJSONValueProcessor implements JsonValueProcessor {
29
	private static Logger logger = Logger.getLogger(DateTimeJSONValueProcessor.class);
30

  
31
	private static SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
32
	
33
	/* (non-Javadoc)
34
	 * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
35
	 */
36
	public Object processArrayValue(Object object, JsonConfig jsonConfig) {
37
		if(object == null){
38
			return "";
39
		}
40
		Calendar calendar = (Calendar) object;
41
		if (logger.isDebugEnabled()) {
42
			logger.debug("processArrayValue of java.util.Calendar: " + CalendarJSONValueProcessor.iso8601Format.format(calendar.getTime()));
43
		}
44
        return CalendarJSONValueProcessor.iso8601Format.format(calendar.getTime());
45
	}
46

  
47
	/* (non-Javadoc)
48
	 * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
49
	 */
50
	public Object processObjectValue(String key, Object object, JsonConfig jsonConfig) {
51
		if(object == null){
52
			return "";
53
		}
54
		Calendar dateTime = (Calendar) object;
55
		if (logger.isDebugEnabled()) {
56
			logger.debug("processObjectValue of java.util.Calendar: " + CalendarJSONValueProcessor.iso8601Format.format(dateTime.getTime()));
57
		}
58
        return CalendarJSONValueProcessor.iso8601Format.format(dateTime.getTime());
59
	}
60
}
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

  
11
package eu.etaxonomy.cdm.remote.json.processor;
12

  
13
import java.text.DateFormat;
14
import java.text.SimpleDateFormat;
15
import java.util.Calendar;
16

  
17
import net.sf.json.JsonConfig;
18
import net.sf.json.processors.JsonValueProcessor;
19

  
20
import org.apache.log4j.Logger;
21

  
22

  
23
/**
24
 * @author a.kohlbecker
25
 * @created 20.01.2009
26
 * @version 1.0
27
 */
28
public class CalendarJSONValueProcessor implements JsonValueProcessor {
29
	private static Logger logger = Logger.getLogger(DateTimeJSONValueProcessor.class);
30

  
31
	private static SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
32
	
33
	/* (non-Javadoc)
34
	 * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
35
	 */
36
	public Object processArrayValue(Object object, JsonConfig jsonConfig) {
37
		if(object == null){
38
			return "";
39
		}
40
		Calendar calendar = (Calendar) object;
41
		if (logger.isDebugEnabled()) {
42
			logger.debug("processArrayValue of java.util.Calendar: " + CalendarJSONValueProcessor.iso8601Format.format(calendar.getTime()));
43
		}
44
        return CalendarJSONValueProcessor.iso8601Format.format(calendar.getTime());
45
	}
46

  
47
	/* (non-Javadoc)
48
	 * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
49
	 */
50
	public Object processObjectValue(String key, Object object, JsonConfig jsonConfig) {
51
		if(object == null){
52
			return "";
53
		}
54
		Calendar dateTime = (Calendar) object;
55
		if (logger.isDebugEnabled()) {
56
			logger.debug("processObjectValue of java.util.Calendar: " + CalendarJSONValueProcessor.iso8601Format.format(dateTime.getTime()));
57
		}
58
        return CalendarJSONValueProcessor.iso8601Format.format(dateTime.getTime());
59
	}
60
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/DateTimeJSONValueProcessor.java
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

  
11
package eu.etaxonomy.cdm.remote.json.processor;
12

  
13
import net.sf.json.JsonConfig;
14
import net.sf.json.processors.JsonValueProcessor;
15

  
16
import org.apache.log4j.Logger;
17
import org.joda.time.DateTime;
18
import org.joda.time.format.DateTimeFormatter;
19
import org.joda.time.format.ISODateTimeFormat;
20

  
21
/**
22
 * @author n.hoffmann
23
 * @created 24.07.2008
24
 * @version 1.0
25
 */
26
public class DateTimeJSONValueProcessor implements JsonValueProcessor {
27
	private static Logger logger = Logger
28
			.getLogger(DateTimeJSONValueProcessor.class);
29

  
30
	private static DateTimeFormatter iso8601Format = ISODateTimeFormat.dateTime();
31
	
32
	/* (non-Javadoc)
33
	 * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
34
	 */
35
	public Object processArrayValue(Object object, JsonConfig jsonConfig) {
36
		DateTime dateTime = (DateTime) object;
37
        return DateTimeJSONValueProcessor.iso8601Format.print(dateTime);
38
	}
39

  
40
	/* (non-Javadoc)
41
	 * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
42
	 */
43
	public Object processObjectValue(String key, Object object,
44
			JsonConfig jsonConfig) {
45
		DateTime dateTime = (DateTime) object;
46
        return DateTimeJSONValueProcessor.iso8601Format.print(dateTime);
47
	}
48
}
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

  
11
package eu.etaxonomy.cdm.remote.json.processor;
12

  
13
import net.sf.json.JsonConfig;
14
import net.sf.json.processors.JsonValueProcessor;
15

  
16
import org.apache.log4j.Logger;
17
import org.joda.time.DateTime;
18
import org.joda.time.format.DateTimeFormatter;
19
import org.joda.time.format.ISODateTimeFormat;
20

  
21
/**
22
 * @author n.hoffmann
23
 * @created 24.07.2008
24
 * @version 1.0
25
 */
26
public class DateTimeJSONValueProcessor implements JsonValueProcessor {
27
	private static Logger logger = Logger
28
			.getLogger(DateTimeJSONValueProcessor.class);
29

  
30
	private static DateTimeFormatter iso8601Format = ISODateTimeFormat.dateTime();
31
	
32
	/* (non-Javadoc)
33
	 * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
34
	 */
35
	public Object processArrayValue(Object object, JsonConfig jsonConfig) {
36
		DateTime dateTime = (DateTime) object;
37
        return DateTimeJSONValueProcessor.iso8601Format.print(dateTime);
38
	}
39

  
40
	/* (non-Javadoc)
41
	 * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
42
	 */
43
	public Object processObjectValue(String key, Object object,
44
			JsonConfig jsonConfig) {
45
		DateTime dateTime = (DateTime) object;
46
        return DateTimeJSONValueProcessor.iso8601Format.print(dateTime);
47
	}
48
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/PartialJSONValueProcessor.java
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

  
11
package eu.etaxonomy.cdm.remote.json.processor;
12

  
13
import net.sf.json.JsonConfig;
14
import net.sf.json.processors.JsonValueProcessor;
15

  
16
import org.apache.log4j.Logger;
17
import org.joda.time.Partial;
18
import org.joda.time.format.ISODateTimeFormat;
19

  
20
import eu.etaxonomy.cdm.model.common.PartialUserType;
21

  
22
/**
23
 * Partial time as four digit year, two digit month of year, and two digit day of month (yyyy-MM-dd).
24
 * @author a.kohlbecker
25
 * @created 20.01.2008
26
 * @version 1.0
27
 */
28
public class PartialJSONValueProcessor implements JsonValueProcessor {
29
	private static Logger logger = Logger.getLogger(PartialJSONValueProcessor.class);
30

  
31
	
32
	/* (non-Javadoc)
33
	 * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
34
	 */
35
	public Object processArrayValue(Object object, JsonConfig jsonConfig) {
36
		if(object == null){
37
			return "";
38
		}
39
		Partial partial = (Partial) object;
40
		if (logger.isDebugEnabled()) {
41
			logger.debug("processArrayValue of joda.time.DateTime: " + PartialUserType.partialToString(partial));
42
		}
43
        return partial.toString(ISODateTimeFormat.date());
44
	}
45

  
46
	/* (non-Javadoc)
47
	 * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
48
	 */
49
	public Object processObjectValue(String key, Object object, JsonConfig jsonConfig) {
50
		if(object == null){
51
			return "";
52
		}
53
		Partial partial = (Partial) object;
54
		if (logger.isDebugEnabled()) {
55
			logger.debug("processObjectValue of joda.time.DateTime: " + PartialUserType.partialToString(partial));
56
		}
57
		return partial.toString(ISODateTimeFormat.date());
58
	}
59
}
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

  
11
package eu.etaxonomy.cdm.remote.json.processor;
12

  
13
import net.sf.json.JsonConfig;
14
import net.sf.json.processors.JsonValueProcessor;
15

  
16
import org.apache.log4j.Logger;
17
import org.joda.time.Partial;
18
import org.joda.time.format.ISODateTimeFormat;
19

  
20
import eu.etaxonomy.cdm.model.common.PartialUserType;
21

  
22
/**
23
 * Partial time as four digit year, two digit month of year, and two digit day of month (yyyy-MM-dd).
24
 * @author a.kohlbecker
25
 * @created 20.01.2008
26
 * @version 1.0
27
 */
28
public class PartialJSONValueProcessor implements JsonValueProcessor {
29
	private static Logger logger = Logger.getLogger(PartialJSONValueProcessor.class);
30

  
31
	
32
	/* (non-Javadoc)
33
	 * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
34
	 */
35
	public Object processArrayValue(Object object, JsonConfig jsonConfig) {
36
		if(object == null){
37
			return "";
38
		}
39
		Partial partial = (Partial) object;
40
		if (logger.isDebugEnabled()) {
41
			logger.debug("processArrayValue of joda.time.DateTime: " + PartialUserType.partialToString(partial));
42
		}
43
        return partial.toString(ISODateTimeFormat.date());
44
	}
45

  
46
	/* (non-Javadoc)
47
	 * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
48
	 */
49
	public Object processObjectValue(String key, Object object, JsonConfig jsonConfig) {
50
		if(object == null){
51
			return "";
52
		}
53
		Partial partial = (Partial) object;
54
		if (logger.isDebugEnabled()) {
55
			logger.debug("processObjectValue of joda.time.DateTime: " + PartialUserType.partialToString(partial));
56
		}
57
		return partial.toString(ISODateTimeFormat.date());
58
	}
59
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/TaxonNodeBeanProcessor.java
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

  
11
package eu.etaxonomy.cdm.remote.json.processor;
12

  
13
import java.util.Arrays;
14
import java.util.List;
15

  
16
import net.sf.json.JSONObject;
17
import net.sf.json.JsonConfig;
18

  
19
import org.apache.log4j.Logger;
20

  
21
import eu.etaxonomy.cdm.model.common.CdmBase;
22

  
23
/**
24
 * @author n.hoffmann
25
 * @created Apr 9, 2010
26
 * @version 1.0
27
 */
28
public class TaxonNodeBeanProcessor extends AbstractCdmBeanProcessor {
29
	private static final Logger logger = Logger
30
			.getLogger(TaxonNodeBeanProcessor.class);
31

  
32
	/* (non-Javadoc)
33
	 * @see eu.etaxonomy.cdm.remote.json.processor.AbstractCdmBeanProcessor#getIgnorePropNames()
34
	 */
35
	@Override
36
	public List getIgnorePropNames() {
37
		return Arrays.asList(new String[]{
38
				"parent", //TODO put in json-config ignore list ?
39
		});
40
	}
41

  
42
	/* (non-Javadoc)
43
	 * @see eu.etaxonomy.cdm.remote.json.processor.AbstractCdmBeanProcessor#processBeanSecondStep(eu.etaxonomy.cdm.model.common.CdmBase, net.sf.json.JSONObject, net.sf.json.JsonConfig)
44
	 */
45
	@Override
46
	public JSONObject processBeanSecondStep(CdmBase bean, JSONObject json,
47
			JsonConfig jsonConfig) {
48
		return json;
49
	}
50
}
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

  
11
package eu.etaxonomy.cdm.remote.json.processor;
12

  
13
import java.util.Arrays;
14
import java.util.List;
15

  
16
import net.sf.json.JSONObject;
17
import net.sf.json.JsonConfig;
18

  
19
import org.apache.log4j.Logger;
20

  
21
import eu.etaxonomy.cdm.model.common.CdmBase;
22

  
23
/**
24
 * @author n.hoffmann
25
 * @created Apr 9, 2010
26
 * @version 1.0
27
 */
28
public class TaxonNodeBeanProcessor extends AbstractCdmBeanProcessor {
29
	private static final Logger logger = Logger
30
			.getLogger(TaxonNodeBeanProcessor.class);
31

  
32
	/* (non-Javadoc)
33
	 * @see eu.etaxonomy.cdm.remote.json.processor.AbstractCdmBeanProcessor#getIgnorePropNames()
34
	 */
35
	@Override
36
	public List getIgnorePropNames() {
37
		return Arrays.asList(new String[]{
38
				"parent", //TODO put in json-config ignore list ?
39
		});
40
	}
41

  
42
	/* (non-Javadoc)
43
	 * @see eu.etaxonomy.cdm.remote.json.processor.AbstractCdmBeanProcessor#processBeanSecondStep(eu.etaxonomy.cdm.model.common.CdmBase, net.sf.json.JSONObject, net.sf.json.JsonConfig)
44
	 */
45
	@Override
46
	public JSONObject processBeanSecondStep(CdmBase bean, JSONObject json,
47
			JsonConfig jsonConfig) {
48
		return json;
49
	}
50
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/view/JsonView.java
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.view;
11

  
12
import java.io.PrintWriter;
13
import java.util.Collection;
14
import java.util.Map;
15

  
16
import javax.servlet.http.HttpServletRequest;
17
import javax.servlet.http.HttpServletResponse;
18

  
19
import net.sf.json.JSON;
20
import net.sf.json.JSONArray;
21
import net.sf.json.JSONObject;
22
import net.sf.json.JsonConfig;
23
import net.sf.json.xml.XMLSerializer;
24

  
25
import org.apache.log4j.Logger;
26
import org.springframework.web.servlet.View;
27

  
28

  
29
public class JsonView extends BaseView implements View{
30
	
31
	/**
32
	 * 
33
	 */
34
	private static final String CONTENTTYPE_JSON = "application/json";
35
	
36
	private static final String CONTENTTYPE_XML = "text/xml";
37

  
38
	public static final Logger logger = Logger.getLogger(JsonView.class);
39

  
40
	private JsonConfig jsonConfig;
41
	
42
	public enum Type{
43
		JSON, XML
44
	}
45

  
46
	private Type type = Type.JSON;
47

  
48
	private String xsl;
49
	
50
	public void setXsl(String xsl) {
51
		this.xsl = xsl;
52
	}
53

  
54
	public Type getType() {
55
		return type;
56
	}
57

  
58
	/**
59
	 * Default is Type.JSON
60
	 * @param type
61
	 */
62
	public void setType(Type type) {
63
		this.type = type;
64
	}
65

  
66
	public void setJsonConfig(JsonConfig jsonConfig) {
67
			this.jsonConfig = jsonConfig;
68
	}
69

  
70
	public String getContentType() {
71
		return "application/json";
72
	}
73
	
74
	
75
	public void render(Map model, HttpServletRequest req, HttpServletResponse resp) throws Exception {
76
		
77
		// Retrieve data from model
78
		Object entity = getResponseData(model);
79
		
80
		// set content type 
81
		resp.setContentType(getContentType());
82
		
83
		// prepare writer
84
		// TODO determine preferred charset from HTTP Accept-Charset header
85
		//Writer out = new BufferedWriter(new OutputStreamWriter(resp.getOutputStream(),  "UTF-8"));
86
		PrintWriter out =  resp.getWriter();
87
		// create JSON Object
88
		boolean isCollectionType = false;
89
		JSON jsonObj;
90
		if (entity == null){
91
		  jsonObj = JSONObject.fromObject("{}");
92
		} else if(Collection.class.isAssignableFrom(entity.getClass())){
93
			isCollectionType = true;
94
			jsonObj = JSONArray.fromObject(entity, jsonConfig);
95
		}else if(entity instanceof String){
96
			jsonObj = JSONObject.fromObject("{\"String\":\""+entity+"\"}");
97
		} else if(entity instanceof Integer){
98
			jsonObj = JSONObject.fromObject("{\"Integer\":\""+((Integer)entity).intValue()+"\"}");
99
		} else {
100
			jsonObj = JSONObject.fromObject(entity, jsonConfig);
101
		}
102
		
103
		if(type.equals(Type.XML)){
104
			XMLSerializer xmlSerializer = new XMLSerializer();
105
			if(isCollectionType){
106
				xmlSerializer.setArrayName(entity.getClass().getSimpleName());
107
				Class elementType = Object.class;
108
				Collection c = (Collection)entity;
109
				if(c.size() > 0){
110
					elementType = c.iterator().next().getClass();
111
				}
112
				xmlSerializer.setObjectName(elementType.getSimpleName());
113
			} else if(entity != null){
114
				xmlSerializer.setObjectName(entity.getClass().getSimpleName());
115
			}
116
			String xml = xmlSerializer.write( jsonObj );
117
			if(xsl != null){
118
				String xslInclude = "\r\n<?xml-stylesheet type=\"text/xsl\" href=\"human.xsl\"?>\r\n";
119
				xml = xml.replaceFirst("\r\n", xslInclude);
120
			}
121
			resp.setContentType(CONTENTTYPE_XML);
122
			out.append(xml);
123
		} else {
124
			// assuming json
125
			resp.setContentType(CONTENTTYPE_JSON);
126
			out.append(jsonObj.toString());
127
		}
128
		out.flush();
129
	}
130
}
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.view;
11

  
12
import java.io.PrintWriter;
13
import java.util.Collection;
14
import java.util.Map;
15

  
16
import javax.servlet.http.HttpServletRequest;
17
import javax.servlet.http.HttpServletResponse;
18

  
19
import net.sf.json.JSON;
20
import net.sf.json.JSONArray;
21
import net.sf.json.JSONObject;
22
import net.sf.json.JsonConfig;
23
import net.sf.json.xml.XMLSerializer;
24

  
25
import org.apache.log4j.Logger;
26
import org.springframework.web.servlet.View;
27

  
28

  
29
public class JsonView extends BaseView implements View{
30
	
31
	/**
32
	 * 
33
	 */
34
	private static final String CONTENTTYPE_JSON = "application/json";
35
	
36
	private static final String CONTENTTYPE_XML = "text/xml";
37

  
38
	public static final Logger logger = Logger.getLogger(JsonView.class);
39

  
40
	private JsonConfig jsonConfig;
41
	
42
	public enum Type{
43
		JSON, XML;
44
		
45
		public String toString(){
46
			if(this.equals(XML)){
47
				return "application/xml";
48
			}
49
			return "application/json";
50
			
51
		}
52
	}
53

  
54
	private Type type = Type.JSON;
55

  
56
	private String xsl;
57
	
58
	public void setXsl(String xsl) {
59
		this.xsl = xsl;
60
	}
61

  
62
	public Type getType() {
63
		return type;
64
	}
65

  
66
	/**
67
	 * Default is Type.JSON
68
	 * @param type
69
	 */
70
	public void setType(Type type) {
71
		this.type = type;
72
	}
73

  
74
	public void setJsonConfig(JsonConfig jsonConfig) {
75
			this.jsonConfig = jsonConfig;
76
	}
77

  
78
	public String getContentType() {
79
		return type.toString();
80
	}
81
	
82
	
83
	public void render(Map model, HttpServletRequest req, HttpServletResponse resp) throws Exception {
84
		
85
		// Retrieve data from model
86
		Object entity = getResponseData(model);
87
		
88
		// set content type 
89
		resp.setContentType(getContentType());
90
		
91
		// prepare writer
92
		// TODO determine preferred charset from HTTP Accept-Charset header
93
		//Writer out = new BufferedWriter(new OutputStreamWriter(resp.getOutputStream(),  "UTF-8"));
94
		PrintWriter out =  resp.getWriter();
95
		// create JSON Object
96
		boolean isCollectionType = false;
97
		JSON jsonObj;
98
		if (entity == null){
99
		  jsonObj = JSONObject.fromObject("{}");
100
		} else if(Collection.class.isAssignableFrom(entity.getClass())){
101
			isCollectionType = true;
102
			jsonObj = JSONArray.fromObject(entity, jsonConfig);
103
		}else if(entity instanceof String){
104
			jsonObj = JSONObject.fromObject("{\"String\":\""+entity+"\"}");
105
		} else if(entity instanceof Integer){
106
			jsonObj = JSONObject.fromObject("{\"Integer\":\""+((Integer)entity).intValue()+"\"}");
107
		} else {
108
			jsonObj = JSONObject.fromObject(entity, jsonConfig);
109
		}
110
		
111
		if(type.equals(Type.XML)){
112
			XMLSerializer xmlSerializer = new XMLSerializer();
113
			if(isCollectionType){
114
				xmlSerializer.setArrayName(entity.getClass().getSimpleName());
115
				Class elementType = Object.class;
116
				Collection c = (Collection)entity;
117
				if(c.size() > 0){
118
					elementType = c.iterator().next().getClass();
119
				}
120
				xmlSerializer.setObjectName(elementType.getSimpleName());
121
			} else if(entity != null){
122
				xmlSerializer.setObjectName(entity.getClass().getSimpleName());
123
			}
124
			String xml = xmlSerializer.write( jsonObj );
125
			if(xsl != null){
126
				String xslInclude = "\r\n<?xml-stylesheet type=\"text/xsl\" href=\"human.xsl\"?>\r\n";
127
				xml = xml.replaceFirst("\r\n", xslInclude);
128
			}
129
			resp.setContentType(CONTENTTYPE_XML);
130
			out.append(xml);
131
		} else {
132
			// assuming json
133
			resp.setContentType(CONTENTTYPE_JSON);
134
			out.append(jsonObj.toString());
135
		}
136
		out.flush();
137
	}
138
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/view/PatternViewResolver.java
25 25
import org.springframework.web.servlet.View;
26 26
import org.springframework.web.servlet.view.XmlViewResolver;
27 27

  
28
import com.sun.xml.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
29

  
30 28
/**
31 29
 * Resolves views by using a {@link PathMatcher} to match the view name to the bean names.
32 30
 * 
......
39 37
 *  </ul>
40 38
 * @author ben.clark
41 39
 */
42
@Component
43 40
public class PatternViewResolver extends XmlViewResolver {
41
	
44 42
	private final Set<String> viewSet = new HashSet<String>();
45 43
	
46 44
	private PathMatcher pathMatcher = new AntPathMatcher();
47 45
	
46
	
47
	
48 48
	public void setPathMatcher(PathMatcher pathMatcher) {
49 49
		Assert.notNull(pathMatcher, "PathMatcher must not be null");
50 50
		this.pathMatcher = pathMatcher;
cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote.xml
52 52
          </entry>
53 53
          <entry key="dateTimeConverter">
54 54
            <bean class="eu.etaxonomy.cdm.remote.dto.assembler.converter.DateTimeConverter"/>
55
          </entry>
56
           <entry key="timePeriodConverter">
57
            <bean class="eu.etaxonomy.cdm.remote.dto.assembler.converter.TimePeriodConverter"/>
55 58
          </entry>
56 59
          <entry key="hibernateProxyDeepConverter">
57 60
            <bean class="eu.etaxonomy.cdm.remote.dto.assembler.converter.HibernateProxyNullSafeDeepConverter"/>
cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote/dto/oaipmh/mappings.xml
31 31
            <a>lsid</a>
32 32
            <b>identifier</b>
33 33
        </field>
34
    </mapping>
35
    
36
    <mapping>
37
        <class-a>eu.etaxonomy.cdm.model.taxon.TaxonBase</class-a>
38
        <class-b map-null="false">eu.etaxonomy.cdm.remote.dto.oaipmh.OaiDc</class-b>
34 39
        <field>
35 40
            <a>created</a>
36 41
            <b>date</b>
......
46 51
        <field>
47 52
            <a>titleCache</a>
48 53
            <b>title</b>
54
       </field>
55
    </mapping>
56
    
57
    <mapping>
58
        <class-a>eu.etaxonomy.cdm.model.reference.ReferenceBase</class-a>
59
        <class-b map-null="false">eu.etaxonomy.cdm.remote.dto.oaipmh.OaiDc</class-b>
60
        <field custom-converter-id="timePeriodConverter">
61
            <a>datePublished</a>
62
            <b>date</b>
63
        </field>
64
        <field custom-converter-id="hibernateProxyDeepConverter" custom-converter-param="titleCache" >
65
            <a>authorTeam</a>
66
            <b>creator</b>
49 67
        </field>
68
        <field>
69
            <a>title</a>
70
            <b>title</b>
71
       </field>
50 72
    </mapping>
51 73
    
52 74
</mappings>
cdmlib-remote/src/main/resources/spy.properties
189 189
log4j.appender.SQLPROFILER_CLIENT.LocationInfo=true
190 190

  
191 191

  
192
#log4j.logger.p6spy=INFO,STDOUT
193
log4j.logger.p6spy=INFO, SQLPROFILER_CLIENT
192
log4j.logger.p6spy=INFO,STDOUT
193
#log4j.logger.p6spy=INFO, SQLPROFILER_CLIENT
194 194

  
195 195

  
196 196
#################################################################
cdmlib-remote/src/main/webapp/WEB-INF/applicationContext.views.xml
7 7
    http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-2.5.xsd
8 8
    http://www.springframework.org/schema/tx   http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
9 9
    ">
10
	
11
	<!-- 
12
		- Accepts a configuration file. 
13
		- The default configuration file is /WEB-INF/views.xml 
14
	-->
15
    <bean  name="viewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
16
 		<!-- FOR DEBUGING ONLY !!!!   
17
 		<property name="cache" value="false"/> 
18
 		 -->
19
    </bean>
20 10
    
21 11
    
22 12
    <import resource="jsonConfigurations.xml"/>
cdmlib-remote/src/main/webapp/WEB-INF/applicationContext.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
    xmlns:tx="http://www.springframework.org/schema/tx"
5
    xmlns:context="http://www.springframework.org/schema/context"
6
    xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7
    http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-2.5.xsd
8
    http://www.springframework.org/schema/tx   http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
9
    ">
10
	
11
	<!-- include default application context and customization -->
12
     <import resource="classpath:/eu/etaxonomy/cdm/defaultApplicationContext.xml"/>
13
     <bean id="persistentTermInitializer" class="eu.etaxonomy.cdm.database.PersistentTermInitializer">
14
     	<property name="omit" value="true" />
15
     </bean>
16
    <context:component-scan base-package="eu/etaxonomy/cdm/ext" />
17
    
18
    <import resource="classpath:/eu/etaxonomy/cdm/remote.xml"/>
19
    
20
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
21
		<property name="properties">
22
		  <props>
23
		      <prop key="eu.etaxonomy.cdm.base.path">${user.home}/.cdmLibrary/</prop>
24
		      <prop key="eu.etaxonomy.cdm.search.index.path">${user.home}/.cdmLibrary/index/</prop>
25
		      <prop key="eu.etaxonomy.cdm.ehcache.diskstore.path">${user.home}/.cdmLibrary/ehcache</prop>
26
		  </props>
27
        </property>
28
	</bean>
29
 
30
    <!-- enable the configuration of transactional behavior based on annotations -->
31
    <tx:annotation-driven transaction-manager="transactionManager"/>
32
    
33
    <!-- import additional beans into the root context -->
34
    <import resource="applicationContext.views.xml"/>
35
    
36
    <!-- CONFIGURE WEB APPLICATION HERE -->
37
    <import resource="datasources/configurable.xml" />
38
    
39
    
40
    <!-- OAI-PMH TODO externalize? -->
41
     <bean name="taxonOaiPmhController" class="eu.etaxonomy.cdm.remote.controller.oaipmh.TaxonOaiPmhController">
42
	   <property name="cachingModel" ref="taxonOaiPmhCacheMapping"/>
43
	 </bean>
44
	
45
	<bean name="taxonOaiPmhCacheMapping" class="org.springmodules.cache.provider.ehcache.EhCacheCachingModel">
46
	        <property name="cacheName" value="eu.etaxonomy.cdm.remote.controller.TaxonOaiPmhController.resumptionToken"/>
47
	</bean>
48
	<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
49
    <property name="configLocation" value="classpath:/eu/etaxonomy/cdm/remote/ehcache.xml" />
50
        <property name="shared" value="true"/>
51
    </bean>
52

  
53
	<bean id="serializableFactory" class="org.springmodules.cache.serializable.XStreamSerializableFactory"/>
54
	
55
	<bean id="cacheProviderFacade" class="org.springmodules.cache.provider.ehcache.EhCacheFacade">
56
	    <property name="cacheManager" ref="cacheManager" />
57
	    <property name="serializableFactory" ref="serializableFactory"/>
58
	</bean>
59
    <!-- 
60
     -->	
61

  
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
    xmlns:tx="http://www.springframework.org/schema/tx"
5
    xmlns:context="http://www.springframework.org/schema/context"
6
    xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7
    http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-2.5.xsd
8
    http://www.springframework.org/schema/tx   http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
9
    ">
10
	
11
	<!-- include default application context and customization -->
12
     <import resource="classpath:/eu/etaxonomy/cdm/defaultApplicationContext.xml"/>
13
     <bean id="persistentTermInitializer" class="eu.etaxonomy.cdm.database.PersistentTermInitializer">
14
     	<property name="omit" value="true" />
15
     </bean>
16
    <context:component-scan base-package="eu/etaxonomy/cdm/ext" />
17
    
18
    <import resource="classpath:/eu/etaxonomy/cdm/remote.xml"/>
19
    
20
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
21
		<property name="properties">
22
		  <props>
23
		      <prop key="eu.etaxonomy.cdm.base.path">${user.home}/.cdmLibrary/</prop>
24
		      <prop key="eu.etaxonomy.cdm.search.index.path">${user.home}/.cdmLibrary/index/</prop>
25
		      <prop key="eu.etaxonomy.cdm.ehcache.diskstore.path">${user.home}/.cdmLibrary/ehcache</prop>
26
		  </props>
27
        </property>
28
	</bean>
29
 
30
    <!-- enable the configuration of transactional behavior based on annotations -->
31
    <tx:annotation-driven transaction-manager="transactionManager"/>
32
    
33
    <!-- import additional beans into the root context -->
34
    <import resource="applicationContext.views.xml"/>
35
    
36
    <!-- CONFIGURE WEB APPLICATION HERE -->
37
    <import resource="datasources/configurable.xml" />
38
    
39
    <!-- OAI-PMH TODO externalize? -->
40
     <bean name="taxonOaiPmhController" class="eu.etaxonomy.cdm.remote.controller.oaipmh.TaxonOaiPmhController">
41
	   <property name="cachingModel" ref="taxonOaiPmhCacheMapping"/>
42
	 </bean>
43
	
44
	<bean name="taxonOaiPmhCacheMapping" class="org.springmodules.cache.provider.ehcache.EhCacheCachingModel">
45
	        <property name="cacheName" value="eu.etaxonomy.cdm.remote.controller.TaxonOaiPmhController.resumptionToken"/>
46
	</bean>
47
	<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
48
    <property name="configLocation" value="classpath:/eu/etaxonomy/cdm/remote/ehcache.xml" />
49
        <property name="shared" value="true"/>
50
    </bean>
51

  
52
	<bean id="serializableFactory" class="org.springmodules.cache.serializable.XStreamSerializableFactory"/>
53
	
54
	<bean id="cacheProviderFacade" class="org.springmodules.cache.provider.ehcache.EhCacheFacade">
55
	    <property name="cacheManager" ref="cacheManager" />
56
	    <property name="serializableFactory" ref="serializableFactory"/>
57
	</bean>
58
    <!-- 
59
     -->	
60

  
62 61
</beans>
cdmlib-remote/src/main/webapp/WEB-INF/cdmrest-servlet.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
	xmlns:tx="http://www.springframework.org/schema/tx"
5
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
6
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
8
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
9
    ">
10
	<context:component-scan base-package="eu/etaxonomy/cdm/remote" />
11

  
12

  
13
	<!-- 
14
	  ======= HandlerMappings =======
15
	  -->
16
	<!--
17
		first we try to find the controller using the simpleurlmapping, then
18
		the classname this follows the principal of "convention over
19
		configuration"
20
	-->
21
	<bean
22
		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
23
		<property name="order" value="1" />
24
		<property name="interceptors">
25
			<list>
26
				<ref bean="contentNegociationHandlerInterceptor" />
27
				<ref bean="localeContextHandlerInterceptor" />
28
			</list>
29
		</property>
30
	</bean>
31

  
32
    <!-- 
33
	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
34
		<property name="order" value="0" />
35
		<property name="mappings">
36
			<props>
37
				<prop key="/index.do">urlFilenameViewController
38
				</prop>
39
				<prop key="/">welcomeFileViewController
40
				</prop>
41
			</props>
42
		</property>
43
	</bean>
44
	 -->
45
    
46
	<!-- 
47
	======= HandlerAdapters =======
48
	-->
49
	<bean
50
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
51
	</bean>
52

  
53
	<!-- needed when using SimpleUrlHandlerMapping 	-->
54
	<bean
55
		class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
56
    
57
    
58
	<!-- 
59
	======= HandlerInterceptors =======
60
	-->
61
	<!-- 
62
	<bean id="datasourceContextHandlerInterceptor"
63
		class="eu.etaxonomy.cdm.remote.controller.interceptor.DatasourceContextHandlerInterceptor" /> -->
64
	<bean id="localeContextHandlerInterceptor"
65
		class="eu.etaxonomy.cdm.remote.controller.interceptor.LocaleContextHandlerInterceptor" />
66
	<bean id="contentNegociationHandlerInterceptor"
67
		class="eu.etaxonomy.cdm.remote.controller.interceptor.ContentNegociationHandlerInterceptor">
68
		<property name="mapping">
69
			<map>
70
				<entry key="text/json" value="json" />
71
				<entry key="application/json" value="json" />
72
				<entry key="application/xml" value="xml" />
73
			</map>
74
		</property>
75
		<property name="defaultExtension" value="xml" />
76
	</bean>
77

  
78
	<!-- 
79
	 ======= ViewControllers =======
80
	 -->
81
	<bean id="urlFilenameViewController"
82
		class="org.springframework.web.servlet.mvc.UrlFilenameViewController">
83
	</bean>
84
	<!--
85
		The welcome-file-list in the web.xml will is ignored since the
86
		cdmserver servlet is mapped to the root path [/] So the welcome file
87
		list is being replaced by a SimpleUrlHandlerMapping on the root path
88
		[/] which is mapped via this ViewController to the [index] view
89
	<bean id="welcomeFileViewController"
90
		class="org.springframework.web.servlet.mvc.UrlFilenameViewController">
91
		<property name="suffix">
92
			<value>index</value>
93
		</property>
94
	</bean>
95
	-->
96

  
97

  
98
	<!-- 
99
    ======= ViewResolver =======
100
    -->
101
	<!--
102
		PatternViewResolver is Subclass of
103
		org.springframework.web.servlet.view.XmlViewResolver which accepts a
104
		configuration file. The default configuration file is
105
		/WEB-INF/views.xml
106
	-->
107
	<bean name="viewResolver" class="eu.etaxonomy.cdm.remote.view.PatternViewResolver">
108
		<property name="order" value="0" />
109
		<!--
110
			turn caching off FOR DEBUGING ONLY !!!! 
111
			<property name="cache" value="false"/>
112
		-->
113
	</bean>
114
	
115
    <!--  
116
        === the viewResolverJsp is currently unused ===
117
	<bean id="viewResolverJsp"
118
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
119
		<property name="order" value="1" />
120
		<property name="prefix" value="/WEB-INF/jsp/" />
121
		<property name="suffix" value=".jsp" />
122
		<property name="viewNames">
123
			<!- -
124
				view names (or name patterns) that can be handled
125
			- ->
126
			<list>
127
				<value>index</value>
128
			</list>
129
		</property>
130
	</bean>
131
    -->
132

  
133
	<!-- 
134
	======= Exception Handling =======
135
	-->
136
	<bean id="exceptionResolver" class="eu.etaxonomy.cdm.remote.exception.CdmExceptionResolver">
137
	</bean>
138

  
139
	<!--  
140
    ======= Security ======= 
141
    -->
142
<!--    <bean id="basicProcessingFilter" class="org.springframework.security.ui.basicauth.BasicProcessingFilter">-->
143
<!--		<property name="authenticationManager"><ref bean="authenticationManager"/></property>-->
144
<!--		<property name="authenticationEntryPoint"><ref bean="authenticationEntryPoint"/></property>-->
145
<!--	</bean>-->
146
<!--	<bean id="authenticationEntryPoint" class="org.springframework.security.ui.basicauth.BasicProcessingFilterEntryPoint">-->
147
<!--		<property name="realmName"><value>Name Of Your Realm</value></property>-->
148
<!--	</bean>-->
149
    
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
	xmlns:tx="http://www.springframework.org/schema/tx"
5
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
6
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
8
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
9
    ">
10
	<context:component-scan base-package="eu/etaxonomy/cdm/remote" />
11

  
12

  
13
	<!-- 
14
	  ======= HandlerMappings =======
15
	  -->
16
	<!--
17
		first we try to find the controller using the simpleurlmapping, then
18
		the classname this follows the principal of "convention over
19
		configuration"
20
	-->
21
	<bean
22
		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
23
		<property name="order" value="1" />
24
		<property name="interceptors">
25
			<list>
26
				<!--<ref bean="contentNegociationHandlerInterceptor" /> -->
27
				<ref bean="localeContextHandlerInterceptor" />
28
			</list>
29
		</property>
30
	</bean>
31

  
32
    <!-- 
33
	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
34
		<property name="order" value="0" />
35
		<property name="mappings">
36
			<props>
37
				<prop key="/index.do">urlFilenameViewController
38
				</prop>
39
				<prop key="/">welcomeFileViewController
40
				</prop>
41
			</props>
42
		</property>
43
	</bean>
44
	 -->
45
    
46
	<!-- 
47
	======= HandlerAdapters =======
48
	-->
49
	<bean
50
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
51
	</bean>
52

  
53
	<!-- needed when using SimpleUrlHandlerMapping 	-->
54
	<bean
55
		class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
56
    
57
    
58
	<!-- 
59
	======= HandlerInterceptors =======
60
	-->
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff