Project

General

Profile

« Previous | Next » 

Revision 41502854

Added by Andreas Müller over 2 years ago

cleanup

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/api/application/CdmIoApplicationController.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
1 9
package eu.etaxonomy.cdm.io.api.application;
2 10

  
3 11
import org.apache.log4j.Logger;
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/BerlinModelTransformer.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.io.berlinModel;
11 10

  
12 11
import java.sql.ResultSet;
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmDefaultIOBase.java
3 3
 * European Distributed Institute of Taxonomy
4 4
 * http://www.e-taxonomy.eu
5 5
 */
6

  
7 6
package eu.etaxonomy.cdm.io.common;
8 7

  
9 8
import org.apache.log4j.Logger;
......
22 21
 * @since 17.11.2008
23 22
 */
24 23
public class CdmDefaultIOBase<T extends IIoConfigurator> {
25
	@SuppressWarnings("unused")
24

  
25
    @SuppressWarnings("unused")
26 26
	private static final Logger logger = Logger.getLogger(CdmDefaultIOBase.class);
27 27

  
28 28
	public static final String DEFAULT_IO_APPLICATION_CONTEXT_RESOURCE = "/eu/etaxonomy/cdm/defaultIoApplicationContext.xml";
29 29

  
30

  
31 30
	protected ICdmRepository cdmApp = null;
32 31

  
33 32
	/**
34 33
	 * Creates a new {@link CdmApplicationController} if it does not exist yet
35 34
	 * or if createNew is <ocde>true</code>
36
	 *
37
	 * @param config
38
	 * @param destination
39
	 * @param omitTermLoading
40
	 * @param createNew
41
	 * @return
42 35
	 */
43 36
	protected boolean startApplicationController(IIoConfigurator config,
44 37
			ICdmDataSource cdmSource, boolean omitTermLoading, boolean createNew) {
......
84 77
	public void setCdmAppController(ICdmRepository cdmApp) {
85 78
		this.cdmApp = cdmApp;
86 79
	}
87

  
88
}
80
}
cdmlib-io/src/main/resources/eu/etaxonomy/cdm/defaultIoApplicationContext.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:context="http://www.springframework.org/schema/context"
5
  xmlns:security="http://www.springframework.org/schema/security"
6
  
7
  xsi:schemaLocation=
8
      "http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
9
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
10
       http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security-4.2.xsd">
11
    
12
  <import resource="classpath:/eu/etaxonomy/cdm/defaultApplicationContext.xml"/>
13

  
14
  <!-- TODO move to defaultApplicationContext in ext -->
15
  <!-- includes external services beans e.g. my/cdm/ext/geo/IGeoServiceAreaMapping  -->
16
  <context:component-scan base-package="eu/etaxonomy/cdm/ext"/>
17

  
18
  <!-- includes service beans e.g. in eu/etaxonomy/cdm/api -->
19
  <context:component-scan base-package="eu/etaxonomy/cdm/io"/>
20
  
21
</beans>
cdmlib-io/src/main/resources/eu/etaxonomy/cdm/io.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:context="http://www.springframework.org/schema/context"
5
  xmlns:security="http://www.springframework.org/schema/security"
6
  
7
  xsi:schemaLocation=
8
      "http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
9
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
10
       http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security-4.2.xsd">
11
    
12
  <import resource="classpath:/eu/etaxonomy/cdm/defaultApplicationContext.xml"/>
13

  
14
  <!-- TODO move to defaultApplicationContext in ext -->
15
  <!-- includes external services beans e.g. my/cdm/ext/geo/IGeoServiceAreaMapping  -->
16
  <context:component-scan base-package="eu/etaxonomy/cdm/ext"/>
17

  
18
  <!-- includes service beans e.g. in eu/etaxonomy/cdm/api -->
19
  <context:component-scan base-package="eu/etaxonomy/cdm/io"/>
20
  
21
</beans>
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/CdmPersistentDataSource.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.database;
11 10

  
12 11
import static eu.etaxonomy.cdm.common.XmlHelp.getBeansRoot;
......
48 47
        extends CdmDataSourceBase
