Skip to content

Commit

Permalink
Remove unused upload and download properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Tara Drwenski committed Dec 19, 2022
1 parent 9e27ba2 commit 4f50ed7
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 160 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/tds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ jobs:
java-vendor: ${{ matrix.java-vendor }}
java-version: ${{ matrix.java-version }}
build-tool: 'gradlew'
test-command: '-Dtds.content.root.path=$CONTENT_DIR -Dtds.download.dir=$DOWNLOAD_DIR -Dtds.upload.dir=$UPLOAD_DIR -Dtds.test.gretty.container=${{ matrix.servletcontainer }} --info --stacktrace testAll'
test-command: '-Dtds.content.root.path=$CONTENT_DIR -Dtds.test.gretty.container=${{ matrix.servletcontainer }} --info --stacktrace testAll'
env:
CONTENT_DIR: ${{ github.workspace }}/tds/src/test/content
DOWNLOAD_DIR: '/tmp/download'
UPLOAD_DIR: '/tmp/upload'
- uses: actions/upload-artifact@v2
if: failure()
with:
Expand Down
5 changes: 0 additions & 5 deletions tds/src/main/java/thredds/core/DataRootManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public void afterPropertiesSet() throws Exception {
AliasTranslator.addAlias("content", StringUtils.cleanPath(file.getPath())); // LOOK
}

File uploaddir = tdsContext.getUploadDir();
if (uploaddir != null) {
AliasTranslator.addAlias("${tds.upload.dir}", StringUtils.cleanPath(uploaddir.getAbsolutePath()));
}

makeDebugActions();
startupLog.info("DataRootManager:" + AliasTranslator.size() + " aliases set ");
}
Expand Down
145 changes: 0 additions & 145 deletions tds/src/main/java/thredds/server/config/TdsContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ public final class TdsContext implements ServletContextAware, InitializingBean,
@Value("${tds.content.root.path}")
private String contentRootPathProperty; // wants a trailing slash

@Value("${tds.upload.dir}")
private String uploadDirProperty;

@Value("${tds.upload.form}")
private String uploadFormProperty;

@Value("${tds.download.dir}")
private String downloadDirProperty;

@Value("${tds.download.form}")
private String downloadFormProperty;

@Value("${tds.debug.flags:}") // :} indicates an empty string if tds.debugflags prop is not set
private String tdsDebugFlagsProperty; // space sep debug flags to enable

Expand All @@ -97,10 +85,6 @@ public final class TdsContext implements ServletContextAware, InitializingBean,
private File publicContentDirectory;
private File startupContentDirectory;
private File tomcatLogDir;
private File uploadDir = null;
private File downloadDir = null;
private File uploadForm = null;
private File downloadForm = null;

