Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy, mapping and file load fix. #4

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
ARG JDK_VERSION=11

# Step 1 - Run Maven Build
FROM dspace/dspace-dependencies:dspace-7_x as build
#FROM dspace/dspace-dependencies:dspace-7_x as build
FROM dspace/dspace-dependencies:dspace-7.6 as build
ARG TARGET_DIR=dspace-installer
WORKDIR /app
# The dspace-installer directory will be written to /install
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
ARG JDK_VERSION=11

# Step 1 - Run Maven Build
FROM dspace/dspace-dependencies:dspace-7_x as build
# UM Chnage. need to use the 7.6 dependencies because 7_x no longer uses docker.
#FROM dspace/dspace-dependencies:dspace-7_x as build
FROM dspace/dspace-dependencies:dspace-7.6 as build
ARG TARGET_DIR=dspace-installer
WORKDIR /app
# The dspace-installer directory will be written to /install
Expand Down
174 changes: 1 addition & 173 deletions dspace-api/src/main/java/org/dspace/app/util/DCInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

// UM Change
import javax.servlet.http.HttpServletRequest;
import org.dspace.core.Context;
import javax.servlet.ServletException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


// For UM Changes.
import org.dspace.core.Constants;
import org.dspace.eperson.EPerson;
import java.util.UUID;
import org.dspace.content.service.CollectionService;
import org.dspace.content.factory.ContentServiceFactory;

//UM Changes
import org.dspace.web.ContextUtil;
import org.dspace.services.RequestService;
import org.dspace.services.model.Request;
import org.dspace.utils.DSpace;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.content.Collection;

/**
* Class representing a line in an input form.
*
* @author Brian S. Hughes, based on work by Jenny Toves, OCLC
*/
public class DCInput {

private CollectionService collectionService =
ContentServiceFactory.getInstance().getCollectionService();


private static final Logger log = LoggerFactory.getLogger(DCInput.class);

/**
Expand Down Expand Up @@ -205,21 +178,6 @@ public class DCInput {
*/
public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap) {

// UM Change - needed for mapping and proxy depositor logic.
Context c = ContextUtil.obtainCurrentRequestContext();
HttpServletRequest request = null;

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

Request currentRequest = requestService.getCurrentRequest();
if ( currentRequest != null)
{
request = currentRequest.getHttpServletRequest();
}
// End UM Change



dcElement = fieldMap.get("dc-element");
dcQualifier = fieldMap.get("dc-qualifier");

Expand Down Expand Up @@ -253,140 +211,10 @@ public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap)
|| "list".equals(inputType)) {
valueListName = fieldMap.get("value-pairs-name");

/// As far as I can tell this does nothing.

if ( valueListName.equals("collection_mappings") )
{
try
{
valueList.add ( "In just DC" );
valueList.add ( "In just DC" );


// Having this here causes perfomace problems in depoist pages loading and traverssing.
//HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
//AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
//ContentServiceFactory contentServiceFactory = ContentServiceFactory.getInstance();
//List<Collection> collections = contentServiceFactory.getCollectionService().findAll(c);

String pr_collection_id = DSpaceServicesFactory.getInstance().getConfigurationService()
.getProperty("pr.collectionid");
List<Collection> collections = collectionService.findAuthorizedOptimized(c, Constants.ADD);
for (Collection t : collections) {
String handle = t.getHandle();
if ( handle != null )
{
//DSpaceObject coll = handleService.resolveToObject(c, handle);
//Collection coll = (Collection) handleService.resolveToObject(c, handle);
//if ( authorizeService.authorizeActionBoolean ( c, coll, Constants.ADD ) )
//{
String name = t.getName();
UUID id = t.getID();
String the_id = id.toString();

if ( !the_id.equals(pr_collection_id) )
{
log.info("PROX-JustDC: Adding collections for mapping.");

valueList.add ( name );
valueList.add ( the_id );
}
//}
}
}

log.info("PROX-JustDC: DONE Adding collections for mapping.");

valueList.add ( "None" );
valueList.add ( "-1" );
}
catch (Exception e)
{
log.info("PROX-JustDC: ERROR but it may be OK jose, creating collection mapping context is null.");
//Do Nothing
}

}

else if ( valueListName.startsWith("depositor"))
{

try
{

String collectionHandle = valueListName.substring(10).replace("_", "/");
log.info ("PROX-JustDC: this is the coll=" + collectionHandle);

valueList.add ( "In just DC" );
valueList.add ( "In just DC" );



log.info("PROX-JustDC: Creating depositor pick list " + collectionHandle);

//Get the eperson
EPerson e = c.getCurrentUser();

UUID userid = e.getID();

// Jim asked to remove this option.
//valueList.add ( "" );
//valueList.add ( "" );

EPerson[] Proxies = e.getProxies ( c, userid, collectionHandle );

String nameMain = e.getFullName();
String emailMain = e.getEmail();


String labelMain = nameMain + ", " + emailMain;
valueList.add ( labelMain );

//valueList.add ( "SELF" );
valueList.add ( "SELF" );
for (int i = 0; i < Proxies.length; i++)
{
String name = Proxies[i].getFullName();
String email = Proxies[i].getEmail();
UUID id = Proxies[i].getID();

String label = name + ", " + email;

log.info("PROX-JustDC: Adding proxies." + label + " " + id.toString());

valueList.add ( label );
valueList.add ( id.toString() );
}

log.info("PROX-JustDC: DONE Adding proxies.");

}
catch (Exception e)
{
log.info("PROX-JustDC: ERROR but it may be OK jose, creating the depositor picklist for proxies, request is null");
//Do Nothing
}
}
else
{
valueList = (List) listMap.get(valueListName);
}





// The first value is how it came with 7.6.
// valueList = listMap.get(valueListName);
//valueList = (List) listMap.get(valueListName);
valueList = listMap.get(valueListName);
}







hint = fieldMap.get("hint");
warning = fieldMap.get("required");
required = warning != null && warning.length() > 0;
Expand Down
2 changes: 0 additions & 2 deletions dspace-api/src/main/java/org/dspace/app/util/DCInputSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public DCInputSet(String formName, List<List<Map<String, String>>> rows, Map<Str
inputs[i] = new DCInput[fields.size()];
for (int j = 0; j < inputs[i].length; j++) {
Map<String, String> field = rows.get(i).get(j);
log.info("DC-Setup: field, listMap=" + field + "=============>" + listMap);
log.info("DC-Setup: ");
inputs[i][j] = new DCInput(field, listMap);
}
}
Expand Down