49 48
        implements ICdmPersistentSource {
50 49

  
50
    @SuppressWarnings("unused")
51 51
    private static final Logger logger = Logger.getLogger(CdmPersistentDataSource.class);
52 52

  
53 53
	public static final String DATASOURCE_BEAN_POSTFIX = "DataSource";
......
70 70

  
71 71
	/**
72 72
	 * Returns the default CdmDataSource
73
	 * @return the default CdmDataSource
74
	 * @throws DataSourceNotFoundException
75 73
	 */
76 74
	public final static CdmPersistentDataSource NewDefaultInstance() throws DataSourceNotFoundException {
77 75
		return NewInstance("default");
......
79 77

  
80 78
	/**
81 79
	 * Returns the default CdmDataSource
82
	 * @return the default CdmDataSource
83
	 * @throws DataSourceNotFoundException
84 80
	 */
85 81
	public final static CdmPersistentDataSource NewLocalHsqlInstance() throws DataSourceNotFoundException{
86 82
		return NewInstance("localDefaultHsql");
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/term/TermVocabularyDaoImpl.java
398 398
        String queryString = TermVocabularyDto.getTermCollectionDtoSelect();
399 399

  
400 400
        if (!termTypeWithSubType.isEmpty()){
401
            queryString += " where a.termType in (:termTypes) ";
401
            queryString += " WHERE a.termType in (:termTypes) ";
402 402
            if (pattern != null){
403 403
                queryString += " AND a.titleCache like :pattern";
404 404
            }
cdmlib-print/src/main/java/eu/etaxonomy/cdm/print/LocalXMLEntityFactory.java
56 56
    private final JsonView xmlView;
57 57

  
58 58
    @Autowired
59
    private final ICdmRepository applicationConfiguration;
59
    private final ICdmRepository repository;
60 60

  
61 61
    @Autowired
62 62
    private JsonConfig jsonConfig;
......
88 88

  
89 89
    private final IProgressMonitor monitor;
90 90

  
91
    /**
92
     *
93
     * @param applicationConfiguration
94
     * @param monitor
95
     */
96 91
    protected LocalXMLEntityFactory(
97 92
            ICdmRepository applicationConfiguration,
98 93
            IProgressMonitor monitor) {
99
        this.applicationConfiguration = applicationConfiguration;
94
        this.repository = applicationConfiguration;
100 95
        this.monitor = monitor;
101 96
        this.xmlView = new JsonView();
102 97
        xmlView.setType(Type.XML);
......
104 99
        initJsonConfigs();
105 100
    }
106 101

  
107
    /**
108
     *
109
     */
110 102
    private void initControllers() {
111
    	classificationListController = (ClassificationListController) applicationConfiguration
103
    	classificationListController = (ClassificationListController) repository
112 104
    			.getBean("classificationListController");
113
    	classificationController = (ClassificationController) applicationConfiguration
105
    	classificationController = (ClassificationController) repository
114 106
    			.getBean("classificationController");
115
    	taxonNodePrintAppController = (TaxonNodePrintAppController) applicationConfiguration
107
    	taxonNodePrintAppController = (TaxonNodePrintAppController) repository
116 108
    			.getBean("taxonNodePrintAppController");
117 109

  
118
    	nameController = (NameController) applicationConfiguration
110
    	nameController = (NameController) repository
119 111
    			.getBean("nameController");
120 112

  
121
    	featureTreeListController = (TermTreeListController) applicationConfiguration
113
    	featureTreeListController = (TermTreeListController) repository
122 114
    			.getBean("featureTreeListController");
123
    	featureTreeController = (TermTreeController) applicationConfiguration
115
    	featureTreeController = (TermTreeController) repository
124 116
    			.getBean("featureTreeController");
125
    	termNodeController = (TermNodeController) applicationConfiguration
117
    	termNodeController = (TermNodeController) repository
126 118
    			.getBean("featureNodeController");
127 119

  
128
    	taxonPortalController = (TaxonPortalController) applicationConfiguration
120
    	taxonPortalController = (TaxonPortalController) repository
129 121
    			.getBean("taxonPortalController");
130 122

  
131
    	polytomousKeyNodeDtoController = (PolytomousKeyNodeDtoController) applicationConfiguration.getBean("polytomousKeyNodeDtoController");
123
    	polytomousKeyNodeDtoController = (PolytomousKeyNodeDtoController) repository.getBean("polytomousKeyNodeDtoController");
132 124
    }
133 125

  
134
    /**
135
     *
136
     */
137 126
    private void initJsonConfigs() {
138
        jsonConfig = (JsonConfig) applicationConfiguration.getBean("jsonConfig");
139
        jsonConfigPortal = (JsonConfig) applicationConfiguration
127
        jsonConfig = (JsonConfig) repository.getBean("jsonConfig");
128
        jsonConfigPortal = (JsonConfig) repository
140 129
                .getBean("jsonConfigPortal");
141 130
    }
142 131

  
cdmlib-print/src/test/java/eu/etaxonomy/cdm/print/PubTest.java
32 32
/**
33 33
 * @author l.morris
34 34
 * @since Mar 7, 2013
35
 *
36 35
 */
37 36
public class PubTest {
38 37

  
......
40 39

  
41 40
	private static PublishConfigurator configurator;
42 41

  
43
	private static Publisher publisher;
44

  
45 42
	public static final String DEFAULT_PRINT_APPLICATION_CONTEXT_RESOURCE = "/eu/etaxonomy/cdm/defaultPrintApplicationContext.xml";
46 43

  
47

  
48
	/**
49
	 * @throws java.lang.Exception
50
	 */
51 44
	public static void setUpBeforeClass() throws Exception {
52 45

  
53 46
		ICdmDataSource dataSource = customDataSource();
cdmlib-remote-webapp/src/main/webapp/WEB-INF/applicationContext.xml
34 34
  <context:component-scan base-package="eu/etaxonomy/cdm/ext" />
35 35

  
36 36
  <import resource="classpath:/eu/etaxonomy/cdm/remote.xml"/>
37
  <context:component-scan base-package="eu/etaxonomy/cdm/io">
38
    <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.io\.pesi.*" />
39
    <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.io\.faunaEuropaea.*" />
40
    <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.io\.erms.*" />
41
    <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.io\.eflora.*" />
42
    <context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.io\.berlinModel.*" />
43
  </context:component-scan>
37
  <context:component-scan base-package="eu/etaxonomy/cdm/io"/>
44 38

  
45 39
  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
46 40
    <property name="properties">
cdmlib-remote-webapp/src/test/java/eu/etaxonomy/cdm/remote/ClassificationIT.java
14 14
/**
15 15
 * @author a.kohlbecker
16 16
 * @since Mar 3, 2014
17
 *
18 17
 */
19

  
20 18
public class ClassificationIT extends WebServiceTestBase  {
21 19

  
22 20
    public static final Logger logger = Logger.getLogger(ClassificationIT.class);
......
27 25
        logger.debug("response: " + response);
28 26
        assertTrue(response.contains("My Classification"));
29 27
    }
30

  
31
}
28
}
cdmlib-remote-webapp/src/test/java/eu/etaxonomy/cdm/remote/ForceSchemaCreateIT.java
13 13
/**
14 14
 * @author a.kohlbecker
15 15
 * @date May 18, 2020
16
 *
17 16
 */
18 17
public class ForceSchemaCreateIT extends WebServiceTestBase {
19 18

  
......
25 24
        assertTrue(response.contains("DB_CREATE_DATE"));
26 25
        // TODO check for DB_CREATE_DATE value no older than 5 minutes
27 26
    }
28

  
29
}
27
}
cdmlib-remote-webapp/src/test/java/eu/etaxonomy/cdm/remote/SwaggerStaticIT.java
10 10

  
11 11
import java.io.File;
12 12
import java.io.IOException;
13
import java.nio.charset.Charset;
13 14

  
14 15
import org.apache.commons.io.FileUtils;
15 16
import org.apache.log4j.Logger;
......
51 52
            try {
52 53
                File targetFile = new File(staticResourcesFolder + path + StaticSwaggerApiDoc.JSON);
53 54
                new File(targetFile.getParent()).mkdirs();
54
                FileUtils.write(targetFile, response);
55
                FileUtils.write(targetFile, response, Charset.defaultCharset());
55 56
                logger.info(response.length() + " characters of swagger-resources written to " + targetFile.getAbsolutePath());
56 57
            } catch (IOException e) {
57 58
                logger.error(e);
58 59
            }
59 60
        }
60

  
61 61
    }
