Merge branch 'maint-rel-1.7' of https://github.com/vivo-project/Vitro into maint-rel-1.7

This commit is contained in:
Tim Worrall 2014-06-18 14:24:44 -04:00
commit 6ddb6336ca
4 changed files with 20 additions and 14 deletions

View file

@ -16,7 +16,7 @@
<auth:status rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ACTIVE</auth:status>
<auth:loginCount rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1</auth:loginCount>
<auth:passwordLinkExpires rdf:datatype="http://www.w3.org/2001/XMLSchema#long">0</auth:passwordLinkExpires>
<auth:hasPermissionSet rdf:resource="http://permissionSet-50"/>
<auth:hasPermissionSet rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/authorization#ADMIN"/>
</auth:UserAccount>
<auth:UserAccount rdf:about="http://vivo.mydomain.edu/individual/JohnCurator">
@ -28,7 +28,7 @@
<auth:status rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ACTIVE</auth:status>
<auth:loginCount rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1</auth:loginCount>
<auth:passwordLinkExpires rdf:datatype="http://www.w3.org/2001/XMLSchema#long">0</auth:passwordLinkExpires>
<auth:hasPermissionSet rdf:resource="http://permissionSet-5"/>
<auth:hasPermissionSet rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/authorization#CURATOR"/>
</auth:UserAccount>
<auth:UserAccount rdf:about="http://vivo.mydomain.edu/individual/SallyEditor">
@ -40,7 +40,7 @@
<auth:status rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ACTIVE</auth:status>
<auth:loginCount rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1</auth:loginCount>
<auth:passwordLinkExpires rdf:datatype="http://www.w3.org/2001/XMLSchema#long">0</auth:passwordLinkExpires>
<auth:hasPermissionSet rdf:resource="http://permissionSet-4"/>
<auth:hasPermissionSet rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/authorization#EDITOR"/>
</auth:UserAccount>
<auth:UserAccount rdf:about="http://vivo.mydomain.edu/individual/JoeUser">
@ -52,7 +52,7 @@
<auth:status rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ACTIVE</auth:status>
<auth:loginCount rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1</auth:loginCount>
<auth:passwordLinkExpires rdf:datatype="http://www.w3.org/2001/XMLSchema#long">0</auth:passwordLinkExpires>
<auth:hasPermissionSet rdf:resource="http://permissionSet-1"/>
<auth:hasPermissionSet rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/authorization#SELF_EDITOR"/>
</auth:UserAccount>
</rdf:RDF>

View file

@ -18,8 +18,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.logging.Log;
@ -188,7 +189,7 @@ public class MultipartRequestWrapper extends HttpServletRequestWrapper {
ParsingStrategy strategy) throws IOException {
try {
return upload.parseRequest(req);
} catch (FileSizeLimitExceededException e) {
} catch (FileSizeLimitExceededException | SizeLimitExceededException e) {
if (strategy.stashFileSizeException()) {
req.setAttribute(ATTRIBUTE_FILE_SIZE_EXCEPTION, e);
return Collections.emptyList();

View file

@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -285,10 +285,14 @@ public class VitroRequest extends HttpServletRequestWrapper {
return getFileSizeException() != null;
}
public FileSizeLimitExceededException getFileSizeException() {
/**
* Could be either FileSizeLimitExceededException or
* SizeLimitExceededException, so return their common ancestor.
*/
public FileUploadException getFileSizeException() {
Object e = getAttribute(ATTRIBUTE_FILE_SIZE_EXCEPTION);
if (e instanceof FileSizeLimitExceededException) {
return (FileSizeLimitExceededException) e;
if (e instanceof FileUploadException) {
return (FileUploadException) e;
} else {
return null;
}

View file

@ -188,12 +188,13 @@ public class ImageUploadController extends FreemarkerHttpServlet {
*/
@Override
protected ResponseValues processRequest(VitroRequest vreq) {
Individual entity = null;
try {
entity = validateEntityUri(vreq);
checkForFileTooBigException(vreq);
String action = vreq.getParameter(PARAMETER_ACTION);
Individual entity = validateEntityUri(vreq);
if (ACTION_UPLOAD.equals(action)) {
return doUploadImage(vreq, entity);
} else if (ACTION_SAVE.equals(action)) {
@ -208,8 +209,8 @@ public class ImageUploadController extends FreemarkerHttpServlet {
return doIntroScreen(vreq, entity);
}
} catch (UserMistakeException e) {
// Can't find the entity? Complain.
return showAddImagePageWithError(vreq, null, e.formatMessage(vreq));
// Can't find the entity? Image too large? Complain.
return showAddImagePageWithError(vreq, entity, e.formatMessage(vreq));
} catch (Exception e) {
// We weren't expecting this - log it, and apologize to the user.
return new ExceptionResponseValues(e);