Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 1340dddd75a7eb0a67b36f92ab6bf10d066332b0
Author: Jody Garnett <jody.garnett@gmail.com>
Date:   Thu May 19 16:57:11 2016 -0700

    class header because standards

commit dad7ea3359c728241f5fa1105131e70ebaf078ef
Author: Jody Garnett <jody.garnett@gmail.com>
Date:   Thu May 19 16:44:44 2016 -0700

    fix up headers

commit 43cbaea
Author: Niels Charlier <niels@scitus.be>
Date:   Thu May 19 13:38:13 2016 +0200

    Undo faulty serializable resources, Resources.serializable, fix DemoRequestPage and importer module
  • Loading branch information
jodygarnett committed May 20, 2016
1 parent ec76b46 commit ec95a8b
Show file tree
Hide file tree
Showing 28 changed files with 169 additions and 35 deletions.
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 - 2016 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down Expand Up @@ -140,9 +140,7 @@ public String toString() {
*
*/
protected class JDBCResource implements Resource {

private static final long serialVersionUID = 1829574259576354635L;


private final JDBCDirectoryStructure.Entry entry;

public JDBCResource(JDBCDirectoryStructure.Entry entry) {
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2001 - 2014 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* Copyright (c) 2015 OpenPlans - www.openplans.org. All rights reserved.
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
/* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
Expand All @@ -7,6 +7,7 @@

import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -28,7 +29,7 @@ public class FileData extends ImportData {
protected Resource file;

public FileData(Resource file) {
this.file = file;
this.file = Resources.serializable(file);
}

public FileData(FileData file) {
Expand Down
Expand Up @@ -82,15 +82,15 @@ public Resource getPrjFile() {
}

public void setPrjFile(Resource prjFile) {
this.prjFile = prjFile;
this.prjFile = Resources.serializable(prjFile);
}

public Resource getStyleFile() {
return styleFile;
}

public void setStyleFile(Resource styleFile) {
this.styleFile = styleFile;
this.styleFile = Resources.serializable(styleFile);
}

public List<Resource> getSuppFiles() {
Expand Down
Expand Up @@ -148,7 +148,6 @@ public String toString() {
* This implementation is a stateless data object, acting as a simple handle around a File.
*/
class FileSystemResource implements Resource {
private static final long serialVersionUID = 5824101017129479435L;

String path;

Expand Down
Expand Up @@ -39,7 +39,6 @@ public final class Files {
* in the data directory.
*/
static final class ResourceAdaptor implements Resource {
private static final long serialVersionUID = -3529072360389761648L;

final File file;

Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
/* (c) 2014-2015 Open Source Geospatial Foundation - all rights reserved
* (c) 2014 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
Expand All @@ -23,7 +23,6 @@ final class NullResourceStore implements ResourceStore {
@Override
public Resource get(final String resourcePath) {
return new Resource() {
private static final long serialVersionUID = -8613315438546471004L;

String path = resourcePath;

Expand Down
Expand Up @@ -20,7 +20,7 @@
* Resource creation is handled in a lazy fashion, simply use {@link #file()} or {@link #out()} and the resource will be created as required. In a
* similar fashion setting up a child resource will create any required parent directories.
*/
public interface Resource extends Serializable {
public interface Resource {
/**
* Enumeration indicating kind of resource used.
*/
Expand Down
Expand Up @@ -9,7 +9,9 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
Expand Down Expand Up @@ -79,6 +81,9 @@ public static boolean canRead(Resource resource) {
* @return true If resource is hidden
*/
public static boolean isHidden(Resource resource) {
if (resource instanceof SerializableResourceWrapper) {
resource = ((SerializableResourceWrapper) resource).delegate;
}
if (resource instanceof FileSystemResourceStore.FileSystemResource ||
resource instanceof Files.ResourceAdaptor) {
//this is a file based resource, just check the file
Expand Down Expand Up @@ -676,4 +681,129 @@ public OutputStream getOutputStream() throws IOException {
}
}

/**
* Resource wrapper, serialization using resource path.
*/
private static class SerializableResourceWrapper implements Serializable, Resource {
private static final long serialVersionUID = 1758097257412707071L;

private transient Resource delegate;
private String path;

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
delegate = Resources.fromPath(path);
}

public SerializableResourceWrapper(Resource delegate) {
this.delegate = delegate;
path = delegate.path();
}

@Override
public String path() {
return path;
}

@Override
public String name() {
return delegate.name();
}

@Override
public Lock lock() {
return delegate.lock();
}

@Override
public void addListener(ResourceListener listener) {
delegate.addListener(listener);
}

@Override
public void removeListener(ResourceListener listener) {
delegate.removeListener(listener);
}

@Override
public InputStream in() {
return delegate.in();
}

@Override
public OutputStream out() {
return delegate.out();
}

@Override
public File file() {
return delegate.file();
}

@Override
public File dir() {
return delegate.dir();
}

@Override
public long lastmodified() {
return delegate.lastmodified();
}

@Override
public Resource parent() {
return new SerializableResourceWrapper(delegate.parent());
}

@Override
public Resource get(String resourcePath) {
return delegate.get(resourcePath);
}

@Override
public List<Resource> list() {
List<Resource> children = new ArrayList<Resource>();
for (Resource child : delegate.list()) {
children.add(new SerializableResourceWrapper(child));
}
return children;
}

@Override
public Type getType() {
return delegate.getType();
}

@Override
public boolean delete() {
return delegate.delete();
}

@Override
public boolean renameTo(Resource dest) {
return delegate.renameTo(dest);
}

@Override
public boolean equals(Object o) {
if (!(o instanceof SerializableResourceWrapper)) {
return false;
}
return delegate.equals(((SerializableResourceWrapper) o).delegate);
}

@Override
public int hashCode() {
return delegate.hashCode();
}

}

public static Resource serializable(Resource resource) {
if (resource instanceof Serializable) {
return resource;
}
return new SerializableResourceWrapper(resource);
}

}
@@ -1,4 +1,4 @@
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
/* (c) 2015-2016 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
Expand Down Expand Up @@ -27,7 +27,6 @@ public final class URIs {
private URIs() {}

static class ResourceAdaptor implements Resource {
private static final long serialVersionUID = 4002509659099083614L;

private URL url;

Expand Down
Expand Up @@ -40,6 +40,7 @@
import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.platform.GeoServerResourceLoader;
import org.geoserver.platform.resource.Resource;
import org.geoserver.platform.resource.Resources;
import org.geoserver.platform.resource.Resource.Type;
import org.geoserver.web.GeoServerApplication;
import org.geoserver.web.GeoServerBasePage;
Expand All @@ -59,7 +60,7 @@ public class DemoRequestsPage extends GeoServerBasePage {

private static final Logger LOGGER = Logging.getLogger("org.geoserver.web.demo");

private final Resource demoDir;
final Resource demoDir;

private TextField urlTextField;

Expand All @@ -72,7 +73,7 @@ public class DemoRequestsPage extends GeoServerBasePage {
public DemoRequestsPage() {
try {
GeoServerResourceLoader loader = this.getGeoServer().getCatalog().getResourceLoader();
demoDir = loader.get("demo");
demoDir = Resources.serializable(loader.get("demo"));
} catch (Exception e) {
throw new WicketRuntimeException("Can't access demo requests directory: "
+ e.getMessage());
Expand All @@ -89,7 +90,7 @@ public DemoRequestsPage() {
* @param demoDir
*/
DemoRequestsPage(final Resource demoDir) {
this.demoDir = demoDir;
this.demoDir = Resources.serializable(demoDir);
DemoRequest model = new DemoRequest(demoDir.path());
setDefaultModel(new Model(model));
setUpDemoRequestsForm(demoDir);
Expand Down

0 comments on commit ec95a8b

Please sign in to comment.