mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
DS-3004: Fixed unit tests, license check and unused parameters
This commit is contained in:
@@ -318,7 +318,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
Group g = groupService.create(context);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
groupService.setName(context, g,
|
||||
groupService.setName(g,
|
||||
"COLLECTION_" + collection.getID() + "_WORKFLOW_STEP_" + step);
|
||||
groupService.update(context, g);
|
||||
setWorkflowGroup(collection, step, g);
|
||||
@@ -396,7 +396,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
submitters = groupService.create(context);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
groupService.setName(context, submitters,
|
||||
groupService.setName(submitters,
|
||||
"COLLECTION_" + collection.getID() + "_SUBMIT");
|
||||
groupService.update(context, submitters);
|
||||
}
|
||||
@@ -437,7 +437,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
admins = groupService.create(context);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
groupService.setName(context, admins, "COLLECTION_" + collection.getID() + "_ADMIN");
|
||||
groupService.setName(admins, "COLLECTION_" + collection.getID() + "_ADMIN");
|
||||
groupService.update(context, admins);
|
||||
}
|
||||
|
||||
@@ -689,6 +689,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
Group g = collection.getWorkflowStep1();
|
||||
if (g != null)
|
||||
{
|
||||
collection.setWorkflowStep1(null);
|
||||
groupService.delete(context, g);
|
||||
}
|
||||
|
||||
@@ -696,6 +697,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
|
||||
if (g != null)
|
||||
{
|
||||
collection.setWorkflowStep2(null);
|
||||
groupService.delete(context, g);
|
||||
}
|
||||
|
||||
@@ -703,6 +705,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
|
||||
if (g != null)
|
||||
{
|
||||
collection.setWorkflowStep3(null);
|
||||
groupService.delete(context, g);
|
||||
}
|
||||
|
||||
@@ -711,6 +714,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
|
||||
if (g != null)
|
||||
{
|
||||
collection.setAdmins(null);
|
||||
groupService.delete(context, g);
|
||||
}
|
||||
|
||||
@@ -719,6 +723,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
|
||||
if (g != null)
|
||||
{
|
||||
collection.setSubmitters(null);
|
||||
groupService.delete(context, g);
|
||||
}
|
||||
|
||||
|
@@ -270,7 +270,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
admins = groupService.create(context);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
groupService.setName(context, admins, "COMMUNITY_" + community.getID() + "_ADMIN");
|
||||
groupService.setName(admins, "COMMUNITY_" + community.getID() + "_ADMIN");
|
||||
groupService.update(context, admins);
|
||||
}
|
||||
|
||||
|
@@ -7,19 +7,7 @@
|
||||
*/
|
||||
package org.dspace.content.packager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
@@ -42,6 +30,17 @@ import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Create EPersons and Groups from a file of external representations.
|
||||
*
|
||||
@@ -356,7 +355,7 @@ public class RoleIngester implements PackageIngester
|
||||
}
|
||||
|
||||
// Always set the name: parent.createBlop() is guessing
|
||||
groupService.setName(context, groupObj, name);
|
||||
groupService.setName(groupObj, name);
|
||||
|
||||
log.info("Created Group {}.", groupObj.getName());
|
||||
}
|
||||
|
@@ -202,9 +202,9 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
}
|
||||
|
||||
/** Change the name of this Group. */
|
||||
void setName(Context context, String name) throws SQLException
|
||||
void setName(String name) throws SQLException
|
||||
{
|
||||
if(!StringUtils.equals(this.name, name)) {
|
||||
if(!StringUtils.equals(this.name, name) && !isPermanent()) {
|
||||
this.name = name;
|
||||
groupsChanged = true;
|
||||
}
|
||||
|
@@ -91,7 +91,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(Context context, Group group, String name) throws SQLException {
|
||||
public void setName(Group group, String name) throws SQLException {
|
||||
if (group.isPermanent())
|
||||
{
|
||||
log.error("Attempt to rename permanent Group {} to {}.",
|
||||
@@ -99,7 +99,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
|
||||
throw new SQLException("Attempt to rename a permanent Group");
|
||||
}
|
||||
else
|
||||
group.setName(context, name);
|
||||
group.setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -415,7 +415,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
|
||||
if(anonymousGroup==null)
|
||||
{
|
||||
anonymousGroup = groupService.create(context);
|
||||
anonymousGroup.setName(context, Group.ANONYMOUS);
|
||||
anonymousGroup.setName(Group.ANONYMOUS);
|
||||
anonymousGroup.setPermanent(true);
|
||||
groupService.update(context, anonymousGroup);
|
||||
}
|
||||
@@ -426,7 +426,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
|
||||
if(adminGroup == null)
|
||||
{
|
||||
adminGroup = groupService.create(context);
|
||||
adminGroup.setName(context, Group.ADMIN);
|
||||
adminGroup.setName(Group.ADMIN);
|
||||
adminGroup.setPermanent(true);
|
||||
groupService.update(context, adminGroup);
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ public interface GroupService extends DSpaceObjectService<Group>, DSpaceObjectLe
|
||||
* @param name
|
||||
* new group name
|
||||
*/
|
||||
public void setName(Context context, Group group, String name) throws SQLException;
|
||||
public void setName(Group group, String name) throws SQLException;
|
||||
|
||||
/**
|
||||
* add an eperson member
|
||||
|
@@ -1,3 +1,10 @@
|
||||
/**
|
||||
* 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.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@@ -131,11 +131,11 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
||||
authorizeService.authorizeAction(context, collection, Constants.WRITE);
|
||||
roleGroup = groupService.create(context);
|
||||
if(role.getScope() == Role.Scope.COLLECTION){
|
||||
groupService.setName(context, roleGroup,
|
||||
groupService.setName(roleGroup,
|
||||
"COLLECTION_" + collection.getID().toString()
|
||||
+ "_WORKFLOW_ROLE_" + roleName);
|
||||
}else{
|
||||
groupService.setName(context, roleGroup, role.getName());
|
||||
groupService.setName(roleGroup, role.getName());
|
||||
}
|
||||
groupService.update(context, roleGroup);
|
||||
authorizeService.addPolicy(context, collection, Constants.ADD, roleGroup);
|
||||
|
@@ -0,0 +1,33 @@
|
||||
--
|
||||
-- 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/
|
||||
--
|
||||
|
||||
---------------------------------------------------------------
|
||||
-- DS-3024 extremely slow searching when logged in as admin
|
||||
---------------------------------------------------------------
|
||||
-- This script will put the group name on the epersongroup
|
||||
-- record itself for performance reasons. It will also make
|
||||
-- sure that a group name is unique (so that for example no two
|
||||
-- Administrator groups can be created).
|
||||
---------------------------------------------------------------
|
||||
|
||||
ALTER TABLE epersongroup
|
||||
DROP COLUMN IF EXISTS name;
|
||||
|
||||
ALTER TABLE epersongroup
|
||||
ADD (name VARCHAR(250));
|
||||
|
||||
CREATE UNIQUE INDEX epersongroup_unique_idx_name on epersongroup(name);
|
||||
|
||||
UPDATE epersongroup
|
||||
SET name =
|
||||
(SELECT text_value
|
||||
FROM metadatavalue v
|
||||
JOIN metadatafieldregistry field on v.metadata_field_id = field.metadata_field_id
|
||||
JOIN metadataschemaregistry s ON field.metadata_schema_id = s.metadata_schema_id
|
||||
WHERE s.short_id = 'dc' AND element = 'title' AND qualifier IS NULL
|
||||
AND v.dspace_object_id = epersongroup.uuid LIMIT 1);
|
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
package org.dspace.eperson;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import org.dspace.AbstractUnitTest;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
@@ -15,6 +14,8 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Test integration of GroupServiceImpl.
|
||||
*
|
||||
@@ -105,7 +106,7 @@ public class GroupServiceImplIT
|
||||
String name = "NOTANONYMOUS";
|
||||
GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
||||
Group group = groupService.findByName(context, Group.ANONYMOUS);
|
||||
groupService.setName(context, group, name);
|
||||
groupService.setName(group, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -141,12 +141,25 @@ public class GroupTest extends AbstractUnitTest {
|
||||
|
||||
@Test
|
||||
public void setGroupName() throws SQLException, AuthorizeException {
|
||||
topGroup.setName(context, "new name");
|
||||
topGroup.setName("new name");
|
||||
groupService.update(context, topGroup);
|
||||
assertThat("setGroupName 1", topGroup.getName(), notNullValue());
|
||||
assertEquals("setGroupName 2", topGroup.getName(), "new name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setGroupNameOnPermanentGroup() throws SQLException, AuthorizeException {
|
||||
topGroup.setPermanent(true);
|
||||
|
||||
topGroup.setName("new name");
|
||||
groupService.update(context, topGroup);
|
||||
assertThat("setGroupName 1", topGroup.getName(), notNullValue());
|
||||
assertEquals("setGroupName 2", topGroup.getName(), "topGroup");
|
||||
|
||||
topGroup.setPermanent(false);
|
||||
groupService.update(context, topGroup);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByName() throws SQLException {
|
||||
Group group = groupService.findByName(context, "topGroup");
|
||||
@@ -491,7 +504,7 @@ public class GroupTest extends AbstractUnitTest {
|
||||
protected Group createGroup(String name) throws SQLException, AuthorizeException {
|
||||
context.turnOffAuthorisationSystem();
|
||||
Group group = groupService.create(context);
|
||||
group.setName(context, name);
|
||||
group.setName(name);
|
||||
groupService.update(context, group);
|
||||
context.restoreAuthSystemState();
|
||||
return group;
|
||||
|
@@ -400,7 +400,7 @@ public class CollectionWizardServlet extends DSpaceServlet
|
||||
g = groupService.create(context);
|
||||
|
||||
// Name it according to our conventions
|
||||
groupService.setName(context, g,
|
||||
groupService.setName(g,
|
||||
"COLLECTION_" + collection.getID() + "_DEFAULT_ITEM_READ");
|
||||
|
||||
// Give it the needed permission
|
||||
|
@@ -96,7 +96,7 @@ public class GroupEditServlet extends DSpaceServlet
|
||||
|
||||
if (!newName.equals(group.getName()))
|
||||
{
|
||||
groupService.setName(c, group, newName);
|
||||
groupService.setName(group, newName);
|
||||
groupService.update(c, group);
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ public class GroupEditServlet extends DSpaceServlet
|
||||
{
|
||||
group = groupService.create(c);
|
||||
|
||||
groupService.setName(c, group, "new group" + group.getID());
|
||||
groupService.setName(group, "new group" + group.getID());
|
||||
groupService.update(c, group);
|
||||
|
||||
request.setAttribute("group", group);
|
||||
|
@@ -9,6 +9,7 @@ package org.dspace.app.xmlui.aspect.administrative;
|
||||
|
||||
import org.apache.cocoon.environment.Request;
|
||||
import org.apache.cocoon.servlet.multipart.Part;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.xmlui.utils.UIException;
|
||||
import org.dspace.app.xmlui.wing.Message;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -25,7 +26,6 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.curate.Curator;
|
||||
@@ -37,6 +37,7 @@ import org.dspace.harvest.HarvestedCollection;
|
||||
import org.dspace.harvest.OAIHarvester;
|
||||
import org.dspace.harvest.factory.HarvestServiceFactory;
|
||||
import org.dspace.harvest.service.HarvestedCollectionService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.workflow.WorkflowException;
|
||||
import org.dspace.workflow.WorkflowService;
|
||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||
@@ -57,7 +58,6 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* Utility methods to processes actions on Communities and Collections.
|
||||
@@ -604,7 +604,7 @@ public class FlowContainerUtils
|
||||
}
|
||||
|
||||
Group role = groupService.create(context);
|
||||
groupService.setName(context, role, "COLLECTION_"+collection.getID().toString() +"_DEFAULT_READ");
|
||||
groupService.setName(role, "COLLECTION_"+collection.getID().toString() +"_DEFAULT_READ");
|
||||
|
||||
// Remove existing privileges from the anonymous group.
|
||||
authorizeService.removePoliciesActionFilter(context, collection, Constants.DEFAULT_ITEM_READ);
|
||||
|
@@ -217,7 +217,7 @@ public class FlowGroupUtils {
|
||||
{
|
||||
// All good, create the new group.
|
||||
group = groupService.create(context);
|
||||
groupService.setName(context, group, newName);
|
||||
groupService.setName(group, newName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -245,7 +245,7 @@ public class FlowGroupUtils {
|
||||
if (potentialDuplicate == null)
|
||||
{
|
||||
// All good, update the name
|
||||
groupService.setName(context, group, newName);
|
||||
groupService.setName(group, newName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user