62 62

  
63

  
64 63
    @Test
65 64
    public void fetchSwaggerGroups(){
66 65

  
67 66
        String swagger2Endpoint= "/v2/api-docs";
68

  
69

  
70 67
        String staticApiDocFolder = "./target/classes/"+ StaticSwaggerApiDoc.SWAGGER_STATIC + "/api-docs/";
71 68

  
72 69
        staticApiDocFolder = staticApiDocFolder.replace("/", File.separator);
73 70

  
74

  
75 71
        for(SwaggerGroupsConfig group : SwaggerGroupsConfig.values()) {
76 72
            logger.info(group.groupName());
77 73
            String response =  httpGetJson(swagger2Endpoint, "group=" + group.groupName());
78 74
            response = response.replaceAll(",\"host\":\"([^\"]*)", ",\"host\":\"" + StaticSwaggerApiDoc.HOST);
79 75
            response = response.replaceAll(",\"basePath\":\"([^\"]*)", ",\"basePath\":\"" + StaticSwaggerApiDoc.BASE_PATH);
80 76
            try {
81
                FileUtils.write(new File(staticApiDocFolder + group.name() + StaticSwaggerApiDoc.JSON), response);
77
                FileUtils.write(new File(staticApiDocFolder + group.name() + StaticSwaggerApiDoc.JSON), response, Charset.defaultCharset());
82 78
            } catch (IOException e) {
83 79
                // TODO Auto-generated catch block
84 80
                e.printStackTrace();
......
88 84
//        File pwd = new File("pom.xml");
89 85
//        System.err.println(pwd.getAbsolutePath());
90 86
    }
91

  
92
}
87
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/opt/config/DataSourceException.java
20 20
    public DataSourceException(String message, Throwable cause) {
21 21
        super(message, cause);
22 22
    }
23

  
24

  
25

  
26
}
23
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/opt/config/DataSourceProperties.java
14 14
/**
15 15
 * @author a.kohlbecker
16 16
 * @since Oct 5, 2012
17
 *
18 17
 */
