Skip to content

Commit

Permalink
added portal functionality to filter out unnecessary UI components wh…
Browse files Browse the repository at this point in the history
…en iframing RODA on other applications
  • Loading branch information
nunovieira220 committed Mar 4, 2019
1 parent a2add8d commit 5505740
Show file tree
Hide file tree
Showing 37 changed files with 1,384 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public final class RodaConstants {
/*
* Misc
*/
public static final String INSTALL_FOLDER_ENVIRONEMNT_VARIABLE = "RODA_HOME";
public static final String INSTALL_FOLDER_ENVIRONMENT_VARIABLE = "RODA_HOME";
public static final String GWT_RPC_BASE_URL = "gwtrpc/";

/**
* XXX Use DateTimeFormatter.ISO_INSTANT instead when GWT supports Instant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@ private static Path determineRodaHomePath() {
Path rodaHomePath;
if (System.getProperty(RodaConstants.INSTALL_FOLDER_SYSTEM_PROPERTY) != null) {
rodaHomePath = Paths.get(System.getProperty(RodaConstants.INSTALL_FOLDER_SYSTEM_PROPERTY));
} else if (System.getenv(RodaConstants.INSTALL_FOLDER_ENVIRONEMNT_VARIABLE) != null) {
rodaHomePath = Paths.get(System.getenv(RodaConstants.INSTALL_FOLDER_ENVIRONEMNT_VARIABLE));
} else if (System.getenv(RodaConstants.INSTALL_FOLDER_ENVIRONMENT_VARIABLE) != null) {
rodaHomePath = Paths.get(System.getenv(RodaConstants.INSTALL_FOLDER_ENVIRONMENT_VARIABLE));
} else {
// last attempt (using user home and hidden directory called .roda)
String userHome = System.getProperty("user.home");
Expand Down
156 changes: 156 additions & 0 deletions roda-ui/roda-wui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,162 @@
</plugins>
</build>
</profile>
<profile>
<id>default-portal</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
<runTarget>org.roda.wui.RodaWUIPortal/Portal.html</runTarget>
<buildOutputDirectory>target/classes</buildOutputDirectory>
</configuration>
<executions>
<execution>
<id>compile-gwt</id>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>gwt-unitCache/</include>
</includes>
</fileset>
<fileset>
<directory>src/main</directory>
<includes>
<include>gwt-unitCache/**</include>
<include>webapp/org.roda.wui.RodaWUI/**</include>
<include>webapp/org.roda.wui.RodaWUIPortal/**</include>
<include>webapp/WEB-INF/deploy/**</include>
<include>webapp/WEB-INF/classes/**</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
<executions>
<execution>
<id>gwt-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>roda-wui-docker-portal</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
<runTarget>org.roda.wui.RodaWUIPortal/Portal.html</runTarget>
<buildOutputDirectory>target/classes</buildOutputDirectory>
</configuration>
<executions>
<execution>
<id>compile-gwt</id>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>gwt-unitCache/</include>
</includes>
</fileset>
<fileset>
<directory>src/main</directory>
<includes>
<include>gwt-unitCache/**</include>
<include>webapp/org.roda.wui.RodaWUI/**</include>
<include>webapp/org.roda.wui.RodaWUIPortal/**</include>
<include>webapp/WEB-INF/deploy/**</include>
<include>webapp/WEB-INF/classes/**</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
<executions>
<execution>
<id>gwt-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<forceTags>true</forceTags>
<imageName>keeps/roda</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<dockerDirectory>${project.basedir}/docker-files</dockerDirectory>
<resources>
<resource>
<targetPath>/ROOT</targetPath>
<directory>${project.build.directory}/${project.build.finalName}</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
Expand Down
45 changes: 45 additions & 0 deletions roda-ui/roda-wui/src/main/java/org/roda/wui/RodaWUIPortal.gwt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<inherits name="com.google.gwt.logging.Logging" />
<inherits name="com.google.gwt.resources.Resources" />
<source path="client" />

<!-- I18N -->
<extend-property name="locale" values="en" />
<extend-property name="locale" values="pt_PT" />
<extend-property name="locale" values="es_CL" />
<set-property-fallback name="locale" value="en"/>

<!-- Locale -->
<set-configuration-property name="locale.useragent" value="Y"/>
<set-configuration-property name="locale.searchorder" value="queryparam,cookie,meta,useragent"/>

<!-- GSS -->
<set-configuration-property name="CssResource.enableGss" value="true" />
<set-configuration-property name="CssResource.gssDefaultInUiBinder" value="true" />
<!-- Still needing conversion mode because default CellTable style is still provided in CSS instead of GSS -->
<set-configuration-property name="CssResource.conversionMode" value="strict" />


<!-- Inherit required libraries -->
<inherits name="com.github.nmorel.gwtjackson.GwtJackson" />

<!-- Inherit sub-projects -->
<!-- TODO: Remove the Common sub-module -->
<inherits name='org.roda.wui.common.Common' />

<!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<!-- <inherits name="com.google.gwt.user.theme.chrome.Chrome" /> -->
<!-- <inherits name="com.google.gwt.user.theme.dark.Dark" /> -->

<!-- Specify the app entry point class. -->
<entry-point class='org.roda.wui.client.portal.MainPortal' />
<!-- <stylesheet src="Main.css" /> Replaced by MyResources -->
<stylesheet src="../api/v1/theme?resource_id=theme.css" />
<stylesheet src="../api/v1/theme?resource_id=printing.css" />

</module>
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public static StreamResponse retrieveAIPRepresentationPart(User user, String aip
}

public static EntityResponse listAIPDescriptiveMetadata(User user, String aipId, String start, String limit,
String acceptFormat)
String acceptFormat, String language)
throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException {
final ControllerAssistant controllerAssistant = new ControllerAssistant() {};

Expand All @@ -596,7 +596,7 @@ public static EntityResponse listAIPDescriptiveMetadata(User user, String aipId,
controllerAssistant.checkObjectPermissions(user, aip);

// delegate
return BrowserHelper.listAIPDescriptiveMetadata(aipId, start, limit, acceptFormat);
return BrowserHelper.listAIPDescriptiveMetadata(aipId, start, limit, acceptFormat, language);
} catch (RODAException e) {
state = LOG_ENTRY_STATE.FAILURE;
throw e;
Expand All @@ -608,7 +608,7 @@ public static EntityResponse listAIPDescriptiveMetadata(User user, String aipId,
}

public static EntityResponse listRepresentationDescriptiveMetadata(User user, String aipId, String representationId,
String start, String limit, String acceptFormat)
String start, String limit, String acceptFormat, String language)
throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException {
ControllerAssistant controllerAssistant = new ControllerAssistant() {};

Expand All @@ -627,7 +627,7 @@ public static EntityResponse listRepresentationDescriptiveMetadata(User user, St

// delegate
return BrowserHelper.listRepresentationDescriptiveMetadata(representation.getAipId(), representation.getId(),
start, limit, acceptFormat);
start, limit, acceptFormat, language);
} catch (RODAException e) {
state = LOG_ENTRY_STATE.FAILURE;
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,13 @@ protected static void validateListAIPDescriptiveMetadataParams(String acceptForm
if (!RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_ZIP.equals(acceptFormat)
&& !RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSON.equals(acceptFormat)
&& !RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_XML.equals(acceptFormat)
&& !RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSONP.equals(acceptFormat)) {
&& !RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSONP.equals(acceptFormat)
&& !RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_HTML.equals(acceptFormat)) {
throw new RequestNotValidException(
"Invalid '" + RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT + "' value. Expected values: "
+ Arrays.asList(RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_ZIP,
RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSON, RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSONP,
RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_XML));
RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_XML, RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_HTML));
}
}

Expand All @@ -862,25 +863,25 @@ public static void validateGetOtherMetadataParams(String acceptFormat) throws Re
}

protected static EntityResponse listAIPDescriptiveMetadata(String aipId, String start, String limit,
String acceptFormat)
String acceptFormat, String language)
throws RequestNotValidException, NotFoundException, GenericException, AuthorizationDeniedException {
ModelService model = RodaCoreFactory.getModelService();
AIP aip = model.retrieveAIP(aipId);
List<DescriptiveMetadata> metadata = aip.getDescriptiveMetadata();
return listDescriptiveMetadata(metadata, aipId, start, limit, acceptFormat);
return listDescriptiveMetadata(metadata, aipId, start, limit, acceptFormat, language);
}

protected static EntityResponse listRepresentationDescriptiveMetadata(String aipId, String representationId,
String start, String limit, String acceptFormat)
String start, String limit, String acceptFormat, String language)
throws RequestNotValidException, NotFoundException, GenericException, AuthorizationDeniedException {
ModelService model = RodaCoreFactory.getModelService();
Representation representation = model.retrieveRepresentation(aipId, representationId);
List<DescriptiveMetadata> metadata = representation.getDescriptiveMetadata();
return listDescriptiveMetadata(metadata, aipId, start, limit, acceptFormat);
return listDescriptiveMetadata(metadata, aipId, start, limit, acceptFormat, language);
}

private static EntityResponse listDescriptiveMetadata(List<DescriptiveMetadata> metadata, String aipId, String start,
String limit, String acceptFormat)
String limit, String acceptFormat, String language)
throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException {
StorageService storage = RodaCoreFactory.getStorageService();
Pair<Integer, Integer> pagingParams = ApiUtils.processPagingParams(start, limit);
Expand All @@ -903,6 +904,25 @@ private static EntityResponse listDescriptiveMetadata(List<DescriptiveMetadata>
}

return DownloadUtils.createZipStreamResponse(zipEntries, aipId);
} else if (RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_HTML.equals(acceptFormat)) {
ModelService model = RodaCoreFactory.getModelService();
List<Pair<String, String>> htmlDescriptives = new ArrayList<>();

for (DescriptiveMetadata dm : metadata) {
Binary descriptiveMetadataBinary = model.retrieveDescriptiveMetadataBinary(aipId, dm.getId());
DescriptiveMetadata descriptiveMetadata = model.retrieveDescriptiveMetadata(aipId, dm.getId());
htmlDescriptives.add(Pair.of(dm.getId(), HTMLUtils.descriptiveMetadataToHtml(descriptiveMetadataBinary,
descriptiveMetadata.getType(), descriptiveMetadata.getVersion(), ServerTools.parseLocale(language))));
}

return new StreamResponse(
new DefaultConsumesOutputStream(aipId + HTML_EXT, RodaConstants.MEDIA_TYPE_TEXT_HTML, out -> {
PrintStream printStream = new PrintStream(out);
for (Pair<String, String> htmlDescriptive : htmlDescriptives) {
printStream.print(htmlDescriptive.getSecond());
}
printStream.close();
}));
} else if (RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSON.equals(acceptFormat)
|| RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_XML.equals(acceptFormat)
|| RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSONP.equals(acceptFormat)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public Response deleteAIP(
@GET
@Path("/{" + RodaConstants.API_PATH_PARAM_AIP_ID + "}/" + RodaConstants.API_DESCRIPTIVE_METADATA + "/")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, ExtraMediaType.APPLICATION_ZIP,
ExtraMediaType.APPLICATION_JAVASCRIPT})
ExtraMediaType.APPLICATION_JAVASCRIPT, MediaType.TEXT_HTML})
@JSONP(callback = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK, queryParam = RodaConstants.API_QUERY_KEY_JSONP_CALLBACK)
@ApiOperation(value = "List descriptive metadata", notes = "List descriptive metadata", response = DescriptiveMetadataList.class, responseContainer = "List")
@ApiResponses(value = {
Expand All @@ -225,6 +225,7 @@ public Response retrieveDescriptiveMetadataListFromAIP(
@ApiParam(value = "Index of the first element to return", defaultValue = "0") @QueryParam(RodaConstants.API_QUERY_KEY_START) String start,
@ApiParam(value = "Maximum number of elements to return", defaultValue = RodaConstants.DEFAULT_PAGINATION_STRING_VALUE) @QueryParam(RodaConstants.API_QUERY_KEY_LIMIT) String limit,
@ApiParam(value = "Choose format in which to get the list", allowableValues = RodaConstants.API_GET_LIST_MEDIA_TYPES) @QueryParam(RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT) String acceptFormat,
@ApiParam(value = "The language for the HTML output", allowableValues = RodaConstants.API_DESCRIPTIVE_METADATA_LANGUAGES, defaultValue = RodaConstants.API_QUERY_VALUE_LANG_DEFAULT) @DefaultValue(RodaConstants.API_QUERY_VALUE_LANG_DEFAULT) @QueryParam(RodaConstants.API_QUERY_KEY_LANG) String language,
@ApiParam(value = "JSONP callback name", required = false, allowMultiple = false, defaultValue = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK) @QueryParam(RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) String jsonpCallbackName)
throws RODAException {
String mediaType = ApiUtils.getMediaType(acceptFormat, request);
Expand All @@ -233,7 +234,7 @@ public Response retrieveDescriptiveMetadataListFromAIP(
User user = UserUtility.getApiUser(request);

// delegate action to controller
EntityResponse metadataList = Browser.listAIPDescriptiveMetadata(user, aipId, start, limit, acceptFormat);
EntityResponse metadataList = Browser.listAIPDescriptiveMetadata(user, aipId, start, limit, acceptFormat, language);

if (metadataList instanceof ObjectResponse) {
ObjectResponse<DescriptiveMetadataList> dmlist = (ObjectResponse<DescriptiveMetadataList>) metadataList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public Response retrieveDescriptiveMetadataListFromRepresentation(
@ApiParam(value = "Index of the first element to return", defaultValue = "0") @QueryParam(RodaConstants.API_QUERY_KEY_START) String start,
@ApiParam(value = "Maximum number of elements to return", defaultValue = "100") @QueryParam(RodaConstants.API_QUERY_KEY_LIMIT) String limit,
@ApiParam(value = "Choose format in which to get the representation", allowableValues = RodaConstants.API_GET_LIST_MEDIA_TYPES) @QueryParam(RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT) String acceptFormat,
@ApiParam(value = "The language for the HTML output", allowableValues = RodaConstants.API_DESCRIPTIVE_METADATA_LANGUAGES, defaultValue = RodaConstants.API_QUERY_VALUE_LANG_DEFAULT) @DefaultValue(RodaConstants.API_QUERY_VALUE_LANG_DEFAULT) @QueryParam(RodaConstants.API_QUERY_KEY_LANG) String language,
@ApiParam(value = "JSONP callback name", required = false, allowMultiple = false, defaultValue = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK) @QueryParam(RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) String jsonpCallbackName)
throws RODAException {
String mediaType = ApiUtils.getMediaType(acceptFormat, request);
Expand All @@ -250,7 +251,7 @@ public Response retrieveDescriptiveMetadataListFromRepresentation(

// delegate action to controller
EntityResponse metadataList = Browser.listRepresentationDescriptiveMetadata(user, aipId, representationId, start,
limit, acceptFormat);
limit, acceptFormat, language);

if (metadataList instanceof ObjectResponse) {
ObjectResponse<DescriptiveMetadataList> dmlist = (ObjectResponse<DescriptiveMetadataList>) metadataList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,14 @@ private void pdfPreview() {
@Override
public void onAttachOrDetach(AttachEvent attachEvent) {
if (attachEvent.isAttached()) {
GWT.log("add handler");
adjustPdfPreviewHeight(frame);
handlerRegistration = Window.addResizeHandler(resizeEvent -> adjustPdfPreviewHeight(frame));
} else if (handlerRegistration != null) {
GWT.log("remove handler");
handlerRegistration.removeHandler();
}
}
});

panel.add(frame);
frame.setStyleName("viewRepresentationPDFFilePreview");
}
Expand Down
Loading

0 comments on commit 5505740

Please sign in to comment.