Skip to content

Commit

Permalink
depoist form changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
blancoj committed May 28, 2024
1 parent 2e2fe39 commit 05de3a6
Show file tree
Hide file tree
Showing 17 changed files with 4,848 additions and 1,057 deletions.
35 changes: 21 additions & 14 deletions dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
import org.dspace.services.model.Request;
import org.dspace.utils.DSpace;

// This gives and error.
//import org.dspace.app.rest.utils.ContextUtil;

/**
* Submission form generator for DSpace. Reads and parses the installation
* form definitions file, submission-forms.xml, from the configuration directory.
Expand Down Expand Up @@ -183,15 +180,22 @@ public List<String> getPairs(String name) {
// UM Change - needed for mapping and proxy depositor logic.
Context c = ContextUtil.obtainCurrentRequestContext();

HttpServletRequest request = null;
//HttpServletRequest request = null;

RequestService requestService = new DSpace().getRequestService();

String collectionUUID = "NO_UUID"; // Default Value

// This code could be cleaned up. From what I see the currentRequest is never null,
// but I will leave it here for now.
Request currentRequest = requestService.getCurrentRequest();
if ( currentRequest != null)
if ( currentRequest == null)
{
log.info("PROX: curretnRequest is not null");
request = currentRequest.getHttpServletRequest();
log.info("COLL: owningCollectin=" + collectionUUID);
}
{
collectionUUID = ContextUtil.getCollectionUUID();
log.info("COLL: owningCollectin=" + collectionUUID);
}

List<String> myList = new ArrayList<>();
Expand All @@ -211,7 +215,7 @@ public List<String> getPairs(String name) {
UUID id = t.getID();
String the_id = id.toString();

if ( !the_id.equals(pr_collection_id) )
if ( !the_id.equals(pr_collection_id) && !the_id.equals(collectionUUID) )
{
myList.add(nameUser);
myList.add( the_id );
Expand All @@ -229,13 +233,15 @@ public List<String> getPairs(String name) {
} else if (name.startsWith("depositor")) {
try
{
// This is the way I was doing it when I could not get the uuid or handle passed on.
// But found a way to get it passed to this method.
// UM Change.
// Get the collection handle from the configuration.
// This is different from the way we did it in 6.3
// depositor_123456789_6
// 01234567890
String collectionHandle = name.substring(10).replace("_", "/");
log.info ("PROX: this is the coll=" + collectionHandle);
//String collectionHandle = name.substring(10).replace("_", "/");
//log.info ("PROX: this is the coll=" + collectionHandle);

if ( c.getCurrentUser() != null )
{
Expand All @@ -251,8 +257,7 @@ public List<String> getPairs(String name) {
myList.add(labelMain);
myList.add("SELF");


EPerson[] Proxies = ePerson.getProxies ( c, userid, collectionHandle );
EPerson[] Proxies = ePerson.getProxiesByUUID ( c, userid, collectionUUID );

log.info ("PROX: processing request");
for (int k = 0; k < Proxies.length; k++)
Expand Down Expand Up @@ -293,7 +298,8 @@ public List<String> getPairs(String name) {
* @throws ServletException
*/
public List<DCInputSet> getInputsByCollectionHandle(String collectionHandle)
throws DCInputsReaderException {
throws DCInputsReaderException {

SubmissionConfig config;
try {
config = new SubmissionConfigReader().getSubmissionConfigByCollection(collectionHandle);
Expand Down Expand Up @@ -834,7 +840,8 @@ private String getValue(Node nd) {
}

public String getInputFormNameByCollectionAndField(Collection collection, String field)
throws DCInputsReaderException {
throws DCInputsReaderException {

List<DCInputSet> inputSets = getInputsByCollectionHandle(collection.getHandle());
for (DCInputSet inputSet : inputSets) {
String[] tokenized = Utils.tokenize(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ public List<Group> getSpecialGroups(Context context, HttpServletRequest request)

GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();

//Using this one for testing in docker
// UM Change
// The way swordv2 works now, the code will come here, and in that case request will be null.
if ( request == null )
{
return Collections.emptyList();
}
String addr = request.getRemoteAddr();

// This is the one you should use on the live area.
Expand Down
22 changes: 22 additions & 0 deletions dspace-api/src/main/java/org/dspace/eperson/EPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,28 @@ public static EPerson[] getProxies (Context context, UUID depositor_id, String c
return epersonArray;

}

public static EPerson[] getProxiesByUUID (Context context, UUID depositor_id, String collectionUUID) throws SQLException
{
List<EPerson> proxies = new ArrayList<EPerson>();

EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
if (!collectionUUID.equals("NO_UUID") )
{
proxies = ePersonService.findProxiesForDepositorInCollectionByUUID(context, depositor_id, collectionUUID);
}
else
{
proxies = ePersonService.findProxiesForDepositor(context, depositor_id);
}

EPerson[] epersonArray = new EPerson[proxies.size()];
epersonArray = (EPerson[]) proxies.toArray(epersonArray);

return epersonArray;

}

// End UM Change

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,11 @@ public List <EPerson> findProxiesForDepositorInCollection(Context context, UUID
return ePersonDAO.findProxiesForDepositorInCollection(context, depositor_id, collection_handle);
}

@Override
public List <EPerson> findProxiesForDepositorInCollectionByUUID(Context context, UUID depositor_id, String collectionUUID) throws SQLException {
return ePersonDAO.findProxiesForDepositorInCollectionByUUID(context, depositor_id, collectionUUID);
}

@Override
public int countIndivStats(Context context, String email) throws SQLException {
return ePersonDAO.countIndivStats(context, email);
Expand Down
8 changes: 8 additions & 0 deletions dspace-api/src/main/java/org/dspace/eperson/Proxies.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public class Proxies implements ReloadableEntity<Integer> {
@Column(name = "handle", unique = false)
private String handle;

@Column(name = "uuid", unique = false)
private String uuid;


/**
* Protected constructor, create object using:
* {@link org.dspace.eperson.service.SubscribeService#subscribe(Context, EPerson, Collection)}
Expand Down Expand Up @@ -83,6 +87,10 @@ public String getHandle() {
return handle;
}

public String getUUID() {
return uuid;
}

void setePerson(String handle) {
this.handle = handle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public List<EPerson> findAll(Context context, MetadataField metadataFieldSort, S

public List<EPerson> findProxiesForDepositorInCollection(Context context, UUID depositor_id, String collection_handle) throws SQLException;

public List<EPerson> findProxiesForDepositorInCollectionByUUID(Context context, UUID depositor_id, String collectionUUID) throws SQLException;

public int countIndivStats(Context context, String email) throws SQLException;

public void DeleteFromIndivStats(Context context, String email) throws SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,17 @@ public List <EPerson> findProxiesForDepositorInCollection(Context context, UUID
return list(query);
}

@Override
public List <EPerson> findProxiesForDepositorInCollectionByUUID(Context context, UUID depositor_id, String collectionUUID) throws SQLException {


Query query = createQuery(context, "SELECT e FROM EPerson e WHERE e.id in (SELECT p.ePerson_proxy FROM Proxies p WHERE p.ePerson_depositor = :depositor_id AND p.uuid= :collectionUUID)");
query.setParameter("depositor_id", depositor_id);
query.setParameter("collectionUUID", collectionUUID);

return list(query);
}

@Override
public int countIndivStats(Context context, String email) throws SQLException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public EPerson create(Context context) throws SQLException,

public List <EPerson> findProxiesForDepositorInCollection(Context context, UUID depositor_id, String collection_handle) throws SQLException;

public List <EPerson> findProxiesForDepositorInCollectionByUUID(Context context, UUID depositor_id, String collectionUUID) throws SQLException;

public int countIndivStats(Context context, String email) throws SQLException;

Expand Down
12 changes: 12 additions & 0 deletions dspace-api/src/main/java/org/dspace/web/ContextUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class ContextUtil {
*/
private ContextUtil() { }

public static String collectionUUID = "NO_UUID";

/**
* Inspection method to check if a DSpace context has been created for this request.
*
Expand Down Expand Up @@ -106,6 +108,16 @@ public static Context obtainCurrentRequestContext() {
return context;
}

// To be able to pass the collection UUID to DCInputsReader.java
public static void setCollectionUUID(String uuid) {
collectionUUID = uuid;
}

public static String getCollectionUUID() {
return collectionUUID;
}
// End

private static Locale getLocale(Context context, HttpServletRequest request) {
Locale userLocale = null;
Locale supportedLocale = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import org.dspace.identifier.DOIIdentifierProvider;
import org.dspace.content.DSpaceObject;

/**
* When an item is submitted and is somewhere in a workflow, it has a row in the
* {@code cwf_workflowitem} table pointing to it.
Expand Down Expand Up @@ -806,6 +809,17 @@ protected void notifyOfArchive(Context context, Item item, Collection coll)
// Get the item handle to email to user
String handle = handleService.findHandle(context, item);

DOIIdentifierProvider doiIdentifierProvider = DSpaceServicesFactory.getInstance().getServiceManager()
.getServiceByName("org.dspace.identifier.DOIIdentifierProvider", DOIIdentifierProvider.class);

DSpaceObject item_dso = (DSpaceObject) item;
String doi = doiIdentifierProvider.getDOIByObject(context, item_dso);

// what you get for doi: doi:10.33577/42
// what you want to send out in email:https://dx.doi.org/10.7302/22447
String doi_url = doi.replace("doi:", "https://dx.doi.org/");
log.info("DOIHERE is = " + doi_url);

// Get title
List<MetadataValue> titles = itemService
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
Expand Down Expand Up @@ -850,6 +864,7 @@ protected void notifyOfArchive(Context context, Item item, Collection coll)
email.addArgument(title);
email.addArgument(coll.getName());
email.addArgument(handleService.getCanonicalForm(handle));
email.addArgument(doi_url);

email.send();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
--

CREATE SEQUENCE proxies_seq;
create table proxies (proxies_id integer NOT NULL DEFAULT nextval('proxies_seq'), depositor_id uuid, proxy_id uuid, handle varchar(100));
create table proxies (proxies_id integer NOT NULL DEFAULT nextval('proxies_seq'), depositor_id uuid, proxy_id uuid, handle varchar(100), uuid varchar(100));


CREATE SEQUENCE umrestricted_seq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public WorkspaceItem createWorkspaceItem(Context context, Request request) throw
collectionUUID = configurationService.getProperty("submission.default.collection");
}

// Save collection UUID to pass to the DCInputsReader.java file.
org.dspace.web.ContextUtil.setCollectionUUID(collectionUUID);

try {
if (StringUtils.isNotBlank(collectionUUID)) {
collection = collectionService.find(context, UUID.fromString(collectionUUID));
Expand Down
6 changes: 2 additions & 4 deletions dspace/config/emails/request_item.author
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## 8 corresponding author email
## 9 configuration property "dspace.name"
## 10 configuration property "mail.helpdesk"
#set($subject = "${config.get('dspace.name')}: Request copy of document")
#set($subject = "Request copy of document")

Dear ${params[7]},

Expand All @@ -27,6 +27,4 @@ IF YOU ARE NOT AN AUTHOR OF THIS DOCUMENT, and only submitted the document on th

IF YOU ARE AN AUTHOR OF THE REQUESTED DOCUMENT, thank you for your cooperation!

If you have any questions concerning this request, please contact ${params[10]}.

The ${config.get('dspace.name')} Team
If you have any questions concerning this request, please contact ${params[10]}.
9 changes: 4 additions & 5 deletions dspace/config/emails/submit_archive
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
## {2} handle
## {3} Identifier
##
#set($subject = 'DSpace: Deep Blue: Submission Approved and Archived')
#set($subject = 'Deep Blue: Submission Approved and Archived')

${params[0]}: ${params[1]}

To collection: ${params[2]}

Its identifier: ${params[3]}
Deep Blue DOI: ${params[4]}

Note: Please use this identifier in your citations to this work; you can use this identifier immediately in citations to your work, but it may take a
few minutes for the the deposit to appear in Deep Blue Document's index.
Note: Please use this identifier when citing your work; you can use it immediately, but it may take one to two (1-2) hours for the DOI to be activated as a clickable URL.

Thank you!

Deep Blue Documents
Deep Blue

Loading

0 comments on commit 05de3a6

Please sign in to comment.