19 18
public class DataSourceProperties {
20 19

  
21 20
    private static final String CDMLIB_REMOTE_XSL_BASE_PATH = "cdmlib-remote.xslBasePath";
22 21

  
22
    private static final Properties emptyProperties = new Properties();
23

  
23 24
    private String currentDataSourceId = null;
24 25

  
25 26
    private Map<String, Properties> propsMap;
26 27

  
28

  
29
    public DataSourceProperties() {
30
        super();
31
    }
32

  
33

  
27 34
    public Map<String, Properties> getPropsMap() {
28 35
        return propsMap;
29 36
    }
30

  
31 37
    public void setPropsMap(Map<String, Properties> propsMap) {
32 38
        this.propsMap = propsMap;
33 39
    }
34 40

  
35
    private static final Properties emptyProperties = new Properties();
36 41

  
37 42
    public String getCurrentDataSourceId() {
38 43
        return currentDataSourceId;
39 44
    }
40

  
41 45
    /**
42 46
     * will be set by {@link DataSourceConfigurer} only
43
     *
44
     * @param currentDataSourceId
45 47
     */
46 48
    protected void setCurrentDataSourceId(String currentDataSourceId) {
47 49
        this.currentDataSourceId = currentDataSourceId;
48 50
    }
49 51

  
50
    public DataSourceProperties() {
51
        super();
52
    }
53

  
54 52
    /**
55 53
     * returns the XslBasePath for the current data source from the cdm bean definition file
56 54
     *
57 55
     * This file is usually {@code ./.cdmLibrary/datasources.xml}
58
     *
59
     * @param beanName
60
     * @return
61 56
     */
62 57
    public String getXslBasePath(String defaultPath) {
63 58

  
64 59
        String xslBasePath = currentDataSourceProperties().getProperty(CDMLIB_REMOTE_XSL_BASE_PATH, defaultPath);
65 60
        xslBasePath = xslBasePath.replaceAll("/$", "");
66 61
        return xslBasePath;
67

  
68 62
    }
69 63

  
70 64
    private Properties currentDataSourceProperties() {
......
77 71

  
78 72
        return emptyProperties;
79 73
    }
80

  
81

  
82

  
83
}
74
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/opt/config/EhCacheDiskStoreConfiguration.java
21 21
/**
22 22
 * @author a.kohlbecker
23 23
 * @since Feb 1, 2017
24
 *
25 24
 */
26 25
@Configuration
27 26
public class EhCacheDiskStoreConfiguration {
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/config/AbstractWebApplicationConfigurer.java
27 27
/**
28 28
 * @author a.kohlbecker
29 29
 * @since 20.07.2010
30
 *
31 30
 */
32 31
public abstract class AbstractWebApplicationConfigurer  implements InitializingBean {
33 32

  
......
63 62
                            + java.io.File.separator
64 63
                            + CDMLIB_REMOTE_PROPERTIES
65 64
                    );
66
                if (in != null) {
67
                    userDefinedProperties.load(in);
68
                }
65
                userDefinedProperties.load(in);
69 66
            } catch (IOException e) {
70 67
                logger.debug("No per user " + CDMLIB_REMOTE_PROPERTIES + " found.");
71 68
            }
