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: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: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: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>
<auth:UserAccount rdf:about="http://vivo.mydomain.edu/individual/JohnCurator"> <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: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: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: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>
<auth:UserAccount rdf:about="http://vivo.mydomain.edu/individual/SallyEditor"> <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: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: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: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>
<auth:UserAccount rdf:about="http://vivo.mydomain.edu/individual/JoeUser"> <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: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: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: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> </auth:UserAccount>
</rdf:RDF> </rdf:RDF>

View file

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

View file

@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.commons.fileupload.FileItem; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -285,10 +285,14 @@ public class VitroRequest extends HttpServletRequestWrapper {
return getFileSizeException() != null; 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); Object e = getAttribute(ATTRIBUTE_FILE_SIZE_EXCEPTION);
if (e instanceof FileSizeLimitExceededException) { if (e instanceof FileUploadException) {
return (FileSizeLimitExceededException) e; return (FileUploadException) e;
} else { } else {
return null; return null;
} }

View file

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