Skip to content

Commit

Permalink
DS-2701 JSPUI: initial refactoring
Browse files Browse the repository at this point in the history
still missing JSP, tag library, submission controller/servelet and
administrative servlets
  • Loading branch information
Andrea Bollini committed Sep 10, 2015
1 parent 8326e64 commit 6693f28
Show file tree
Hide file tree
Showing 50 changed files with 1,087 additions and 1,620 deletions.
Expand Up @@ -26,6 +26,7 @@
public interface GroupService extends DSpaceObjectService<Group>, DSpaceObjectLegacySupportService<Group> {

public static final int NAME = 1; // sort by NAME (default)
public static final int ANONYMOUS_ID = 0;


/**
Expand Down
Expand Up @@ -7,7 +7,8 @@
*/
package org.dspace.app.webui.components;

import org.apache.commons.lang.ArrayUtils;
import java.util.List;

import org.dspace.content.Item;


Expand All @@ -21,17 +22,17 @@
public class RecentSubmissions
{
/** The set of items being represented */
private Item[] items;
private List<Item> items;

/**
* Construct a new RecentSubmissions object to represent the passed
* array of items
*
* @param items
*/
public RecentSubmissions(Item[] items)
public RecentSubmissions(List<Item> items)
{
this.items = (Item[]) ArrayUtils.clone(items);
this.items = items;
}

/**
Expand All @@ -41,17 +42,17 @@ public RecentSubmissions(Item[] items)
*/
public int count()
{
return items.length;
return items.size();
}

/**
* Obtain the array of items
*
* @return an array of items
*/
public Item[] getRecentSubmissions()
public List<Item> getRecentSubmissions()
{
return (Item[])ArrayUtils.clone(items);
return items;
}

/**
Expand All @@ -64,9 +65,9 @@ public Item[] getRecentSubmissions()
*/
public Item getRecentSubmission(int i)
{
if (i < items.length)
if (i < items.size())
{
return items[i];
return items.get(i);
}
else
{
Expand Down
Expand Up @@ -7,19 +7,20 @@
*/
package org.dspace.app.webui.components;

import org.dspace.core.Context;
import org.dspace.content.DSpaceObject;
import java.util.List;

import org.apache.log4j.Logger;
import org.dspace.browse.BrowseEngine;
import org.dspace.browse.BrowserScope;
import org.dspace.browse.BrowseException;
import org.dspace.browse.BrowseIndex;
import org.dspace.browse.BrowseInfo;
import org.dspace.browse.BrowseException;
import org.dspace.sort.SortOption;
import org.dspace.sort.SortException;
import org.dspace.core.ConfigurationManager;
import org.dspace.browse.BrowserScope;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;

import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.sort.SortException;
import org.dspace.sort.SortOption;

/**
* Class that obtains recent submissions to DSpace containers.
Expand Down Expand Up @@ -88,7 +89,7 @@ public RecentSubmissions getRecentSubmissions(DSpaceObject dso)

BrowseInfo results = be.browseMini(bs);

Item[] items = results.getItemResults(context);
List<Item> items = results.getResults();

RecentSubmissions rs = new RecentSubmissions(items);

Expand Down
Expand Up @@ -8,12 +8,15 @@
package org.dspace.app.webui.components;

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

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

import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Community;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CommunityService;
import org.dspace.core.Context;
import org.dspace.plugin.PluginException;
import org.dspace.plugin.SiteHomeProcessor;
Expand All @@ -28,13 +31,15 @@
public class TopCommunitiesSiteProcessor implements SiteHomeProcessor
{

private CommunityService communityService;

/**
* blank constructor - does nothing.
*
*/
public TopCommunitiesSiteProcessor()
{

communityService = ContentServiceFactory.getInstance().getCommunityService();
}

@Override
Expand All @@ -43,10 +48,10 @@ public void process(Context context, HttpServletRequest request,
AuthorizeException
{
// Get the top communities to shows in the community list
Community[] communities;
List<Community> communities;
try
{
communities = Community.findAllTop(context);
communities = communityService.findAllTop(context);
}
catch (SQLException e)
{
Expand Down
Expand Up @@ -18,9 +18,12 @@
import org.dspace.app.webui.util.VersionUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Item;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.handle.HandleServiceImpl;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.plugin.ItemHomeProcessor;
import org.dspace.plugin.PluginException;
import org.dspace.versioning.Version;
Expand All @@ -31,6 +34,15 @@ public class VersioningItemHome implements ItemHomeProcessor {
/** log4j category */
private static Logger log = Logger.getLogger(VersioningItemHome.class);

private ItemService itemService;

private HandleService handleService;

public VersioningItemHome() {
handleService = HandleServiceFactory.getInstance().getHandleService();
itemService = ContentServiceFactory.getInstance().getItemService();
}

@Override
public void process(Context context, HttpServletRequest request,
HttpServletResponse response, Item item) throws PluginException,
Expand All @@ -48,7 +60,7 @@ public void process(Context context, HttpServletRequest request,
String latestVersionURL = null;
if (versioningEnabled) {
try {
if(item.canEdit()) {
if(itemService.canEdit(context, item)) {
if (VersionUtil.isLatest(context, item) && item.isArchived()) {
hasVersionButton = true;
}
Expand Down Expand Up @@ -86,16 +98,16 @@ public void process(Context context, HttpServletRequest request,
}

if (latestVersion != null) {
if (latestVersion != null
&& latestVersion.getItemID() != item.getID()) {
if (latestVersion != null && latestVersion.getItem() != null
&& latestVersion.getItem().getID().equals(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 = HandleServiceImpl.resolveToURL(
latestVersionURL = handleService.resolveToURL(
context, latestVersionItem.getHandle());
} catch (SQLException e) {
throw new PluginException(e.getMessage());
Expand Down
Expand Up @@ -32,13 +32,14 @@
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
import org.dspace.discovery.configuration.DiscoverySortConfiguration;
import org.dspace.discovery.configuration.DiscoverySortFieldConfiguration;
import org.dspace.handle.HandleServiceImpl;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;

public class DiscoverUtility
{
/** log4j category */
private static Logger log = Logger.getLogger(DiscoverUtility.class);

public static final int TYPE_FACETS = 1;
public static final int TYPE_TAGCLOUD = 2;

Expand Down Expand Up @@ -68,7 +69,8 @@ public static DSpaceObject getSearchScope(Context context,
}
return null;
}
DSpaceObject scope = HandleServiceImpl.resolveToObject(context, location);
HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
DSpaceObject scope = handleService.resolveToObject(context, location);
return scope;
}

Expand Down

0 comments on commit 6693f28

Please sign in to comment.