-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removing unused performance visualizations (#1666) * Fix display of exhibits in the UI (#1665) * Fix display of exhibits in the UI. * Fix issue with multiple exhibits not being semicolon separated, and add tests * Move exhibits below finding aid ino. Add a space when separating exhibit links * Bxc 4416 cleanup temp files (#1667) * BXC-4416 clean up temporary files * Capture the email attachment when sendEmail is called for testing purposes * BXC-4416 fix up tests --------- Co-authored-by: Sharon Luong <[email protected]> Co-authored-by: Ben Pennell <[email protected]> * Address codeclimate issues * BXC-4427 add initial files for setting view behavior * Always reload metadata (#1669) * update exhibit field label (#1673) * BXC-4427 get request object and helper started * BXC-4427 initial files and processor test * BXC-4427 start on router test * BXC-4427 making tests pass * BXC-4427 rename view behavior classes to view settings for more flexibility * BXC-4427 update javadoc to new class names --------- Co-authored-by: Dean Farrell <[email protected]> Co-authored-by: Sharon Luong <[email protected]> Co-authored-by: Ben Pennell <[email protected]> Co-authored-by: Ben Pennell <[email protected]> Co-authored-by: Anna Goslen <[email protected]>
- Loading branch information
1 parent
1db22b8
commit dbe2911
Showing
34 changed files
with
509 additions
and
11,421 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
model-api/src/main/java/edu/unc/lib/boxc/model/api/rdf/CdrView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package edu.unc.lib.boxc.model.api.rdf; | ||
|
||
import org.apache.jena.rdf.model.Property; | ||
import org.apache.jena.rdf.model.Resource; | ||
|
||
import static org.apache.jena.rdf.model.ResourceFactory.createProperty; | ||
import static org.apache.jena.rdf.model.ResourceFactory.createResource; | ||
|
||
/** | ||
* @author snluong | ||
*/ | ||
public class CdrView { | ||
private CdrView() { | ||
} | ||
|
||
/** The namespace of the vocabulary as a string */ | ||
public static final String NS = "http://cdr.unc.edu/definitions/view#"; | ||
|
||
/** The namespace of the vocabulary as a string | ||
* @see #NS */ | ||
public static String getURI() { | ||
return NS; } | ||
|
||
/** The namespace of the vocabulary as a resource */ | ||
public static final Resource NAMESPACE = createResource( NS ); | ||
|
||
/** Used to define the IIIFv3 view "behavior" property for works. | ||
* Valid values: https://iiif.io/api/presentation/3.0/#behavior */ | ||
public static final Property viewBehavior = createProperty( | ||
"http://cdr.unc.edu/definitions/view#behavior"); | ||
} |
47 changes: 47 additions & 0 deletions
47
...ns-jms/src/main/java/edu/unc/lib/boxc/operations/jms/viewSettings/ViewSettingRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package edu.unc.lib.boxc.operations.jms.viewSettings; | ||
|
||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import edu.unc.lib.boxc.auth.api.models.AgentPrincipals; | ||
import edu.unc.lib.boxc.auth.fcrepo.models.AgentPrincipalsImpl; | ||
|
||
/** | ||
* Request object for updating the view settings of the UV | ||
* @author sharonluong | ||
*/ | ||
public class ViewSettingRequest { | ||
private String objectPidString; | ||
private ViewBehavior viewBehavior; | ||
|
||
@JsonDeserialize(as = AgentPrincipalsImpl.class) | ||
private AgentPrincipals agent; | ||
public enum ViewBehavior { | ||
INDIVIDUALS, | ||
PAGED, | ||
CONTINUOUS | ||
} | ||
|
||
public String getObjectPidString() { | ||
return objectPidString; | ||
} | ||
|
||
public void setObjectPidString(String objectPidString) { | ||
this.objectPidString = objectPidString; | ||
} | ||
|
||
public ViewBehavior getViewBehavior() { | ||
return viewBehavior; | ||
} | ||
|
||
public void setViewBehavior(ViewBehavior viewBehavior) { | ||
this.viewBehavior = viewBehavior; | ||
} | ||
|
||
public AgentPrincipals getAgent() { | ||
return agent; | ||
} | ||
|
||
public void setAgent(AgentPrincipals agent) { | ||
this.agent = agent; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...a/edu/unc/lib/boxc/operations/jms/viewSettings/ViewSettingRequestSerializationHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package edu.unc.lib.boxc.operations.jms.viewSettings; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.ObjectReader; | ||
import com.fasterxml.jackson.databind.ObjectWriter; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Helper methods for serializing and deserializing view setting requests | ||
* @author snluong | ||
*/ | ||
public class ViewSettingRequestSerializationHelper { | ||
private static final ObjectWriter REQUEST_WRITER; | ||
private static final ObjectReader REQUEST_READER; | ||
|
||
static { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
REQUEST_WRITER = mapper.writerFor(ViewSettingRequest.class); | ||
REQUEST_READER = mapper.readerFor(ViewSettingRequest.class); | ||
} | ||
|
||
private ViewSettingRequestSerializationHelper() { | ||
} | ||
|
||
public static String toJson(ViewSettingRequest request) throws JsonProcessingException { | ||
return REQUEST_WRITER.writeValueAsString(request); | ||
} | ||
|
||
public static ViewSettingRequest toRequest(String json) throws IOException { | ||
return REQUEST_READER.readValue(json); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...c/main/java/edu/unc/lib/boxc/services/camel/viewSettings/ViewSettingRequestProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package edu.unc.lib.boxc.services.camel.viewSettings; | ||
|
||
import edu.unc.lib.boxc.auth.api.Permission; | ||
import edu.unc.lib.boxc.auth.api.services.AccessControlService; | ||
import edu.unc.lib.boxc.model.api.objects.RepositoryObjectLoader; | ||
import edu.unc.lib.boxc.model.api.objects.WorkObject; | ||
import edu.unc.lib.boxc.model.api.rdf.CdrView; | ||
import edu.unc.lib.boxc.model.api.services.RepositoryObjectFactory; | ||
import edu.unc.lib.boxc.model.fcrepo.ids.PIDs; | ||
import edu.unc.lib.boxc.operations.jms.viewSettings.ViewSettingRequestSerializationHelper; | ||
import org.apache.camel.Exchange; | ||
import org.apache.camel.Processor; | ||
|
||
/** | ||
* Processor for requests for updating the view settings for UV | ||
* | ||
* @author snluong | ||
*/ | ||
public class ViewSettingRequestProcessor implements Processor { | ||
private AccessControlService accessControlService; | ||
private RepositoryObjectLoader repositoryObjectLoader; | ||
private RepositoryObjectFactory repositoryObjectFactory; | ||
|
||
@Override | ||
public void process(Exchange exchange) throws Exception { | ||
var in = exchange.getIn(); | ||
var request = ViewSettingRequestSerializationHelper.toRequest(in.getBody(String.class)); | ||
var agent = request.getAgent(); | ||
var pid = PIDs.get(request.getObjectPidString()); | ||
|
||
accessControlService.assertHasAccess("User does not have permission to update view behavior", | ||
pid, agent.getPrincipals(), Permission.ingest); | ||
|
||
var repositoryObject = repositoryObjectLoader.getRepositoryObject(pid); | ||
var behavior = request.getViewBehavior(); | ||
|
||
if (repositoryObject instanceof WorkObject) { | ||
if (behavior == null) { | ||
repositoryObjectFactory.deleteProperty(repositoryObject, CdrView.viewBehavior); | ||
} else { | ||
repositoryObjectFactory.createExclusiveRelationship(repositoryObject, CdrView.viewBehavior, behavior); | ||
} | ||
} | ||
// TODO BXC-4428 send message to update solr | ||
} | ||
|
||
public void setAccessControlService(AccessControlService accessControlService) { | ||
this.accessControlService = accessControlService; | ||
} | ||
|
||
public void setRepositoryObjectLoader(RepositoryObjectLoader repositoryObjectLoader) { | ||
this.repositoryObjectLoader = repositoryObjectLoader; | ||
} | ||
|
||
public void setRepositoryObjectFactory(RepositoryObjectFactory repositoryObjectFactory) { | ||
this.repositoryObjectFactory = repositoryObjectFactory; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...mel-app/src/main/java/edu/unc/lib/boxc/services/camel/viewSettings/ViewSettingRouter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package edu.unc.lib.boxc.services.camel.viewSettings; | ||
|
||
import org.apache.camel.BeanInject; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.slf4j.Logger; | ||
|
||
import static org.apache.camel.LoggingLevel.DEBUG; | ||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
/** | ||
* Router for processing requests to update view setting of UV | ||
* | ||
* @author snluong | ||
*/ | ||
public class ViewSettingRouter extends RouteBuilder { | ||
private static final Logger log = getLogger(ViewSettingRouter.class); | ||
|
||
@BeanInject(value = "viewSettingRequestProcessor") | ||
private ViewSettingRequestProcessor viewSettingRequestProcessor; | ||
|
||
@Override | ||
public void configure() throws Exception { | ||
from("{{cdr.viewsetting.stream.camel}}") | ||
.routeId("DcrViewSetting") | ||
.log(DEBUG, log, "Received view setting request") | ||
.bean(viewSettingRequestProcessor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.