private FileSource publicContentDirSource;
// private FileSource catalogRootDirSource; // look for catalog files at this(ese) root(s)
Expand Down Expand Up @@ -252,13 +236,6 @@ public void afterPropertiesSet() {
// jspRequestDispatcher = servletContext.getNamedDispatcher("jsp");
defaultRequestDispatcher = servletContext.getNamedDispatcher("default");

////////////////////////////////

this.uploadDir = getPropertyDir(uploadDirProperty, "tds.upload.dir", true);
this.uploadForm = getPropertyFile(uploadFormProperty, "tds.upload.form", false);
this.downloadDir = getPropertyDir(downloadDirProperty, "tds.download.dir", true);
this.downloadForm = getPropertyFile(downloadFormProperty, "tds.download.form", false);

////////////////////////////////
// Copy default startup files, if necessary
////////////////////////////////
Expand Down Expand Up @@ -369,14 +346,6 @@ public String toString() {
sb.append("\n");
sb.append("\n servletRootDir= ").append(servletRootDirectory);
sb.append("\n contentRootDir= ").append(contentRootDir);
if (this.uploadDir != null)
sb.append("\n uploadDir= ").append(uploadDir);
if (this.uploadForm != null)
sb.append("\n uploadForm= ").append(uploadForm);
if (this.downloadDir != null)
sb.append("\n downloadDir= ").append(downloadDir);
if (this.downloadForm != null)
sb.append("\n downloadForm= ").append(downloadForm);
sb.append("\n threddsDirectory= ").append(threddsDirectory);
sb.append("\n publicContentDir= ").append(publicContentDirectory);
sb.append("\n startupContentDir=").append(startupContentDirectory);
Expand Down Expand Up @@ -479,22 +448,6 @@ public String getConfigFileProperty() {
return this.configFileProperty;
}

public File getUploadDir() {
return this.uploadDir;
}

public File getDownloadDir() {
return this.downloadDir;
}

public File getUploadForm() {
return uploadForm;
}

public File getDownloadForm() {
return downloadForm;
}

public String getTdsDebugFlags() {
return tdsDebugFlagsProperty;
}
Expand All @@ -506,102 +459,4 @@ public String getTdsDebugFlags() {
public void setContentRootPathProperty(String contentRootPathProperty) {
this.contentRootPathProperty = contentRootPathProperty;
}

public void setUploadDirProperty(String uploadDirProperty) {
this.uploadDirProperty = uploadDirProperty;
}

public void setDownloadDirProperty(String downloadDirProperty) {
this.downloadDirProperty = downloadDirProperty;
}

public void setUploadFormProperty(String uploadFormProperty) {
this.uploadFormProperty = uploadFormProperty;
}

public void setDownloadFormProperty(String downloadFormProperty) {
this.downloadFormProperty = downloadFormProperty;
}

public File getPropertyDir(String prop, String key, boolean create) {
assert prop != null && key != null;
// In applicationContext-tdsConfig.xml, we have ignoreUnresolvablePlaceholders set to "true".
// As a result, when properties aren't defined, they will keep their placeholder String.
// In this case, that's "${<key>}".
if (prop.equals("${" + key + "}")) {
String msg = String.format("\"%s\" property isn't defined.", key);
logServerStartup.warn("TdsContext.init(): " + msg);
return null;
}
prop = StringUtil2.replace(prop, "\\", "/");
if (!prop.endsWith("/"))
prop += "/";
// Set the content directory and source.
File dir = new File(prop);
if (!dir.isAbsolute()) {
String msg = String.format("\"%s=%s\" value must be an absolutepath.", key, prop);
logServerStartup.warn("TdsContext.init(): " + msg);
return null;
}
// Make sure dir exists and is read/writeable
if (!dir.exists() && create) {
if (!dir.mkdirs())
logServerStartup
.warn("TdsContext.init(): " + String.format("Directory: %s=%s could not be created.", key, prop));;
}
if (!dir.exists()) {
logServerStartup.warn("TdsContext.init(): " + String.format("Directory: %s=%s does not exist.", key, prop));
return null;
}
if (!dir.isDirectory()) {
logServerStartup.warn("TdsContext.init(): " + String.format("Directory: %s=%s is not a directory.", key, prop));
return null;
}
if (!dir.canRead() || !dir.canWrite()) {
logServerStartup
.warn("TdsContext.init(): " + String.format("Directory: %s=%s must be readable and writeable.", key, prop));
return null;
}
return dir;
}

public File getPropertyFile(String prop, String key, boolean writeable) {
assert prop != null && key != null;
// In applicationContext-tdsConfig.xml, we have ignoreUnresolvablePlaceholders set to "true".
// As a result, when properties aren't defined, they will keep their placeholder String.
// In this case, that's "${<key>}".
if (prop.equals("${" + key + "}")) {
String msg = String.format("\"%s\" property isn't defined.", key);
logServerStartup.warn("TdsContext.init(): " + msg);
return null;
}
prop = StringUtil2.replace(prop, "\\", "/");
if (!prop.endsWith("/"))
prop += "/";
// Set the content file and source.
File file = new File(prop);
if (!file.isAbsolute()) {
String msg = String.format("\"%s=%s\" value must be an absolutepath.", key, prop);
logServerStartup.warn("TdsContext.init(): " + msg);
return null;
}
// Make sure file exists and is readable and (optionally)writeable
if (!file.exists()) {
logServerStartup.warn("TdsContext.init(): " + String.format("Directory: %s=%s does not exist.", key, prop));
return null;
}
if (!file.isFile()) {
logServerStartup.warn("TdsContext.init(): " + String.format("File: %s=%s is not a file.", key, prop));
return null;
}
if (!file.canRead()) {
logServerStartup.warn("TdsContext.init(): " + String.format("File: %s=%s must be readable.", key, prop));
return null;
}
if (writeable && !file.canWrite()) {
logServerStartup.warn("TdsContext.init(): " + String.format("File: %s=%s must be writeable.", key, prop));
return null;
}
return file;
}
}
7 changes: 0 additions & 7 deletions tds/src/test/content/thredds/catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,4 @@
<!-- urls intended to test container auth without spring -->
<datasetRoot path="containerauth" location="content/testdata"/>

<datasetScan name="Uploaded Files" ID="upload"
location="${tds.upload.dir}" path="upload/">
<metadata inherited="true">
<serviceName>all</serviceName>
</metadata>
</datasetScan>

</catalog>

0 comments on commit 4f50ed7

Please sign in to comment.