Project

General

Profile

« Previous | Next » 

Revision af4969c8

Added by Andreas Kohlbecker over 3 years ago

ref #9095, ref #9096 catching LIEs at Team.members in TeamOrPersonBaseBeanProcessor to handle problems potentially originating from bug ref #7331

View differences:

cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TeamOrPersonBaseBeanProcessor.java
10 10

  
11 11
import java.util.List;
12 12

  
13
import org.hibernate.LazyInitializationException;
14

  
13 15
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
14 16
import net.sf.json.JSONObject;
15 17
import net.sf.json.JsonConfig;
......
21 23
 */
22 24
public class TeamOrPersonBaseBeanProcessor extends AbstractBeanProcessor<TeamOrPersonBase> {
23 25

  
24
    /* (non-Javadoc)
25
     * @see eu.etaxonomy.cdm.remote.json.processor.bean.AbstractBeanProcessor#getIgnorePropNames()
26
     */
27 26
    @Override
28 27
    public List<String> getIgnorePropNames() {
29 28
        // nothing to ignore by default
30 29
        return null;
31 30
    }
32 31

  
33
    /* (non-Javadoc)
34
     * @see eu.etaxonomy.cdm.remote.json.processor.bean.AbstractBeanProcessor#processBeanSecondStep(java.lang.Object, net.sf.json.JSONObject, net.sf.json.JsonConfig)
35
     */
32

  
36 33
    @Override
37 34
    public JSONObject processBeanSecondStep(TeamOrPersonBase bean, JSONObject json,
38 35
            JsonConfig jsonConfig) {
39
        json.element("titleCache", bean.getTitleCache());
40
        json.element("nomenclaturalTitle", bean.getNomenclaturalTitle());
36
        //NOTE LazyInitializationException related to author teams are often causing problems
37
        //     so we catch them here in order to avoid breaking the web service response completely
38
        //     The team should be initialized by the TeamAutoInitializer but due to the bug #7331
39
        //     this seems to be broken in specific cases.
40
        //     The below try-catch should be removed once #7331 but by carefully checking the examples
41
        //     #9095, #9096. Other tickets related to LIEs and eu.etaxonomy.cdm.model.agent.Team.teamMembers
42
        //     should also be checked.
43
        try {
44
            json.element("titleCache", bean.getTitleCache());
45
        } catch (LazyInitializationException e) {
46
           logger.error("Caught LazyInitializationException at getTitleCache()", e);
47
        }
48
        try {
49
            json.element("nomenclaturalTitle", bean.getNomenclaturalTitle());
50
        } catch (LazyInitializationException e) {
51
            logger.error("Caught LazyInitializationException at getNomenclaturalTitle()", e);
52
         }
41 53
        return json;
42 54
    }
43 55

  

Also available in: Unified diff