mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-23 20:43:53 +00:00
moved interface containing the clearState method to SSE; will add it to SecurityService as well; clearing servlet already finds all implementing services
This commit is contained in:
1 parent
619a801f3e
commit
6fecb642a4
8 files changed
+54
-59
No files matched your search
@@ -16,4 +16,5 @@ Require-Bundle: org.junit4;bundle-version="4.8.2",
|
|||||||
com.sap.sse.common,
|
com.sap.sse.common,
|
||||||
org.mockito.mockito-core;bundle-version="1.9.5",
|
org.mockito.mockito-core;bundle-version="1.9.5",
|
||||||
org.objenesis;bundle-version="1.3.0",
|
org.objenesis;bundle-version="1.3.0",
|
||||||
org.hamcrest;bundle-version="1.1.0"
|
org.hamcrest;bundle-version="1.1.0",
|
||||||
|
com.sap.sse
|
||||||
@@ -10,7 +10,8 @@ Require-Bundle: javax.servlet;bundle-version="2.6.0",
|
|||||||
com.sap.sailing.domain.common;bundle-version="1.0.0",
|
com.sap.sailing.domain.common;bundle-version="1.0.0",
|
||||||
com.sap.sailing.server;bundle-version="1.0.0",
|
com.sap.sailing.server;bundle-version="1.0.0",
|
||||||
com.sap.sse.mongodb;bundle-version="1.0.0",
|
com.sap.sse.mongodb;bundle-version="1.0.0",
|
||||||
com.sap.sse.common
|
com.sap.sse.common,
|
||||||
|
com.sap.sse
|
||||||
Bundle-ClassPath: .
|
Bundle-ClassPath: .
|
||||||
Web-ContextPath: /sailingserver/test-support
|
Web-ContextPath: /sailingserver/test-support
|
||||||
Import-Package: org.osgi.framework,
|
Import-Package: org.osgi.framework,
|
||||||
|
|||||||
+33
-36
@@ -12,62 +12,59 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
|
|
||||||
import com.sap.sailing.server.test.support.RacingEventServiceWithTestSupport;
|
|
||||||
import com.sap.sse.mongodb.MongoDBConfiguration;
|
import com.sap.sse.mongodb.MongoDBConfiguration;
|
||||||
import com.sap.sse.mongodb.MongoDBService;
|
import com.sap.sse.mongodb.MongoDBService;
|
||||||
|
import com.sap.sse.util.ClearStateTestSupport;
|
||||||
|
|
||||||
public class ClearStateServlet extends HttpServlet {
|
public class ClearStateServlet extends HttpServlet {
|
||||||
private static final long serialVersionUID = -880795218153271730L;
|
private static final long serialVersionUID = -880795218153271730L;
|
||||||
|
|
||||||
private static final String OSGI_BUNDLECONTEXT_ATTRIBUTE_NAME = "osgi-bundlecontext";
|
private static final String OSGI_BUNDLECONTEXT_ATTRIBUTE_NAME = "osgi-bundlecontext";
|
||||||
|
|
||||||
private static String TEST_DB_NAME = "winddbTest";
|
private static String TEST_DB_NAME = "winddbTest";
|
||||||
|
|
||||||
private ServiceTracker<RacingEventServiceWithTestSupport, RacingEventServiceWithTestSupport> racingEventTracker;
|
private ServiceTracker<ClearStateTestSupport, ClearStateTestSupport> racingEventTracker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ServletConfig config) throws ServletException {
|
public void init(ServletConfig config) throws ServletException {
|
||||||
super.init(config);
|
super.init(config);
|
||||||
|
|
||||||
ServletContext servletContext = config.getServletContext();
|
ServletContext servletContext = config.getServletContext();
|
||||||
BundleContext bundleContext = (BundleContext) servletContext.getAttribute(OSGI_BUNDLECONTEXT_ATTRIBUTE_NAME);
|
BundleContext bundleContext = (BundleContext) servletContext.getAttribute(OSGI_BUNDLECONTEXT_ATTRIBUTE_NAME);
|
||||||
|
this.racingEventTracker = new ServiceTracker<>(bundleContext,
|
||||||
this.racingEventTracker = new ServiceTracker<>(bundleContext, RacingEventServiceWithTestSupport.class.getName(), null);
|
ClearStateTestSupport.class.getName(), null);
|
||||||
this.racingEventTracker.open();
|
this.racingEventTracker.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if(this.racingEventTracker != null) {
|
if (this.racingEventTracker != null) {
|
||||||
this.racingEventTracker.close();
|
this.racingEventTracker.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
|
||||||
throws ServletException, IOException {
|
IOException {
|
||||||
MongoDBConfiguration configuration = MongoDBService.INSTANCE.getConfiguration();
|
MongoDBConfiguration configuration = MongoDBService.INSTANCE.getConfiguration();
|
||||||
String databaseName = configuration.getDatabaseName();
|
String databaseName = configuration.getDatabaseName();
|
||||||
|
if (TEST_DB_NAME.equals(databaseName)) {
|
||||||
if(TEST_DB_NAME.equals(databaseName)) {
|
try {
|
||||||
try {
|
ClearStateTestSupport[] services = getClearStateTestSupportServices();
|
||||||
RacingEventServiceWithTestSupport racingEventService = getRacingEventService();
|
for (ClearStateTestSupport service : services) {
|
||||||
racingEventService.clearState();
|
service.clearState();
|
||||||
|
}
|
||||||
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
|
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, exception.getMessage());
|
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, exception.getMessage());
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
return;
|
}
|
||||||
}
|
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Database " + databaseName
|
||||||
|
+ " is not the database for testing!");
|
||||||
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Database " + databaseName + " is not the database for testing!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RacingEventServiceWithTestSupport getRacingEventService() {
|
private ClearStateTestSupport[] getClearStateTestSupportServices() {
|
||||||
return this.racingEventTracker.getService();
|
return this.racingEventTracker.getServices(new ClearStateTestSupport[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,5 @@ Export-Package: com.sap.sailing.server,
|
|||||||
com.sap.sailing.domain.racelogtrackingadapter.test",
|
com.sap.sailing.domain.racelogtrackingadapter.test",
|
||||||
com.sap.sailing.server.masterdata,
|
com.sap.sailing.server.masterdata,
|
||||||
com.sap.sailing.server.operationaltransformation,
|
com.sap.sailing.server.operationaltransformation,
|
||||||
com.sap.sailing.server.racelog.tracking,
|
com.sap.sailing.server.racelog.tracking
|
||||||
com.sap.sailing.server.test.support;
|
|
||||||
x-friends:="com.sap.sailing.server.gateway.test.support"
|
|
||||||
|
|
||||||
@@ -27,9 +27,9 @@ import com.sap.sailing.domain.tracking.impl.GPSFixMovingImpl;
|
|||||||
import com.sap.sailing.server.RacingEventService;
|
import com.sap.sailing.server.RacingEventService;
|
||||||
import com.sap.sailing.server.RacingEventServiceMXBean;
|
import com.sap.sailing.server.RacingEventServiceMXBean;
|
||||||
import com.sap.sailing.server.racelog.tracking.CachedOsgiTypeBasedServiceFinderFactory;
|
import com.sap.sailing.server.racelog.tracking.CachedOsgiTypeBasedServiceFinderFactory;
|
||||||
import com.sap.sailing.server.test.support.RacingEventServiceWithTestSupport;
|
|
||||||
import com.sap.sse.common.Util;
|
import com.sap.sse.common.Util;
|
||||||
import com.sap.sse.replication.Replicable;
|
import com.sap.sse.replication.Replicable;
|
||||||
|
import com.sap.sse.util.ClearStateTestSupport;
|
||||||
|
|
||||||
public class Activator implements BundleActivator {
|
public class Activator implements BundleActivator {
|
||||||
private static final Logger logger = Logger.getLogger(Activator.class.getName());
|
private static final Logger logger = Logger.getLogger(Activator.class.getName());
|
||||||
@@ -72,7 +72,7 @@ public class Activator implements BundleActivator {
|
|||||||
replicableServiceProperties.put(Replicable.OSGi_Service_Registry_ID_Property_Name, racingEventService.getId().toString());
|
replicableServiceProperties.put(Replicable.OSGi_Service_Registry_ID_Property_Name, racingEventService.getId().toString());
|
||||||
context.registerService(Replicable.class.getName(), racingEventService, replicableServiceProperties);
|
context.registerService(Replicable.class.getName(), racingEventService, replicableServiceProperties);
|
||||||
context.registerService(RacingEventService.class.getName(), racingEventService, null);
|
context.registerService(RacingEventService.class.getName(), racingEventService, null);
|
||||||
context.registerService(RacingEventServiceWithTestSupport.class.getName(), racingEventService, null);
|
context.registerService(ClearStateTestSupport.class.getName(), racingEventService, null);
|
||||||
|
|
||||||
Dictionary<String, String> properties = new Hashtable<String, String>();
|
Dictionary<String, String> properties = new Hashtable<String, String>();
|
||||||
properties.put(TypeBasedServiceFinder.TYPE, GPSFixImpl.class.getName());
|
properties.put(TypeBasedServiceFinder.TYPE, GPSFixImpl.class.getName());
|
||||||
|
|||||||
+2
-2
@@ -182,7 +182,6 @@ import com.sap.sailing.server.operationaltransformation.UpdateStartTimeReceived;
|
|||||||
import com.sap.sailing.server.operationaltransformation.UpdateTrackedRaceStatus;
|
import com.sap.sailing.server.operationaltransformation.UpdateTrackedRaceStatus;
|
||||||
import com.sap.sailing.server.operationaltransformation.UpdateWindAveragingTime;
|
import com.sap.sailing.server.operationaltransformation.UpdateWindAveragingTime;
|
||||||
import com.sap.sailing.server.operationaltransformation.UpdateWindSourcesToExclude;
|
import com.sap.sailing.server.operationaltransformation.UpdateWindSourcesToExclude;
|
||||||
import com.sap.sailing.server.test.support.RacingEventServiceWithTestSupport;
|
|
||||||
import com.sap.sailing.util.impl.LockUtil;
|
import com.sap.sailing.util.impl.LockUtil;
|
||||||
import com.sap.sailing.util.impl.NamedReentrantReadWriteLock;
|
import com.sap.sailing.util.impl.NamedReentrantReadWriteLock;
|
||||||
import com.sap.sse.BuildVersion;
|
import com.sap.sse.BuildVersion;
|
||||||
@@ -195,9 +194,10 @@ import com.sap.sse.common.search.ResultImpl;
|
|||||||
import com.sap.sse.replication.OperationExecutionListener;
|
import com.sap.sse.replication.OperationExecutionListener;
|
||||||
import com.sap.sse.replication.OperationWithResult;
|
import com.sap.sse.replication.OperationWithResult;
|
||||||
import com.sap.sse.replication.ReplicationMasterDescriptor;
|
import com.sap.sse.replication.ReplicationMasterDescriptor;
|
||||||
|
import com.sap.sse.util.ClearStateTestSupport;
|
||||||
import com.sap.sse.replication.impl.OperationWithResultWithIdWrapper;
|
import com.sap.sse.replication.impl.OperationWithResultWithIdWrapper;
|
||||||
|
|
||||||
public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport, RegattaListener, LeaderboardRegistry,
|
public class RacingEventServiceImpl implements RacingEventService, ClearStateTestSupport, RegattaListener, LeaderboardRegistry,
|
||||||
Replicator {
|
Replicator {
|
||||||
private static final Logger logger = Logger.getLogger(RacingEventServiceImpl.class.getName());
|
private static final Logger logger = Logger.getLogger(RacingEventServiceImpl.class.getName());
|
||||||
|
|
||||||
|
|||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
package com.sap.sailing.server.test.support;
|
|
||||||
|
|
||||||
import com.sap.sailing.server.RacingEventService;
|
|
||||||
|
|
||||||
public interface RacingEventServiceWithTestSupport extends RacingEventService {
|
|
||||||
/**
|
|
||||||
* Wipes out the complete state. This method is only used or testing.
|
|
||||||
*
|
|
||||||
* Note: Simple properties like the time delay to the 'live' timepoint are not reseted.
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
void clearState() throws Exception;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.sap.sse.util;
|
||||||
|
|
||||||
|
public interface ClearStateTestSupport {
|
||||||
|
/**
|
||||||
|
* Wipes out the complete state. This method is only used or testing. This also clears the persistent state
|
||||||
|
* accordingly which differs from the {@link Replicable#clearReplicaState()} operation which doesn't care about the
|
||||||
|
* persistent state.
|
||||||
|
*
|
||||||
|
* Note: Simple properties like the time delay to the 'live' time point are not reset.
|
||||||
|
*/
|
||||||
|
void clearState() throws Exception;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user