......
123 120
    protected void addErrorMessageToServletContextAttributes(String errorMessage) {
124 121
        Object o = webApplicationContext.getServletContext().getAttribute(ATTRIBUTE_ERROR_MESSAGES);
125 122
        List<String> messages;
126
        if(o != null  && o instanceof List<?>){
123
        if(o instanceof List<?>){
127 124
            messages = (List<String>) o;
128 125
        } else {
129
            messages = new ArrayList<String>();
126
            messages = new ArrayList<>();
130 127
        }
131 128
        messages.add(errorMessage);
132 129
        webApplicationContext.getServletContext().setAttribute(ATTRIBUTE_ERROR_MESSAGES, messages);
133 130
    }
134

  
135

  
136

  
137
}
131
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/config/MultiWebSecurityConfiguration.java
11 11
import java.io.File;
12 12
import java.io.FileInputStream;
13 13
import java.io.IOException;
14
import java.nio.charset.Charset;
14 15
import java.util.Properties;
15 16

  
16 17
import org.apache.commons.io.FileUtils;
......
38 39
 *
39 40
 * @author a.kohlbecker
40 41
 * @since Oct 6, 2016
41
 *
42 42
 */
43 43
@EnableWebSecurity
44 44
@Import(OAuth2ServerConfiguration.class)
......
57 57
     * Check for full authentication for remoting services
58 58
     * @author a.kohlbecker
59 59
     * @since Oct 6, 2016
60
     *
61 60
     */
62 61
    @Configuration
63 62
    @Order(2)
......
82 81
     *
83 82
     * @author a.kohlbecker
84 83
     * @since Jan 16, 2017
85
     *
86 84
     */
87 85
    @Configuration
88 86
    @Order(1)
......
109 107
     *
110 108
     * @author a.kohlbecker
111 109
     * @since Oct 6, 2016
112
     *
113 110
     */
114 111
    @Configuration
115 112
    public static class DefaultWebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
......
149 146
        }
150 147
    }
151 148

  
152
    /**
153
     * @param globalManagementClients
154
     * @throws IOException
155
     */
156 149
    private void makeManagingUsersPropertiesFile(File propertiesFile) throws IOException {
157 150
        propertiesFile.createNewFile();
158 151
        FileUtils.write(
......
175 168
                + "# This properties file should contain entries in the form\n"
176 169
                + "#    username=password\n"
177 170
                + "# -------------------------------------------------------------------------------------------\n"
178
                + "#\n"
171
                + "#\n",
172
                Charset.defaultCharset()
179 173
                );
180 174
        }
181 175
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/config/OAuth2ServerConfiguration.java
100 100
    /**
101 101
     * @author a.kohlbecker
102 102
     * @since Oct 6, 2016
103
     *
104 103
     */
105 104
    @Configuration
106 105
    @EnableAuthorizationServer
......
133 132
             * Client for 'implicit grant'
134 133
             */
135 134
            builder.withClient(CLIENT_ID)
136
            //.resourceIds(RESOURCE_ID)
137
            .authorizedGrantTypes("authorization_code", "refresh_token", "implicit")
138
            .authorities("ROLE_CLIENT")
139
            .scopes("read", "write", "trust")
140
            .secret("secret") // secret for login of the client into /oauth/token
141
            .autoApprove("read");
142
            // @formatter:on
135
                //.resourceIds(RESOURCE_ID)
136
                .authorizedGrantTypes("authorization_code", "refresh_token", "implicit")
137
                .authorities("ROLE_CLIENT")
138
                .scopes("read", "write", "trust")
139
                .secret("secret") // secret for login of the client into /oauth/token
140
                .autoApprove("read");
141
                // @formatter:on
143 142

  
144 143
        }
145 144

  
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonPortalController.java
572 572
                includeTaxonDescriptions, includeOccurrences, includeTaxonNameDescriptions, response, taxonInitStrategy, null);
573 573
    }
