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

UP-4179: uPortal 5 project overhault with a Gradle-based build #715

Merged
merged 70 commits into from
Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7366a59
UP-4179: Update the version of the master branch to 5.0.0-SNAPSHOT in…
drewwills Aug 31, 2016
fa6de1d
UP-4179: Add a Gradle Wrapper based on the latest version of Gradle t…
drewwills Sep 1, 2016
8e027b1
UP-4179: Update distributionUrl in gradle-wrapper.properties to use t…
drewwills Sep 1, 2016
bc4c0d3
UP-4179: Getting started with Gradle; adding...
drewwills Sep 1, 2016
8e0b9a7
UP-4728: Add submodule uPortal-soffit ported from https://github.com/…
drewwills Sep 1, 2016
9b33dc6
UP-4728: Undo IntelliJ's butchered import order; moce the CACHE_CONT…
drewwills Sep 1, 2016
86ca33a
UP-4728: Add submodule uPortal-soffit-connector ported from https://g…
drewwills Sep 1, 2016
9c56a44
UP-4728: Add submodule uPortal-soffit-renderer ported from https://gi…
drewwills Sep 1, 2016
965625c
UP-4728: Add the connector-portlet.xmlfile to uPortal-soffit-connecto…
drewwills Sep 1, 2016
03a9c77
UP-4728: Add support for Soffit to uPortal
drewwills Sep 2, 2016
08a7215
UP-4179: Instruct Travis CI to use the Maven dependency step, instea…
drewwills Sep 6, 2016
4ab5fc7
UP-4179: Instruct Travis CI to use the Maven dependency step, instea…
drewwills Sep 6, 2016
ae9c898
UP-4179: Add the following (3) Gradle-based submodules and move some…
drewwills Sep 7, 2016
c91a8f8
UP-4728: Use the 'compile project()' dependency style for cross-modu…
drewwills Sep 7, 2016
a87baae
UP-4179: (Interim step) move packages 'org.jasig.portal.aggr' and 'o…
drewwills Sep 7, 2016
e72c3e9
UP-4179: (Interim step) move the following packages out of 'org.jasi…
drewwills Sep 8, 2016
fc3f8d2
Remove channelRegistry.xml and channelRegistry.dtd; they are (unused…
drewwills Sep 8, 2016
80bbf97
UP-4179: (Interim step) move the o.j.p.dao.usertype package out of '…
drewwills Sep 8, 2016
6af06b6
UP-4179: (Interim step) move the o.j.p.events package -- and all subp…
drewwills Sep 8, 2016
1a05df7
UP-4179: (Interim step) move the o.j.p.fragment and o.j.p.groups pack…
drewwills Sep 9, 2016
6812068
UP-4179: (Interim step) move the o.j.p.hibernate and o.j.p.i18n packa…
drewwills Sep 9, 2016
cd93e25
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 10, 2016
8456060
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 10, 2016
0e65cca
UP-4179: (Interim step) move the remainer of the o.j.p.io package out…
drewwills Sep 10, 2016
dd4624c
UP-4179: (Interim step) move the o.j.p.jgroups -- and all subpackages…
drewwills Sep 10, 2016
e36dcc9
UP-4179: (Interim step) move the o.j.p.jmx and o.j.p.jpa packages -- …
drewwills Sep 11, 2016
661efa5
UP-4179: (Interim step) move the o.j.p.json package -- and all subpac…
drewwills Sep 11, 2016
723661f
UP-4179: (Interim step) move the o.j.p.layout.dao and the o.j.p.layou…
drewwills Sep 12, 2016
75efa44
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 12, 2016
a0a29f5
UP-4179: (Interim step) move the o.j.p.ldap and the o.j.p.logging pac…
drewwills Sep 12, 2016
2e3b7a8
UP-4179: (Interim step) move the o.j.p.permission and the o.j.p.perso…
drewwills Sep 12, 2016
bbd6f13
UP-4179: (Interim step) move the o.j.p.portlet.container package -- a…
drewwills Sep 12, 2016
edf11b9
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 12, 2016
283fd45
UP-4179: (Interim step) move the o.j.p.portlet.om package -- and all …
drewwills Sep 13, 2016
1389b9b
UP-4179: Move several Import/Export files that don't need to be in '…
drewwills Sep 13, 2016
a127ec9
UP-4179: (Interim step) move the o.j.p.portlet.registry package -- an…
drewwills Sep 13, 2016
b1122cf
UP-4179: (Interim step) move the o.j.p.portlet.rendering package -- a…
drewwills Sep 13, 2016
4bb7715
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
25a675e
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
0a62393
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
a6f1e9a
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
fbd2ffe
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
89019c2
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
c17a743
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
2da66ec
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
68e59dd
UP-4179: (Interim step) move the o.j.p.rendering package -- and all s…
drewwills Sep 13, 2016
542a01f
UP-4179: (Interim step) move the o.j.p.rest package -- and all subpac…
drewwills Sep 13, 2016
b5e1947
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
ef24fca
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 13, 2016
4c1eb4c
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 14, 2016
e64b9c3
UP-4179: (Interim step) move the o.j.p.spring package -- and all subp…
drewwills Sep 14, 2016
c5365b6
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 14, 2016
20c20d0
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 14, 2016
01ebf39
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills Sep 14, 2016
2c97deb
UP-4179: (Interim step) move the o.j.p.utils package -- and all subpa…
drewwills Sep 15, 2016
63ab3d5
UP-4179: (Interim step) move the following packages out of 'org.jasig…
drewwills Sep 15, 2016
76cf73b
UP-4179: (Interim step) move the 'export-*.crn' files from src/main/r…
drewwills Sep 15, 2016
893d166
UP-4179: Delete folder uportal-war/src/main/resources/org/jasig/port…
drewwills Sep 15, 2016
22cd947
UP-4179: Delete folder uportal-war/src/main/resources/org/jasig/port…
drewwills Sep 15, 2016
67c8fba
UP-4179: (Interim step) move remaining items (portal/groups) out of u…
drewwills Sep 15, 2016
85d4c86
UP-4179: (Interim step) move remaining items out of uportal-war/src/t…
drewwills Sep 15, 2016
62085b9
UP-4179: Remove from 'uportal-war/src/test/resources/org/jasig/porta…
drewwills Sep 15, 2016
9b23b26
UP-4179: Re-package sources within uportal-portlets-overlay/cas from…
drewwills Sep 15, 2016
be64fbe
UP-4179: Re-package sources within uportal-search-api/src/ from 'org…
drewwills Sep 15, 2016
d9ea1ec
UP-4179: grep for org.jasig.portal and verify that remaining occurre…
drewwills Sep 15, 2016
e945df5
UP-4179: Remove (accidentally added) files in .gradle/
drewwills Sep 15, 2016
9be12f0
UP-4179: Rename a couple *.entity-type.xml files replacing 'jasig' w…
drewwills Sep 15, 2016
006bc48
UP-4179: Revert any (IDE-generated) changes to tenant sampledata and…
drewwills Sep 16, 2016
85de7eb
Fix some license headers
drewwills Sep 16, 2016
75787b8
UP-4179: Revert unwanted changes to uportal-war/src/test/resources/o…
drewwills Sep 16, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,20 @@
<!-- ================================ Internal Targets ================================ -->
<!-- -->

<!-- Internal use -->
<target name="gradle-install" description="Build and install (in maven local) the uPortal modules that have been ported to a Gradle-based build">
<!--
| TEMPORARY MEASURE!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a temporary measure for before move to gradle, can this be removed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet. Probably we will need that target as long as we need the build.xml file. We'll be able to remove that file entirely after Phase II (though maybe not immediately).

|
| uPortal is moving from Ant/Maven to Gradle. We are porting sources bit by bit.
| Once we can remove Maven, we can remove this target too.
+-->
<exec executable="./gradlew">
<arg value="clean"/>
<arg value="install"/>
</exec>
</target>

<!-- Internal use -->
<target name="db-ddl" depends="prodPrompt" description="Create a SQL script of commands to drop and create the uPortal database without executing them.">
<fail unless="ddlFile">
Expand Down Expand Up @@ -1575,6 +1589,7 @@ IMPORTANT: The '-Dpattern=' property is no longer a regular expression and is a
<element name="war-sub-tasks" optional="false" implicit="true" />

<sequential>
<antcall target="gradle-install" />
<uportal-db-macro>
<fileset id="uportal-parent.pom.fsid" file="${basedir}/pom.xml" />
</uportal-db-macro>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<commons-dbcp.version>1.4</commons-dbcp.version>
<commons-fileupload.version>1.3.1</commons-fileupload.version>
<commons-httpclient.version>3.1</commons-httpclient.version>
<commons-httpcomponents.version>4.3.2</commons-httpcomponents.version>
<commons-httpcomponents.version>4.4.4</commons-httpcomponents.version>
<commons-io.version>2.4</commons-io.version>
<commons-lang.version>2.6</commons-lang.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
Expand Down
31 changes: 21 additions & 10 deletions uportal-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<name>uPortal WAR</name>
<description>The uPortal web application.</description>

<dependencies>
<!-- ***** Portal JDBC Driver ***** -->
<dependency>
Expand All @@ -42,13 +42,31 @@
<version>${project.version}</version>
<type>pom</type>
</dependency>


<!-- ===== uPortal Dependencies ======================================= -->
<dependency>
<groupId>org.jasig.portal</groupId>
<artifactId>uportal-platform-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jasig.portal</groupId>
<artifactId>uportal-search-api</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.jasig.portal</groupId>
<artifactId>uPortal-soffit-connector</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- ===== Compile Dependencies ======================================= -->
<dependency>
<groupId>org.antlr</groupId>
Expand Down Expand Up @@ -552,13 +570,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jasig.portal</groupId>
<artifactId>uportal-platform-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<!-- ===== Runtime Dependencies ======================================= -->

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/**
* Licensed to Apereo under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Apereo licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a
* copy of the License at the following location:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.jasig.portal.soffit;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.apache.http.Header;
import org.apache.http.message.BasicHeader;
import org.apereo.portal.soffit.Headers;
import org.apereo.portal.soffit.connector.AbstractHeaderProvider;
import org.apereo.portal.soffit.model.v1_0.Bearer;
import org.apereo.portal.soffit.service.BearerService;
import org.jasig.portal.groups.IEntityGroup;
import org.jasig.portal.groups.IGroupMember;
import org.jasig.portal.security.IPerson;
import org.jasig.portal.services.GroupService;
import org.jasig.services.persondir.IPersonAttributeDao;
import org.jasig.services.persondir.IPersonAttributes;
import org.springframework.beans.factory.annotation.Autowired;

/**
* Prepares the standard HTTP Authorization header. This component is defined
* explicitly in the portlet context (not by annotation).
*
* @since 5.0
* @author drewwills
*/
public class AuthorizationHeaderProvider extends AbstractHeaderProvider {

@Autowired
private IPersonAttributeDao personAttributeDao;

@Autowired
private BearerService bearerService;

@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {

// Username
final String username = getUsername(renderRequest);

// Attributes
final Map<String,List<String>> attributes = new HashMap<>();
final IPersonAttributes person = personAttributeDao.getPerson(username);
if (person != null) {
for (Entry<String, List<Object>> y : person.getAttributes().entrySet()) {
final List<String> values = new ArrayList<>();
for (Object value : y.getValue()) {
if (value instanceof String) {
values.add((String) value);
}
}
attributes.put(y.getKey(), values);
}
}
logger.debug("Found the following user attributes for username='{}': {}", username, attributes);

// Groups
final List<String> groups = new ArrayList<>();
final IGroupMember groupMember = GroupService.getGroupMember(username, IPerson.class);
if (groupMember != null) {
Set<IEntityGroup> ancestors = groupMember.getAncestorGroups();
for (IEntityGroup g : ancestors) {
groups.add(g.getName());
}
}
logger.debug("Found the following group affiliations for username='{}': {}", username, groups);

// Expiration of the Bearer token
final PortletSession portletSession = renderRequest.getPortletSession();
final Date expires = new Date(
portletSession.getLastAccessedTime() + ((long) portletSession.getMaxInactiveInterval() * 1000L)
);

// Authorization header
final Bearer bearer = bearerService.createBearer(username, attributes, groups, expires);
final Header rslt = new BasicHeader(
Headers.AUTHORIZATION.getName(),
Headers.BEARER_TOKEN_PREFIX + bearer.getEncryptedToken());
logger.debug("Produced the following Authorization header for username='{}': {}", username, rslt);

return rslt;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/**
* Licensed to Apereo under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Apereo licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a
* copy of the License at the following location:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.jasig.portal.soffit;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.http.Header;
import org.apache.http.message.BasicHeader;
import org.apereo.portal.soffit.Headers;
import org.apereo.portal.soffit.connector.AbstractHeaderProvider;
import org.apereo.portal.soffit.model.v1_0.Definition;
import org.apereo.portal.soffit.service.DefinitionService;
import org.jasig.portal.i18n.ILocaleStore;
import org.jasig.portal.i18n.LocaleManager;
import org.jasig.portal.portlet.marketplace.IMarketplaceService;
import org.jasig.portal.portlet.marketplace.MarketplacePortletDefinition;
import org.jasig.portal.portlet.om.IPortletDefinition;
import org.jasig.portal.portlet.om.IPortletDefinitionParameter;
import org.jasig.portal.portlet.om.IPortletWindow;
import org.jasig.portal.portlet.om.IPortletWindowId;
import org.jasig.portal.portlet.om.PortletCategory;
import org.jasig.portal.portlet.registry.IPortletWindowRegistry;
import org.jasig.portal.security.IPerson;
import org.jasig.portal.security.IPersonManager;
import org.jasig.portal.url.IPortalRequestUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
* Prepares the custom HTTP X-Soffit-Definition header. This component is
* defined explicitly in the portlet context (not by annotation).
*
* @since 5.0
* @author drewwills
*/
public class DefinitionHeaderProvider extends AbstractHeaderProvider {

@Autowired
private IPortalRequestUtils portalRequestUtils;

@Autowired
private IPortletWindowRegistry portletWindowRegistry;

@Autowired
private IMarketplaceService marketplaceService;

@Autowired
private IPersonManager personManager;

@Autowired
private ILocaleStore localeStore;

@Autowired
private DefinitionService definitionService;

@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {

// Username
final String username = getUsername(renderRequest);

// Obtain the MarketplacePortletDefinition for this soffit
final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, renderRequest.getWindowID());
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
final IPortletDefinition pdef = portletWindow.getPortletEntity().getPortletDefinition();
final MarketplacePortletDefinition mpdef = this.marketplaceService.getOrCreateMarketplacePortletDefinition(pdef);

final IPerson user = personManager.getPerson(httpr);
final Locale locale = getUserLocale(user);

// Title
final String title = mpdef.getTitle(locale.toString());

// FName
final String fname = mpdef.getFName();

// Description
final String description = mpdef.getDescription(locale.toString());

// Categories
List<String> categories = new ArrayList<>();
for (PortletCategory pc : mpdef.getCategories()) {
categories.add(pc.getName());
}

// Parameters
Map<String,List<String>> parameters = new HashMap<>();
for (IPortletDefinitionParameter param : mpdef.getParameters()) {
parameters.put(param.getName(), Collections.singletonList(param.getValue()));
}

final Definition definition = definitionService.createDefinition(title, fname,
description, categories, parameters, username, getExpiration(renderRequest));
final Header rslt = new BasicHeader(
Headers.DEFINITION.getName(),
definition.getEncryptedToken());
logger.debug("Produced the following {} header for username='{}': {}", Headers.DEFINITION.getName(), username, rslt);

return rslt;
}

/*
* Implementation
*/

private Locale getUserLocale(IPerson user) {
// get user locale
Locale[] locales = localeStore.getUserLocales(user);
LocaleManager localeManager = new LocaleManager(user, locales);
Locale rslt = localeManager.getLocales()[0];
return rslt;
}

}
10 changes: 10 additions & 0 deletions uportal-war/src/main/resources/properties/ehcache.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2066,4 +2066,14 @@
eternal="false" maxElementsInMemory="2000" overflowToDisk="false" diskPersistent="false"
timeToIdleSeconds="0" timeToLiveSeconds="300" memoryStoreEvictionPolicy="LRU" statistics="true" />

<!--
| Caches out output of remote soffits; timeToLiveSeconds will be set on
| each Element according to the cache-control header send by the remote soffit.
| - 1 x unique combination of (soffit+mode+windowState) [x user for private scope]
| - not replicated
+-->
<cache name="org.apereo.portlet.soffit.connector.SoffitConnectorController.RESPONSE_CACHE"
eternal="false" maxElementsInMemory="2000" overflowToDisk="false" diskPersistent="false"
timeToIdleSeconds="0" timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU" statistics="true" />

</ehcache>
14 changes: 14 additions & 0 deletions uportal-war/src/main/resources/properties/portal.properties
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,18 @@ org.jasig.portal.tincan-api.enabled=false
# org.jasig.rest.interceptor.basic-auth.scorm-cloud-lrs.username=UsernameForProvider
# org.jasig.rest.interceptor.basic-auth.scorm-cloud-lrs.password=PasswordForProvider

# Signature Key (Soffit)
# ----------------------
# Uncomment and change the value of this setting. 'CHANGEME' is the default
# value; it may work (if both sides of the transaction have the default), but
# isn't secure and will produce a WARNING.
#
#org.apereo.portal.soffit.jwt.signatureKey=CHANGEME

# Encryption Password (Soffit)
# ----------------------------
# Uncomment and change the value of this setting. 'CHANGEME' is the default
# value; it may work (if both sides of the transaction have the default), but
# isn't secure and will produce a WARNING.
#
#org.apereo.portal.soffit.jwt.encryptionPassword=CHANGEME
Loading