diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java index 564713c0a..c29dd2fcc 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; @@ -44,6 +45,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash; +import edu.cornell.mannlib.vitro.webapp.filestorage.FileModelHelper; import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils; import edu.cornell.mannlib.vitro.webapp.utils.StringUtils; @@ -157,8 +159,10 @@ public class PropertyEditLinks extends TagSupport{ ObjectPropertyStatement prop = new ObjectPropertyStatementImpl(subjectUri, predicateUri, data); links = doObjPropStmt( prop, policyToAccess(ids, policy, prop), contextPath ); } - } - else { + } else if (VitroVocabulary.IND_MAIN_IMAGE.equals(predicateUri)) { + + links = doImageLinks(entity, ids, policy, contextPath); + } else { log.error("PropertyEditLinks cannot make links for an object of type " + predicateUri); return SKIP_BODY; } @@ -234,18 +238,14 @@ public class PropertyEditLinks extends TagSupport{ if( contains( allowedAccessTypeArray, EditLinkAccess.ADDNEW ) ){ log.debug("vitro namespace property "+propertyUri+" gets an \"add\" link"); LinkStruct ls = null; - if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) { - ls = getImageLink(subjectUri, contextPath, "add"); - } else { - String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp", - "subjectUri", subjectUri, - "predicateUri", propertyUri, - "vitroNsProp", "true"); - ls = new LinkStruct(); - ls.setHref( url ); - ls.setType("add"); - ls.setMouseoverText("add a new entry"); - } + String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp", + "subjectUri", subjectUri, + "predicateUri", propertyUri, + "vitroNsProp", "true"); + ls = new LinkStruct(); + ls.setHref( url ); + ls.setType("add"); + ls.setMouseoverText("add a new entry"); links[0] = ls; } else { log.debug("no add link generated for vitro namespace property "+propertyUri); @@ -345,17 +345,6 @@ public class PropertyEditLinks extends TagSupport{ LinkStruct[] links = new LinkStruct[2]; - if (predicateUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) { - if( contains( allowedAccessTypeArray, EditLinkAccess.MODIFY ) ){ - log.debug("permission found to UPDATE vitro namepsace property statement "+ predicateUri); - links[0] = getImageLink(subjectUri, contextPath, "edit"); - return links; - } - else { - log.debug("NO permission found to DELETE vitro namespace property " + predicateUri); - } - } - String value = dpropStmt.getData(); Model model = (Model)pageContext.getServletContext().getAttribute("jenaOntModel"); @@ -479,6 +468,53 @@ public class PropertyEditLinks extends TagSupport{ return links; } + protected LinkStruct[] doImageLinks(Individual entity, + IdentifierBundle ids, PolicyIface policy, String contextPath) { + Individual mainImage = FileModelHelper.getMainImage(entity); + + String subjectUri = entity.getURI(); + String predicateUri = VitroVocabulary.IND_MAIN_IMAGE; + + if (mainImage == null) { + EditLinkAccess[] accesses = policyToAccess(ids, policy, subjectUri, + predicateUri); + + if (contains(accesses, EditLinkAccess.ADDNEW)) { + log.debug("permission to ADD main image to " + subjectUri); + return new LinkStruct[] { getImageLink(subjectUri, contextPath, + "edit", "upload an image") }; + } else { + log.debug("NO permission to ADD main image to " + subjectUri); + return empty_array; + } + } else { + ObjectPropertyStatement prop = new ObjectPropertyStatementImpl( + subjectUri, predicateUri, mainImage.getURI()); + EditLinkAccess[] allowedAccessTypeArray = policyToAccess(ids, + policy, prop); + + List links = new ArrayList(); + if (contains(allowedAccessTypeArray, EditLinkAccess.MODIFY)) { + log.debug("permission to MODIFY main image to " + subjectUri); + links.add(getImageLink(subjectUri, contextPath, "edit", + "replace this image")); + } else { + log.debug("NO permission to MODIFY main image to " + + subjectUri); + } + + if (contains(allowedAccessTypeArray, EditLinkAccess.DELETE)) { + log.debug("permission to DELETE main image to " + subjectUri); + links.add(getImageLink(subjectUri, contextPath, "delete", + "delete this image")); + } else { + log.debug("NO permission to DELETE main image to " + + subjectUri); + } + return links.toArray(new LinkStruct[links.size()]); + } + } + /* ********************* utility methods ********************************* */ protected static String makeRelativeHref( String baseUrl, String ... queries ) { @@ -636,15 +672,16 @@ public class PropertyEditLinks extends TagSupport{ private LinkStruct[] empty_array = {}; - private LinkStruct getImageLink(String subjectUri, String contextPath, String action) { - LinkStruct ls = new LinkStruct(); - String url = makeRelativeHref(contextPath + "uploadimages.jsp", - "entityUri", subjectUri); - ls.setHref(url); - ls.setType(action); - ls.setMouseoverText("upload a new image"); - return ls; - } + private LinkStruct getImageLink(String subjectUri, String contextPath, + String action, String mouseOverText) { + LinkStruct ls = new LinkStruct(); + String url = makeRelativeHref(contextPath + "uploadimages.jsp", + "entityUri", subjectUri); + ls.setHref(url); + ls.setType(action); + ls.setMouseoverText(mouseOverText); + return ls; + } private String getObjPropMouseoverLabel(String propertyUri) { String mouseoverText = "relationship"; // default diff --git a/webapp/web/images/dummyImages/person.thumbnail.jpg b/webapp/web/images/dummyImages/person.thumbnail.jpg new file mode 100644 index 000000000..dea174dd9 Binary files /dev/null and b/webapp/web/images/dummyImages/person.thumbnail.jpg differ diff --git a/webapp/web/templates/entity/entityBasic.jsp b/webapp/web/templates/entity/entityBasic.jsp index 862961093..94bd7d5c3 100644 --- a/webapp/web/templates/entity/entityBasic.jsp +++ b/webapp/web/templates/entity/entityBasic.jsp @@ -76,6 +76,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L +
@@ -186,38 +187,53 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L <%-- Thumbnail (with citation) --%> - -
- - -

image

- -
- + " /> + + + + + +
+

image

+ ${imageLinks} +
+
+
+ +
-
- - - - - - - - - - ${editLinks} - +
+ + + ${imageLinks} +
- - <%-- Citation --%> - - - -
- +
+
+ <%-- hasImage --%> +
+
+
+
+ + + + + ${imageLinks} + +
+
+
+
+ +
+
<%-- Description --%>