Skip to content

Commit

Permalink
Move versioning table on top of creative commons section, removed
Browse files Browse the repository at this point in the history
unnecessary if, restyling jsp
  • Loading branch information
Pascarelli Luigi Andrea committed Oct 18, 2013
1 parent 7886088 commit 1e43695
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 170 deletions.
12 changes: 6 additions & 6 deletions dspace-api/src/main/resources/Messages.properties
Expand Up @@ -1689,8 +1689,8 @@ jsp.version.version-summary.submit_version = Version
jsp.dspace-admin.version-summary.text = Reason for creating new version

jsp.version.history.delete.success.message = Ok, version/versions has been removed
jsp.version.history.delete.warning.head1 = Confirm Deletion(s)\\n
jsp.version.history.delete.warning.para1 = Are you sure you want to delete these versions?\\n
jsp.version.history.delete.warning.head1 = Confirm Deletion(s)
jsp.version.history.delete.warning.para1 = Are you sure you want to delete these versions?
jsp.version.history.delete.warning.para2 = PLEASE NOTE: That by deleting these versions, the associated items will no longer be accessible.

jsp.version.history.title = Version History
Expand All @@ -1700,15 +1700,15 @@ jsp.version.history.column2 = Item
jsp.version.history.column3 = Editor
jsp.version.history.column4 = Date
jsp.version.history.column5 = Summary
jsp.version.history.column6 = Actions
jsp.version.history.restore = Restore
jsp.version.history.update = Update
jsp.version.history.legend = *Selected version
jsp.version.history.update = Edit
jsp.version.history.legend = <span class="glyphicon glyphicon-asterisk"></span> Selected version
jsp.version.history.delete = Delete Versions
jsp.version.history.return = Return
jsp.version.history.popup.delete = Yes
jsp.version.history.popup.close = No

jsp.version.notice.new_version_head = Notice
jsp.version.notice.new_version_help = This is not the latest version of this item. The latest version can be found at:
jsp.version.notice.workflow_version_head = Notice
jsp.version.notice.workflow_version_help = A more recent version of this item is in the Workflow.
#End Versioning
@@ -0,0 +1,128 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.webui.components;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.dspace.app.webui.util.VersionUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.content.Item;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.handle.HandleManager;
import org.dspace.plugin.ItemHomeProcessor;
import org.dspace.plugin.PluginException;
import org.dspace.versioning.Version;
import org.dspace.versioning.VersionHistory;

public class VersioningItemHome implements ItemHomeProcessor {

/** log4j category */
private static Logger log = Logger.getLogger(VersioningItemHome.class);

@Override
public void process(Context context, HttpServletRequest request,
HttpServletResponse response, Item item) throws PluginException,
AuthorizeException {
boolean versioningEnabled = ConfigurationManager.getBooleanProperty(
"versioning", "enabled");
boolean newVersionAvailable = false;
boolean showVersionWorkflowAvailable = false;
boolean hasVersionButton = false;
boolean hasVersionHistory = false;

VersionHistory history = null;
List<Version> historyVersions = new ArrayList<Version>();
String latestVersionHandle = null;
String latestVersionURL = null;
if (versioningEnabled) {
try {
if(item.canEdit()) {
if (VersionUtil.isLatest(context, item) && item.isArchived()) {
hasVersionButton = true;
}
}
} catch (SQLException e) {
throw new PluginException(e.getMessage());
}

if (VersionUtil.hasVersionHistory(context, item)) {
hasVersionHistory = true;
history = VersionUtil.retrieveVersionHistory(context, item);
for(Version versRow : history.getVersions()) {

//Skip items currently in submission
try {
if(VersionUtil.isItemInSubmission(context, versRow.getItem()))
{
continue;
}
else {
historyVersions.add(versRow);
}
} catch (SQLException e) {
throw new PluginException(e.getMessage());
}
}
}

// Check if we have a history for the item
Version latestVersion;
try {
latestVersion = VersionUtil.checkLatestVersion(context, item);
} catch (SQLException e) {
throw new PluginException(e.getMessage());
}

if (latestVersion != null) {
if (latestVersion != null
&& latestVersion.getItemID() != item.getID()) {
// We have a newer version
Item latestVersionItem = latestVersion.getItem();
if (latestVersionItem.isArchived()) {
// Available, add a link for the user alerting him that
// a new version is available
newVersionAvailable = true;
try {
latestVersionURL = HandleManager.resolveToURL(
context, latestVersionItem.getHandle());
} catch (SQLException e) {
throw new PluginException(e.getMessage());
}
latestVersionHandle = latestVersionItem.getHandle();
} else {
// We might be dealing with a workflow/workspace item
showVersionWorkflowAvailable = true;
}
}
}
}

request.setAttribute("versioning.enabled", versioningEnabled);
request.setAttribute("versioning.hasversionbutton", hasVersionButton);
request.setAttribute("versioning.hasversionhistory", hasVersionHistory);
request.setAttribute("versioning.history", history);
request.setAttribute("versioning.historyversions", historyVersions);
request.setAttribute("versioning.newversionavailable",
newVersionAvailable);
request.setAttribute("versioning.showversionwfavailable",
showVersionWorkflowAvailable);
request.setAttribute("versioning.latestversionhandle",
latestVersionHandle);
request.setAttribute("versioning.latestversionurl", latestVersionURL);

}

}
Expand Up @@ -47,8 +47,11 @@ protected void doDSGet(Context context, HttpServletRequest request,

Item item = Item.find(context, itemID);

if (item == null
|| !AuthorizeManager.isAdmin(context,
if (item == null) {
throw new IllegalArgumentException("Item is null");
}

if(!AuthorizeManager.isAdmin(context,
item.getOwningCollection()))
{
// Check if only administrators can view the item history
Expand Down

0 comments on commit 1e43695

Please sign in to comment.