Skip to content

Commit

Permalink
#26 add max download size and related configs, clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Nov 30, 2015
1 parent 78ff598 commit 322b225
Show file tree
Hide file tree
Showing 23 changed files with 358 additions and 146 deletions.
2 changes: 2 additions & 0 deletions etc/irods-ext/irods-webdav.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ default.starting.location=USER_HOME
provided.starting.location.path=
cache.file.demographics=true
utilize.packing.streams=true
max.upload.in.gb=5
max.download.in.gb=700
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@
provided.starting.location.path=
cache.file.demographics=true
utilize.packing.streams=true
max.upload.in.gb=6
max.download.in.gb=700
</echo>
</tasks>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class AuthWrapper implements DiscretePrincipal {

/*
* (non-Javadoc)
*
*
* @see io.milton.principal.Principal#getIdenitifer()
*/
@Override
Expand All @@ -37,7 +37,7 @@ public PrincipleId getIdenitifer() {

/*
* (non-Javadoc)
*
*
* @see io.milton.resource.Resource#authenticate(java.lang.String,
* java.lang.String)
*/
Expand All @@ -48,7 +48,7 @@ public Object authenticate(final String arg0, final String arg1) {

/*
* (non-Javadoc)
*
*
* @see io.milton.resource.Resource#authorise(io.milton.http.Request,
* io.milton.http.Request.Method, io.milton.http.Auth)
*/
Expand All @@ -60,7 +60,7 @@ public boolean authorise(final Request arg0, final Method arg1,

/*
* (non-Javadoc)
*
*
* @see io.milton.resource.Resource#checkRedirect(io.milton.http.Request)
*/
@Override
Expand All @@ -71,7 +71,7 @@ public String checkRedirect(final Request arg0)

/*
* (non-Javadoc)
*
*
* @see io.milton.resource.Resource#getModifiedDate()
*/
@Override
Expand All @@ -81,7 +81,7 @@ public Date getModifiedDate() {

/*
* (non-Javadoc)
*
*
* @see io.milton.resource.Resource#getName()
*/
@Override
Expand All @@ -91,7 +91,7 @@ public String getName() {

/*
* (non-Javadoc)
*
*
* @see io.milton.resource.Resource#getRealm()
*/
@Override
Expand All @@ -101,7 +101,7 @@ public String getRealm() {

/*
* (non-Javadoc)
*
*
* @see io.milton.resource.Resource#getUniqueId()
*/
@Override
Expand All @@ -111,7 +111,7 @@ public String getUniqueId() {

/*
* (non-Javadoc)
*
*
* @see io.milton.principal.DiscretePrincipal#getPrincipalURL()
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public BasicAuthFilter() {

/*
* (non-Javadoc)
*
*
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
@Override
Expand All @@ -52,14 +52,14 @@ public void init(final FilterConfig filterConfig) throws ServletException {

/*
* (non-Javadoc)
*
*
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
* javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(final ServletRequest request,
final ServletResponse response, final FilterChain chain)
throws IOException, ServletException {
throws IOException, ServletException {

log.debug("doFilter()");

Expand Down Expand Up @@ -107,7 +107,7 @@ private void sendAuthError(final HttpServletResponse httpResponse)

/*
* (non-Javadoc)
*
*
* @see javax.servlet.Filter#destroy()
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void destroy() {
@Override
public void doFilter(final ServletRequest request,
final ServletResponse response, final FilterChain chain)
throws IOException, ServletException {
throws IOException, ServletException {

chain.doFilter(request, response);
log.debug("closing iRODS connection after filter processing");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public IrodsPrincipleId(final String irodsAccountAsString) {

/*
* (non-Javadoc)
*
*
* @see io.milton.principal.Principal.PrincipleId#getIdType()
*/
@Override
Expand All @@ -35,7 +35,7 @@ public QName getIdType() {

/*
* (non-Javadoc)
*
*
* @see io.milton.principal.Principal.PrincipleId#getValue()
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static String basicAuthTokenFromIRODSAccount(
*/
public static UserAndPassword getAccountFromBasicAuthValues(
final String basicAuthData, final WebDavConfig webDavConfig)
throws JargonException {
throws JargonException {

log.debug("getIRODSAccountFromBasicAuthValues");

Expand Down
92 changes: 60 additions & 32 deletions src/main/java/org/irods/jargon/webdav/config/WebDavConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ public class WebDavConfig {
private String defaultStorageResource = "";
private String authScheme = AuthScheme.STANDARD.getTextValue();
private String realm = "irods";

/**
* Maximum upload size in Gb
*/
private long maxUploadInGb = 5;

/**
* Maximum download size in Gb
*/
private long maxDownloadInGb = 5;

/**
* Use an optimization to cache file data (length, etc) preventing requery
* of file data, may cause stale data issues
Expand Down Expand Up @@ -123,57 +134,44 @@ public void setAuthScheme(final String authScheme) {

/*
* (non-Javadoc)
*
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WebDavConfig [");
if (host != null) {
builder.append("host=");
builder.append(host);
builder.append(", ");
builder.append("host=").append(host).append(", ");
}
if (zone != null) {
builder.append("zone=");
builder.append(zone);
builder.append(", ");
builder.append("zone=").append(zone).append(", ");
}
builder.append("port=");
builder.append(port);
builder.append(", ");
builder.append("port=").append(port).append(", ");
if (defaultStorageResource != null) {
builder.append("defaultStorageResource=");
builder.append(defaultStorageResource);
builder.append(", ");
builder.append("defaultStorageResource=")
.append(defaultStorageResource).append(", ");
}
if (authScheme != null) {
builder.append("authScheme=");
builder.append(authScheme);
builder.append(", ");
builder.append("authScheme=").append(authScheme).append(", ");
}
if (realm != null) {
builder.append("realm=");
builder.append(realm);
builder.append(", ");
builder.append("realm=").append(realm).append(", ");
}
builder.append("cacheFileDemographics=");
builder.append(cacheFileDemographics);
builder.append(", ");
builder.append("maxUploadInGb=").append(maxUploadInGb)
.append(", maxDownloadInGb=").append(maxDownloadInGb)
.append(", cacheFileDemographics=")
.append(cacheFileDemographics).append(", ");
if (defaultStartingLocationEnum != null) {
builder.append("defaultStartingLocationEnum=");
builder.append(defaultStartingLocationEnum);
builder.append(", ");
builder.append("defaultStartingLocationEnum=")
.append(defaultStartingLocationEnum).append(", ");
}
if (providedDefaultStartingLocation != null) {
builder.append("providedDefaultStartingLocation=");
builder.append(providedDefaultStartingLocation);
builder.append(", ");
builder.append("providedDefaultStartingLocation=")
.append(providedDefaultStartingLocation).append(", ");
}
builder.append("usePackingStreams=");
builder.append(usePackingStreams);
builder.append("]");
builder.append("usePackingStreams=").append(usePackingStreams)
.append("]");
return builder.toString();
}

Expand Down Expand Up @@ -250,8 +248,38 @@ public boolean isUsePackingStreams() {
* @param usePackingStreams
* the usePackingStreams to set
*/
public void setUsePackingStreams(boolean usePackingStreams) {
public void setUsePackingStreams(final boolean usePackingStreams) {
this.usePackingStreams = usePackingStreams;
}

/**
* @return the maxUploadInGb
*/
public long getMaxUploadInGb() {
return maxUploadInGb;
}

/**
* @param maxUploadInGb
* the maxUploadInGb to set
*/
public void setMaxUploadInGb(final long maxUploadInGb) {
this.maxUploadInGb = maxUploadInGb;
}

/**
* @return the maxDownloadInGb
*/
public long getMaxDownloadInGb() {
return maxDownloadInGb;
}

/**
* @param maxDownloadInGb
* the maxDownloadInGb to set
*/
public void setMaxDownloadInGb(final long maxDownloadInGb) {
this.maxDownloadInGb = maxDownloadInGb;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.irods.jargon.webdav.exception;

import org.irods.jargon.core.exception.JargonRuntimeException;

/**
* File size exceeds a configured maximum
*
* @author Mike Conway - DICE
*
*/
public class FileSizeExceedsMaximumException extends JargonRuntimeException {

private static final long serialVersionUID = 124144366850943280L;

public FileSizeExceedsMaximumException(final String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
*/
public abstract class BaseResource implements Resource, MoveableResource,
CopyableResource, LockableResource {
CopyableResource, LockableResource {

private IRODSAccessObjectFactory irodsAccessObjectFactory;
private WebDavConfig webDavConfig;
Expand Down Expand Up @@ -260,7 +260,7 @@ public boolean authorise(final Request request, final Method method,

/*
* (non-Javadoc)
*
*
* @see io.milton.resource.Resource#getRealm()
*/
@Override
Expand Down
Loading

0 comments on commit 322b225

Please sign in to comment.