@Override public void collect(Map<String, Object> storage) { PublishedInfo pi = LocalPublished.get(); storage.put(KEY, pi); }
public void mangleURL( StringBuilder baseURL, StringBuilder path, Map<String, String> kvp, URLType type) { if (type == URLType.SERVICE && stripRemainingPath(path.toString()).equalsIgnoreCase(ows)) { if (LocalWorkspace.get() != null) { path.insert(0, LocalWorkspace.get().getName() + "/"); if (LocalPublished.get() != null) { int i = LocalWorkspace.get().getName().length() + 1; path.insert(i, LocalPublished.get().getName() + "/"); } } } } }
public boolean hideLayer(LayerInfo layer) { PublishedInfo local = LocalPublished.get(); if (local == null) { return false; } else if (local instanceof LayerInfo) { return !local.equals(layer); } else if (local instanceof LayerGroupInfo) { LayerGroupInfo lg = (LayerGroupInfo) local; Request request = Dispatcher.REQUEST.get(); if (request != null && "WMS".equalsIgnoreCase(request.getService()) && "GetCapabilities".equals(request.getRequest()) && lg.getMode() == Mode.SINGLE) { return true; } else { return !new LayerGroupHelper(lg).allLayers().contains(layer); } } else { throw new RuntimeException("Unknown PublishedInfo of type " + local.getClass()); } }
@Override void assertThreadLocalApplied() { assertSame(layer, LocalPublished.get()); } });
public Service serviceDispatched(Request request, Service service) throws ServiceException { if (LocalWorkspace.get() != null) { qualifyRequest(LocalWorkspace.get(), LocalPublished.get(), service, request); } return service; }
public Operation operationDispatched(Request request, Operation operation) { if (LocalWorkspace.get() != null) { qualifyRequest(LocalWorkspace.get(), LocalPublished.get(), operation, request); } return operation; }
@Override void assertThreadLocalCleaned() { assertNull(LocalPublished.get()); }
public boolean hideResource(ResourceInfo resource) { if (LocalPublished.get() != null) { for (LayerInfo l : resource.getCatalog().getLayers(resource)) { if (hideLayer(l)) { return true; } } } return hideWorkspace(resource.getStore().getWorkspace()); }
@Override public boolean hideLayerGroup(LayerGroupInfo layerGroup) { PublishedInfo local = LocalPublished.get(); if (local != null) { if (local instanceof LayerGroupInfo) {
private void testCleanup() { transfer.cleanup(); // check all thread locals have been cleaned up from the current // thread assertNull(Dispatcher.REQUEST.get()); assertNull(AdminRequest.get()); assertNull(LocalPublished.get()); assertNull(LocalWorkspace.get()); assertNull(SecurityContextHolder.getContext().getAuthentication()); } });
private void testApply() { transfer.apply(); // check all thread locals have been applied to the current thread assertSame(request, Dispatcher.REQUEST.get()); assertSame(myState, AdminRequest.get()); assertSame(layer, LocalPublished.get()); assertSame(ws, LocalWorkspace.get()); assertSame( auth, SecurityContextHolder.getContext().getAuthentication()); }
@Override public Filter getSecurityFilter(final Class<? extends CatalogInfo> clazz) { WorkspaceInfo localWS = LocalWorkspace.get(); PublishedInfo localPublished = LocalPublished.get(); if (localWS == null && localPublished == null) { return Predicates.acceptAll();
@Test public void testInitRequest_LayerGroupExists() { this.request.setContext("LayerGroup1/ows"); this.callback.init(this.request); assertNull(LocalWorkspace.get()); assertNotNull(LocalPublished.get()); }
@Test public void testInitRequest_WorkspacedLayerGroupExists() { this.request.setContext("cite/LayerGroup2/ows"); this.callback.init(this.request); assertNotNull(LocalWorkspace.get()); assertNotNull(LocalPublished.get()); }
@Test public void testInitRequest_LayerExists() { this.request.setContext("cite/BasicPolygons/ows"); this.callback.init(this.request); assertNotNull(LocalWorkspace.get()); assertNotNull(LocalPublished.get()); }
@Test public void testInitRequest_LayerMissing() { this.request.setContext("cite/MissingLayer/ows"); this.callback.init(this.request); assertNotNull(LocalWorkspace.get()); assertNull(LocalPublished.get()); }
@Test public void testInitRequest_WorkspacedLayerGroupMissing() { this.request.setContext("cite/lg/ows"); this.callback.init(this.request); assertNotNull(LocalWorkspace.get()); assertNull(LocalPublished.get()); }
@Test public void testInitRequest_WorkspaceExists() { this.request.setContext("cite/ows"); this.callback.init(this.request); assertNotNull(LocalWorkspace.get()); assertNull(LocalPublished.get()); }
@Test public void testInitRequest_LayerMissingInWorkspace() { this.request.setContext("cite/Fifteen/ows"); this.callback.init(this.request); assertNotNull(LocalWorkspace.get()); assertNull(LocalPublished.get()); }