574 574

  
575
    public  EntityMediaContext<Taxon> loadMediaForTaxonAndRelated(UUID uuid,
575
    public  EntityMediaContext<Taxon> loadMediaForTaxonAndRelated(UUID taxonUuid,
576 576
            UuidList relationshipUuids, UuidList relationshipInversUuids,
577 577
            Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeTaxonNameDescriptions,
578 578
            HttpServletResponse response,
......
580 580

  
581 581
        boolean includeUnpublished = NO_UNPUBLISHED;
582 582

  
583
        Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, taxonInitStrategy);
583
        Taxon taxon = getCdmBaseInstance(Taxon.class, taxonUuid, response, taxonInitStrategy);
584 584
        taxon = checkExistsAndAccess(taxon, includeUnpublished, response);
585 585

  
586 586
        Set<TaxonRelationshipEdge> includeRelationships = ControllerUtils.loadIncludeRelationships(relationshipUuids, relationshipInversUuids, termService);
......
610 610
            @RequestParam(value = "size", required = false) Integer size,
611 611
            HttpServletRequest request, HttpServletResponse response)throws IOException {
612 612

  
613

  
614 613
        boolean includeUnpublished = NO_UNPUBLISHED;
615 614

  
616 615
        logger.info("doGetSubtreeMedia() " + requestPathAndQuery(request));
......
633 632
        return mediafilteredForPreferredRepresentations;
634 633
    }
635 634

  
636
    /**
637
     * @param includeTaxonDescriptions
638
     * @param includeOccurrences
639
     * @param includeTaxonNameDescriptions
640
     * @param taxon
641
     * @param includeRelationships
642
     * @param media
643
     */
644 635
    public List<Media> addTaxonomicChildrenMedia(Boolean includeTaxonDescriptions, Boolean includeOccurrences,
645 636
            Boolean includeTaxonNameDescriptions, Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
646 637
            List<Media> media) {
......
670 661
        return media;
671 662
    }
672 663

  
673
    /**
674
     *
675
     * @param taxon
676
     * @param includeRelationships
677
     * @param type
678
     * @param mimeTypes
679
     * @param widthOrDuration
680
     * @param height
681
     * @param size
682
     * @return
683
     */
684 664
    private List<Media> listMediaForTaxon(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
685 665
            Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeTaxonNameDescriptions, List<String> propertyPath) {
686 666

  
......
690 670
        return media;
691 671
    }
692 672

  
693

  
694 673
    public class EntityMediaContext<T extends IdentifiableEntity> {
695 674

  
696
        T entity;
697
        List<Media> media;
698
        /**
699
         * @param entity
700
         * @param media
701
         */
702
        public EntityMediaContext(T entity, List<Media> media) {
675
        private T entity;
676
        private List<Media> media;
703 677

  
678
        public EntityMediaContext(T entity, List<Media> media) {
704 679
            this.entity = HibernateProxyHelper.deproxy(entity);
705 680
            this.media = media;
706 681
        }
682

  
707 683
        public T getEntity() {
708 684
            return entity;
709 685
        }
710 686
        public List<Media> getMedia() {
711 687
            return media;
712 688
        }
689

  
713 690
        /**
714 691
         * @param addTaxonomicChildrenMedia
715 692
         */
......
717 694
            this.media = media;
718 695

  
719 696
        }
720

  
721

  
722

  
723 697
    }
724 698

  
725 699
// ---------------------- code snippet preserved for possible later use --------------------
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/oaipmh/ReferenceOaiPmhController.java
65 65
        this.service = service;
66 66
    }
67 67

  
68

  
69
    /* (non-Javadoc)
70
     * @see eu.etaxonomy.cdm.remote.controller.AbstractOaiPmhController#finishModelAndView(eu.etaxonomy.cdm.model.common.LSID, eu.etaxonomy.cdm.remote.dto.oaipmh.MetadataPrefix, org.springframework.web.servlet.ModelAndView)
71
     */
72 68
    @Override
73 69
    protected void finishModelAndView(LSID identifier,
74 70
            MetadataPrefix metadataPrefix, ModelAndView modelAndView)
......
82 78
        }
83 79
    }
84 80

  
85
    /**
86
     * @param identifier
87
     * @param metadataPrefix
88
     * @return
89
     * @throws IdDoesNotExistException
90
     */
91 81
    private  List<TaxonBase> obtainCoveredTaxaList(
92 82
            LSID identifier, MetadataPrefix metadataPrefix)
93 83
            throws IdDoesNotExistException {
......
97 87
        List<TaxonBase> list = service.listCoveredTaxa(reference, true, TAXON_INIT_STRATEGY);
98 88
        return list;
99 89
    }
