diff --git a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/generic/XmlEditorBean.java b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/generic/XmlEditorBean.java index f7e55efc58b..29e044686f4 100644 --- a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/generic/XmlEditorBean.java +++ b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/generic/XmlEditorBean.java @@ -58,6 +58,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.xerces.xni.parser.XMLParseException; +import org.deegree.commons.config.DeegreeWorkspace; import org.deegree.commons.xml.schema.SchemaValidationEvent; import org.deegree.commons.xml.schema.SchemaValidator; import org.deegree.services.controller.OGCFrontController; @@ -159,6 +160,29 @@ public void setNextView(String nextView) { this.nextView = nextView; } + private File getFile() { + File workspaceRoot = new File(DeegreeWorkspace.getWorkspaceRoot()); + + final String platformFileName; + if (!File.separator.equals("/")) { + StringBuilder sb = new StringBuilder(); + + String separator = ""; + for (String filePart : fileName.split("/")) { + sb.append(separator); + sb.append(filePart); + + separator = File.separator; + } + platformFileName = sb.toString(); + } + else { + platformFileName = fileName; + } + + return new File(workspaceRoot, platformFileName); + } + public String getContent() throws IOException, ClassNotFoundException { LOG.trace("Editing file: " + getFileName() + " with ID + " + getId()); LOG.trace("Using schema: " + getSchemaUrl()); @@ -168,7 +192,7 @@ public String getContent() throws IOException, ClassNotFoundException { if (content == null) { LOG.trace("No content set for " + this.toString()); if (resourceProviderClass == null) { - File file = new File(fileName); + File file = getFile(); if (fileName != null && file.exists()) { LOG.trace("Loading content from file: " + file.getAbsolutePath()); content = FileUtils.readFileToString(file); @@ -257,7 +281,7 @@ private ResourceManager lookupResourceManager(Workspace workspace, Class c private void activate() { try { if (resourceProviderClass == null) { - FileUtils.write(new File(fileName), content); + FileUtils.write(getFile(), content); return; } diff --git a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/proxy/ProxyBean.java b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/proxy/ProxyBean.java index 454f5ba1669..7e8049297e8 100644 --- a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/proxy/ProxyBean.java +++ b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/proxy/ProxyBean.java @@ -27,16 +27,11 @@ ----------------------------------------------------------------------------*/ package org.deegree.console.proxy; -import java.io.File; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; -import org.deegree.commons.config.DeegreeWorkspace; import org.deegree.commons.proxy.ProxySettings; /** @@ -47,12 +42,7 @@ public class ProxyBean { public ProxyConfig getProxyConfig() throws IOException { - Path workspaceDir = Paths.get(DeegreeWorkspace.getWorkspaceRoot()); - File proxyFile = new File(workspaceDir.toFile(), "proxy.xml"); - if (!proxyFile.exists()) { - proxyFile.createNewFile(); - } - return new ProxyConfig(proxyFile.getAbsolutePath()); + return new ProxyConfig(); } public String getNonftpProxyHosts() { diff --git a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/proxy/ProxyConfig.java b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/proxy/ProxyConfig.java index 93391e097de..501547b18f5 100644 --- a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/proxy/ProxyConfig.java +++ b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/proxy/ProxyConfig.java @@ -45,11 +45,8 @@ public class ProxyConfig extends Config { private static final URL PROXY_EXAMPLE_URL = ProxyConfig.class.getResource("/META-INF/schemas/proxy/example.xml"); - private String file; - - public ProxyConfig(String file) { + public ProxyConfig() { super(null, null, "/console/proxy/index", false); - this.file = file; } @Override @@ -57,7 +54,7 @@ public String edit() throws IOException { StringBuilder sb = new StringBuilder("/console/generic/xmleditor?faces-redirect=true"); sb.append("&id=").append(id); sb.append("&schemaUrl=").append(PROXY_SCHEMA_URL.toString()); - sb.append("&fileName=").append(file); + sb.append("&fileName=proxy.xml"); sb.append("&nextView=").append(getResourceOutcome()); sb.append("&emptyTemplate=").append(getTemplate()); return sb.toString(); diff --git a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/webservices/MainConfig.java b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/webservices/MainConfig.java index 052d2aa0fc4..5c0d0c0e160 100644 --- a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/webservices/MainConfig.java +++ b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/webservices/MainConfig.java @@ -33,6 +33,7 @@ import org.apache.commons.io.IOUtils; import org.deegree.console.Config; +import org.deegree.services.controller.OGCFrontController; /** * Config implementation for the main.xml. @@ -47,23 +48,19 @@ public class MainConfig extends Config implements Serializable { private static final URL MAIN_SCHEMA_URL = ServicesBean.class .getResource("/META-INF/schemas/services/controller/controller.xsd"); - private String file; - public MainConfig() { super(null, null, "/console/webservices/index", false); } - public MainConfig(String file) { - super(null, null, "/console/webservices/index", false); - this.file = file; - } - @Override public String edit() throws IOException { + String workspaceName = OGCFrontController.getServiceWorkspace().getName(); + String fileName = workspaceName + "/services/main.xml"; + StringBuilder sb = new StringBuilder("/console/generic/xmleditor?faces-redirect=true"); sb.append("&id=").append(id); sb.append("&schemaUrl=").append(MAIN_SCHEMA_URL.toString()); - sb.append("&fileName=").append(file); + sb.append("&fileName=").append(fileName); sb.append("&emptyTemplate=").append(getTemplate()); sb.append("&nextView=").append(getResourceOutcome()); return sb.toString(); diff --git a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/webservices/ServicesBean.java b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/webservices/ServicesBean.java index 16126978e12..145e48f6c2a 100644 --- a/deegree-services/deegree-webservices/src/main/java/org/deegree/console/webservices/ServicesBean.java +++ b/deegree-services/deegree-webservices/src/main/java/org/deegree/console/webservices/ServicesBean.java @@ -27,7 +27,6 @@ ----------------------------------------------------------------------------*/ package org.deegree.console.webservices; -import java.io.File; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; @@ -39,10 +38,7 @@ import org.deegree.console.AbstractResourceManagerBean; import org.deegree.console.Config; import org.deegree.services.OwsManager; -import org.deegree.services.controller.OGCFrontController; import org.deegree.workspace.ResourceMetadata; -import org.deegree.workspace.Workspace; -import org.deegree.workspace.standard.DefaultWorkspace; /** * TODO add class documentation here @@ -55,16 +51,11 @@ public class ServicesBean extends AbstractResourceManagerBean implem private static final long serialVersionUID = -8669333203479413121L; - private Config mainConfig; + private final Config mainConfig; public ServicesBean() { super(OwsManager.class); - Workspace workspace = OGCFrontController.getServiceWorkspace().getNewWorkspace(); - if (workspace instanceof DefaultWorkspace) { - File file = new File(((DefaultWorkspace) workspace).getLocation(), "services"); - file = new File(file, "main.xml"); - mainConfig = new MainConfig(file.getAbsolutePath()); - } + mainConfig = new MainConfig(); } public Config getMainConfig() {