Project

General

Profile

« Previous | Next » 

Revision fc09bcdb

Added by Cherian Mathew almost 7 years ago

#5000 Use new metadata service

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
52 52
import eu.etaxonomy.cdm.api.service.IIdentificationKeyService;
53 53
import eu.etaxonomy.cdm.api.service.ILocationService;
54 54
import eu.etaxonomy.cdm.api.service.IMediaService;
55
import eu.etaxonomy.cdm.api.service.IMetadataService;
55 56
import eu.etaxonomy.cdm.api.service.INameService;
56 57
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
57 58
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
......
105 106

  
106 107
    private ICdmRemoteSource remoteSource;
107 108

  
108
    private Map serviceMap = new HashMap<Class<IService>, IService>();
109
    private static Map serviceMap = new HashMap<Class<IService>, IService>();
109 110

  
110 111
    private ICdmEntitySessionManager cdmEntitySessionManager;
111 112

  
......
119 120

  
120 121
    public CdmApplicationRemoteConfiguration(ICdmRemoteSource remoteSource) {
121 122
        this.remoteSource = remoteSource;
123
        serviceMap.clear();
122 124
    }
123 125

  
124 126
    public void setRemoteSource(ICdmRemoteSource remoteSource) {
......
126 128
    }
127 129

  
128 130
    private Object getService(Class<?> clazz, String serviceSuffix, CdmAuthenticatedHttpInvokerRequestExecutor executor) {
131
        return getService(clazz, serviceSuffix, remoteSource, executor);
132
    }
133

  
134
    public static Object getService(Class<?> clazz, String serviceSuffix, ICdmRemoteSource remoteSource, CdmAuthenticatedHttpInvokerRequestExecutor executor) {
129 135
        if(serviceMap.containsKey(clazz)) {
130 136
            return serviceMap.get(clazz);
131 137
        }
......
292 298
        return (IUserService) getService(IUserService.class, "/remoting-public/user.service", new CdmServiceRequestExecutor());
293 299
    }
294 300

  
301
    @Override
302
    public IMetadataService getMetadataService() {
303
        return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", new CdmServiceRequestExecutor());
304
    }
305

  
306
    public static IMetadataService getMetadataService(ICdmRemoteSource remoteSource) {
307
        return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", remoteSource, new CdmServiceRequestExecutor());
308
    }
309

  
295 310
    @Override
296 311
    public IGrantedAuthorityService getGrantedAuthorityService(){
297 312
        return (IGrantedAuthorityService) getService(IGrantedAuthorityService.class, "/remoting/grantedauthority.service", new CdmServiceRequestExecutor());
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmPersistentRemoteSource.java
84 84
			checkProperties(cdmSourceProperties);
85 85
		} else {
86 86
			throw new CdmRemoteSourceException("Remote source '" + remoteSource + "' does not exist in settings file");
87
		}
88
		initDatabaseConnection();
89 87
	}
90 88

  
91 89
	private static void checkProperties(Properties cdmSourceProperties) throws CdmRemoteSourceException {
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmRemoteSourceBase.java
10 10

  
11 11
import java.util.Map;
12 12

  
13
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
14

  
15
import eu.etaxonomy.cdm.api.service.IUserService;
13
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration;
14
import eu.etaxonomy.cdm.api.service.IMetadataService;
16 15
import eu.etaxonomy.cdm.config.CdmSource;
17 16
import eu.etaxonomy.cdm.config.CdmSourceException;
18 17
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;
......
34 33
	private String contextPath;
35 34
	private String baseUrl;
36 35

  
37
	private IUserService userService;
36
	private IMetadataService metadataService;
38 37

  
39 38
	/**
40 39
	 * Constructs a CdmRemoteSourceBase object with default values.
......
63 62
		setPort(port);
64 63
		setContextPath(contextPath);
65 64
		setNomenclaturalCode(nomenclaturalCode);
66
		initDatabaseConnection();
65
		metadataService = CdmApplicationRemoteConfiguration.getMetadataService(this);
67 66
	}
68 67

  
69
	protected void initDatabaseConnection() {
70
		if(getContextPath() == null || getContextPath().equals("")) {
71
			setBaseUrl("http://" + getServer() + ":" + String.valueOf(getPort()));
72
		} else {
73
			setBaseUrl("http://" + getServer()  + ":" + String.valueOf(getPort()) + "/" + getContextPath());
74
		}
75
		// the database service needs to be initialised (before the spring
76
		// application context initialsation) since it is required to
77
		// to make queries related to the source database
78
	    HttpInvokerProxyFactoryBean proxy = new HttpInvokerProxyFactoryBean();
79
	    proxy.setServiceInterface(IUserService.class);
80
	    // FIXME:Remoting need to fix this hardcoded url and make it configurable somehow
81
	    proxy.setServiceUrl(baseUrl + "/remoting-public/user.service");
82
	    proxy.afterPropertiesSet();
83
	    userService = (IUserService) proxy.getObject();
84

  
85
	}
86 68

  
87 69
	/* (non-Javadoc)
88 70
	 * @see eu.etaxonomy.cdm.remote.ICdmRemoteSource#getBaseUrl()
......
128 110
	 */
129 111
	@Override
130 112
	public String getDbSchemaVersion() throws CdmSourceException {
131
		return userService.getDbSchemaVersion();
113
		return metadataService.getDbSchemaVersion();
132 114

  
133 115
	}
134 116

  
......
137 119
	 */
138 120
	@Override
139 121
	public boolean isDbEmpty() throws CdmSourceException {
140
		return userService.isDbEmpty();
122
		return metadataService.isDbEmpty();
141 123

  
142 124
	}
143 125

  
......
151 133
		// if no exception is thrown then we assume that the
152 134
		// connection is up
153 135
		// FIXME:Remoting is this really correct?
154
		userService.getDbSchemaVersion();
136
		metadataService.getDbSchemaVersion();
155 137

  
156 138
		return true;
157 139
	}
......
167 149

  
168 150
	@Override
169 151
	public Map<MetaDataPropertyName, String> getMetaDataMap() throws CdmSourceException {
170
		return userService.getCdmMetadataMap();
152
		return metadataService.getCdmMetadataMap();
171 153
	}
172 154

  
173 155

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientCdmRepository.java
33 33
import eu.etaxonomy.cdm.api.service.IIdentificationKeyService;
34 34
import eu.etaxonomy.cdm.api.service.ILocationService;
35 35
import eu.etaxonomy.cdm.api.service.IMediaService;
36
import eu.etaxonomy.cdm.api.service.IMetadataService;
36 37
import eu.etaxonomy.cdm.api.service.INameService;
37 38
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
38 39
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
......
427 428
    public IProgressMonitorService getProgressMonitorService() {
428 429
        return defaultApplicationConfiguration.getProgressMonitorService();
429 430
    }
431

  
432
    /**
433
     * {@inheritDoc}
434
     */
435
    @Override
436
    public IMetadataService getMetadataService() {
437
        return defaultApplicationConfiguration.getMetadataService();
438
    }
430 439
}

Also available in: Unified diff