100

  
101

  
102

  
103
}
90
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/util/ControllerUtils.java
21 21
/**
22 22
 * @author a.kohlbecker
23 23
 * @since Jan 24, 2013
24
 *
25 24
 */
26 25
public class ControllerUtils {
27 26

  
28
    /**
29
     * @param relationshipUuids
30
     * @param relationshipInversUuids
31
     * @param includeRelationships
32
     * @return
33
     */
34 27
    public static Set<TaxonRelationshipEdge> loadIncludeRelationships(UuidList relationshipUuids, UuidList relationshipInversUuids, ITermService termService) {
35 28
        Set<TaxonRelationshipEdge> includeRelationships = null;
36 29
        if(relationshipUuids != null || relationshipInversUuids != null){
......
53 46
        }
54 47
        return includeRelationships;
55 48
    }
56

  
57

  
58
}
49
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/occurrencecatalogue/OccurrenceSearch.java
22 22
 * <P>
23 23
 *
24 24
 * @author p.kelbert
25
 * @version 1.0
26 25
 * @since march 10 2014
27 26
 */
28

  
29

  
30 27
public class OccurrenceSearch implements RemoteResponse {
31 28

  
32 29
    private OccurrenceSearchRequest request;
cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote.xml
104 104
        <entry key="constantConverter">
105 105
          <bean class="eu.etaxonomy.cdm.remote.dto.assembler.converter.ConstantConverter"/>
106 106
        </entry>
107

  
108 107
      </map>
109 108
    </property>
110 109
  </bean>
cdmlib-remote/src/test/resources/eu/etaxonomy/cdm/applicationContext-test.xml
15 15
    <!-- 
16 16
        This applicationContext is not a full cdm application context. It only covers the remote components 
17 17
        without service and persistence. The cacheManager is usually provided via a Java config class in
18
        eu/etaxonomy/cdm/service/api/conf which cannot  use in this context. Therefore we are 
18
        eu/etaxonomy/cdm/service/api/conf which cannot be used in this context. Therefore we are 
19 19
        using the EhCacheManagerFactoryBean here to initialize the cacheManager bean.
20 20
     -->
21 21
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
cdmlib-remote/src/test/resources/eu/etaxonomy/cdm/remote/ehcache.xml
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<ehcache>
3 3
  <!--
4
    This configuration is loaded by the default cache configuration. An in only to be used in specific 
5
    Test contexts.
4
    This configuration is loaded by the default cache configuration. It is only to be used in specific 
5
    test contexts.
6 6
  -->
7 7
  <defaultCache maxElementsInMemory="10" eternal="false"
8 8
    timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" />
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationController.java
131 131
	/**
132 132
	 * Constructor, opens an spring ApplicationContext by using the according data source
133 133
	 * and the default database schema validation type
134
	 *
135
	 * @param dataSource
136 134
	 */
137 135
	public static CdmApplicationController NewInstance(ICdmDataSource dataSource){
138 136
		return CdmApplicationController.NewInstance(null, dataSource, defaultDbSchemaValidation, false);
......
143 141
		return CdmApplicationController.NewInstance(null, dataSource, dbSchemaValidation, false);
144 142
	}
145 143

  
146

  
147 144
	public static CdmApplicationController NewInstance(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading){
148 145
		return CdmApplicationController.NewInstance(null, dataSource, dbSchemaValidation, omitTermLoading);
149 146
	}
......
171 168
	//		return new CdmApplicationController(applicationContextResource, dataSource, dbSchemaValidation, omitTermLoading, progressMonitor,listeners);
172 169
	//	}
173 170

  
174
	/**
175
	 * @return
176
	 */
177 171
	protected static ClassPathResource getClasspathResource(){
178 172
		return new ClassPathResource(DEFAULT_APPLICATION_CONTEXT_RESOURCE);
179 173
	}
180 174

  
181

  
182
	/**
183
	 * @return
184
	 * @throws DataSourceNotFoundException
185
	 */
186 175
	protected static CdmPersistentDataSource getDefaultDatasource() throws DataSourceNotFoundException{
187 176
		CdmPersistentDataSource dataSource = CdmPersistentDataSource.NewDefaultInstance();
188 177
		return dataSource;
189 178
	}
190 179

  
191

  
192
	/**
193
	 *
194
	 * FIXME:Remoting this constructor is added only to allow extension of this cntroller
195
	 * class. and should be removed after refactoring
196
	 */
197
	protected CdmApplicationController(){
198
		applicationContextResource = null;
199
		progressMonitor = null;
200
	}
201

  
202

  
203 180
	/**
204 181
	 * Constructor, opens an spring 2.5 ApplicationContext by using the according data
205 182
	 * source
206
	 *
207
	 * @param dataSource
208
	 * @param dbSchemaValidation
209
	 * @param omitTermLoading
210 183
	 */
211 184
	protected CdmApplicationController(Resource applicationContextResource, ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation,
212 185
	        HibernateConfiguration hibernateConfig,
......
222 195
		setNewDataSource(dataSource, dbSchemaValidation, hibernateConfig, omitTermLoading, listeners);
223 196
	}
224 197

  
225

  
226 198
	/**
227 199
	 * Sets the application context to a new spring ApplicationContext by using the
228 200
	 * according data source and initializes the Controller.
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
977 977
    //    logger.setLevel(Level.TRACE);
978 978
//        Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE);
979 979

  
980
        logger.trace("listMedia() - START");
980
        if (logger.isTraceEnabled()){logger.trace("listMedia() - START");}
981 981

  
982 982
        Set<Taxon> taxa = new HashSet<>();
983 983
        List<Media> taxonMedia = new ArrayList<>();
......
989 989

  
990 990
        // --- resolve related taxa
991 991
        if (includeRelationships != null && ! includeRelationships.isEmpty()) {
992
            logger.trace("listMedia() - resolve related taxa");
992
            if (logger.isTraceEnabled()){logger.trace("listMedia() - resolve related taxa");}
993 993
            taxa = listRelatedTaxa(taxon, includeRelationships, null, includeUnpublished, null, null, null);
994 994
        }
995 995

  
996 996
        taxa.add((Taxon) dao.load(taxon.getUuid()));
997 997

  
998 998
        if(includeTaxonDescriptions != null && includeTaxonDescriptions){
999
            logger.trace("listMedia() - includeTaxonDescriptions");
999
            if (logger.isTraceEnabled()){logger.trace("listMedia() - includeTaxonDescriptions");}
1000 1000
            List<TaxonDescription> taxonDescriptions = new ArrayList<>();
1001 1001
            // --- TaxonDescriptions
1002 1002
            for (Taxon t : taxa) {
......
1022 1022

  
1023 1023

  
1024 1024
        if(includeOccurrences != null && includeOccurrences) {
1025
            logger.trace("listMedia() - includeOccurrences");
1025
            if (logger.isTraceEnabled()){logger.trace("listMedia() - includeOccurrences");}
1026 1026
            @SuppressWarnings("rawtypes")
1027 1027
            Set<SpecimenOrObservationBase> specimensOrObservations = new HashSet<>();
1028 1028
            // --- Specimens
......
1061 1061
        }
1062 1062

  
1063 1063
        if(includeTaxonNameDescriptions != null && includeTaxonNameDescriptions) {
1064
            logger.trace("listMedia() - includeTaxonNameDescriptions");
1064
            if (logger.isTraceEnabled()){logger.trace("listMedia() - includeTaxonNameDescriptions");}
1065 1065
            // --- TaxonNameDescription
1066 1066
            Set<TaxonNameDescription> nameDescriptions = new HashSet<>();
1067 1067
            for (Taxon t : taxa) {
1068
                nameDescriptions .addAll(t.getName().getDescriptions());
1068
                nameDescriptions.addAll(t.getName().getDescriptions());
1069 1069
            }
1070 1070
            for(TaxonNameDescription nameDescription: nameDescriptions){
1071 1071
                if (!limitToGalleries || nameDescription.isImageGallery()) {
......
1082 1082
        logger.trace("listMedia() - initialize");
1083 1083
        beanInitializer.initializeAll(taxonMedia, propertyPath);
1084 1084

  
1085
        logger.trace("listMedia() - END");
1085
        if (logger.isTraceEnabled()){logger.trace("listMedia() - END");}
1086 1086

  
1087 1087
        return taxonMedia;
1088 1088
    }
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/applicationContext-test.xml
24 24
    <import resource="classpath:/eu/etaxonomy/cdm/persistence.xml" />
25 25
    <import resource="classpath:/eu/etaxonomy/cdm/services_base_test.xml"/>
26 26

  
27

  
28 27
    <!-- security  -->
29 28
    <bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder"/>
30 29
    <bean id="saltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource">

Also available in: Unified diff