Skip to content

Commit

Permalink
Merge branch 'hotfix/2019.2.2' into stable-2019.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PenghaiZhang committed Apr 3, 2020
2 parents dfaf640 + db14c71 commit dd48f40
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 84 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ services:
- postgresql
addons:
postgresql: "9.6"
chrome: beta
apt:
packages:
- chromium-browser
- chromium-chromedriver
- ffmpeg
- libimage-exiftool-perl
- openjdk-8-jdk
Expand All @@ -51,10 +52,6 @@ before_install:
- sudo ln -s /usr/bin/ffplay /usr/bin/avplay
- sudo ln -s /usr/bin/ffprobe /usr/bin/avprobe
install:
- curl -OL https://chromedriver.storage.googleapis.com/80.0.3987.16/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- sudo apt-get purge google-chrome-stable # have to delete the stable version to force chromedriver to use the beta
- echo `google-chrome --version`
# retrieve full git history for automatic versioning
- git fetch --unshallow
before_script:
Expand All @@ -65,6 +62,9 @@ before_script:
- which java javac
- java -version
- javac -version
# Diagnostics: Display browser versions
- google-chrome --version
- chromium-browser --version

stages:
- name: build and check
Expand Down
5 changes: 5 additions & 0 deletions Source/Plugins/Core/com.equella.core/plugin-jpf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4786,6 +4786,11 @@
<parameter id="url-pattern" value="/*" />
<parameter id="order" value="800" />
</extension>
<extension plugin-id="com.tle.web.core" point-id="webFilter" id="sameSiteFilter">
<parameter id="bean" value="bean:com.tle.web.core.filter.SameSiteFilter" />
<parameter id="url-pattern" value="/*" />
<parameter id="order" value="850" />
</extension>
<extension plugin-id="com.tle.web.core" point-id="webServlet" id="doNotServeServlet">
<parameter id="bean" value="bean:com.tle.web.core.servlet.DoNotServeServlet" />
<parameter id="url-pattern" value="/WEB-INF/*" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ import io.lemonlabs.uri.{Path => _, _}
import io.swagger.annotations.Api
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
import javax.ws.rs._
import javax.ws.rs.core.Response.ResponseBuilder
import javax.ws.rs.core.Response.{ResponseBuilder, Status}
import javax.ws.rs.core.{CacheControl, Context, Response, UriInfo}
import org.slf4j.LoggerFactory

import scala.collection.JavaConverters._
import scala.collection.mutable
Expand Down Expand Up @@ -247,6 +248,7 @@ object LegacyContentController extends AbstractSectionsController with SectionFi
@Api("Legacy content")
@Path("content")
class LegacyContentApi {
val LOGGER = LoggerFactory.getLogger(classOf[LegacyContentApi])

def parsePath(path: String): (String, MutableSectionInfo => MutableSectionInfo) = {

Expand Down Expand Up @@ -623,7 +625,7 @@ class LegacyContentApi {
.map(bbr => SectionUtils.renderToString(context, bbr.getRenderable))
}

def ajaxResponse(info: MutableSectionInfo, arc: AjaxRenderContext) = {
def ajaxResponse(info: MutableSectionInfo, arc: AjaxRenderContext): Response.ResponseBuilder = {
var resp: ResponseBuilder = null
val context = LegacyContentController.prepareJSContext(info)

Expand Down Expand Up @@ -656,6 +658,10 @@ class LegacyContentApi {
case tr: TemplateResult => tr.getNamedResult(context, "body")
case sr: SectionRenderable => sr
case pr: PreRenderable => new PreRenderOnly(pr)
//Due to many unknowns of what could cause renderedBody being null, return a 500 error at the moment.
case _ =>
LOGGER.debug("Unknown error at renderedBody - ajaxResponse");
return Response.status(Status.NOT_IMPLEMENTED);
}
renderAjaxBody(renderedBody)
val responseCallback = arc.getJSONResponseCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.tle.core.favourites.service;

import com.dytech.edge.web.WebConstants;
import com.tle.beans.Institution;
import com.tle.common.Check;
import com.tle.common.institution.CurrentInstitution;
Expand All @@ -37,6 +38,7 @@
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang.StringUtils;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -68,7 +70,23 @@ public void deleteById(long id) {
public void executeSearch(SectionInfo info, long id) {
FavouriteSearch search = dao.getById(id);
if (search != null) {
SectionInfo forward = info.createForwardForUri(search.getUrl());
String url = search.getUrl();
// When user favourites a normal search, cloud search or hierarchy search,
// the value of 'url' starts with '/access' if the fav search is added in old oEQ versions,
// which results in "no tree for xxx" error. Hence, remove "/access" if it exists.
if (url != null
&& url.startsWith(WebConstants.ACCESS_PATH)
&& StringUtils.indexOfAny(
url,
new String[] {
WebConstants.SEARCHING_PAGE,
WebConstants.HIERARCHY_PAGE,
WebConstants.CLOUDSEARCH_PAGE
})
> -1) {
url = "/" + url.replaceFirst(WebConstants.ACCESS_PATH, "");
}
SectionInfo forward = info.createForwardForUri(url);
info.forwardAsBookmark(forward);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ protected void configure() {
bindInt("http.port", -1);
bindInt("https.port", -1);
bindInt("ajp.port", -1);
bindProp("ajp.address", "127.0.0.1");
// Makes sense for this to be in mandatory-config, but we have to provide a default, non-null
// value
bindProp("ajp.secret", "ignore");
bindBoolean("ajp.secret.required", true);
bindInt("tomcat.max.threads", -2);
install(new TomcatOptionalModule());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ public class TomcatServiceImpl implements TomcatService, StartupBean, TomcatRest
@Named("ajp.port")
private int ajpPort;

@Inject
@Named("ajp.address")
private String ajpAddress;

@Inject
@Named("ajp.secret")
private String ajpSecret;

@Inject
@Named("ajp.secret.required")
private boolean ajpSecretRequired;

@Inject
@Named("tomcat.max.threads")
private int maxThreads;
Expand Down Expand Up @@ -182,8 +194,13 @@ public void startup() {
if (ajpPort != -1) {
Connector connector = new Connector(useBio ? BIO_AJP : "AJP/1.3");
connector.setPort(ajpPort);
if (!ajpSecret.equals("ignore")) {
connector.setAttribute("secret", ajpSecret);
}
connector.setAttribute("secretRequired", ajpSecretRequired);
connector.setAttribute("tomcatAuthentication", false);
connector.setAttribute("packetSize", "65536");
connector.setAttribute("address", ajpAddress);
setConnector(connector);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to The Apereo Foundation under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* The Apereo Foundation 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:
*
* 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 com.tle.web.core.filter;

import com.tle.core.guice.Bind;
import com.tle.web.dispatcher.AbstractWebFilter;
import com.tle.web.dispatcher.FilterResult;
import java.io.IOException;
import java.util.Collection;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.HttpHeaders;

@Bind
public class SameSiteFilter extends AbstractWebFilter {

@Override
public FilterResult filterRequest(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (request.isSecure()) {
Collection<String> headers = response.getHeaders(HttpHeaders.SET_COOKIE);
boolean firstHeader = true;
for (String header : headers) {
if (firstHeader) {
response.setHeader(
HttpHeaders.SET_COOKIE, String.format("%s; %s", header, "SameSite=None"));
firstHeader = false;
continue;
}
response.addHeader(
HttpHeaders.SET_COOKIE, String.format("%s; %s", header, "SameSite=None"));
}
}
return FilterResult.FILTER_CONTINUE;
}
}
2 changes: 1 addition & 1 deletion Source/Server/equellaserver/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ unmanagedClasspath in Runtime += (baseDirectory in LocalProject("learningedge_co

val jacksonVersion = "2.9.9"
val axis2Version = "1.6.2"
val TomcatVersion = "8.5.47"
val TomcatVersion = "8.5.51"
val SwaggerVersion = "1.5.24"
val RestEasyVersion = "3.5.0.Final"
val simpledbaVersion = "0.1.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
import com.tle.webtests.pageobject.wizard.ContributePage;
import com.tle.webtests.pageobject.wizard.WizardPageTab;
import com.tle.webtests.pageobject.wizard.controls.UniversalControl;
import com.tle.webtests.pageobject.wizard.controls.universal.YouTubeUniversalControlType;
import com.tle.webtests.pageobject.wizard.controls.universal.UrlUniversalControlType;
import com.tle.webtests.test.AbstractCleanupTest;
import org.testng.annotations.Test;

@TestInstitution("fiveo")
public class ItemUnlock extends AbstractCleanupTest {
private static final String RENAMED_NAME = "A Video";
private static final String ORIGINAL_NAME =
"What is a function? | Functions and their graphs | Algebra II | Khan Academy";
private static final String DISPLAY_NAME = "Original Displayname";
private static final String RENAMED_NAME = "Google Renamed";
private static final String DISPLAY_NAME = "Google";
private final String LINK_ATTACHMENT_URL = "https://www.google.com";

@Test
public void unlockAndResumeItem() {
Expand All @@ -30,10 +29,10 @@ public void unlockAndResumeItem() {
new ContributePage(context).load().openWizard("Youtube Channel Testing Collection");
wizard.editbox(1, itemName);
UniversalControl control = wizard.universalControl(2);
YouTubeUniversalControlType youtube =
control.addDefaultResource(new YouTubeUniversalControlType(control));
youtube.search("Functions and their graphs", "The Khan Academy").selectVideo(1, ORIGINAL_NAME);
control.editResource(youtube.editPage(), ORIGINAL_NAME).setDisplayName(DISPLAY_NAME).save();

UrlUniversalControlType urlControl =
control.addDefaultResource(new UrlUniversalControlType(control));
urlControl.addUrl(LINK_ATTACHMENT_URL, DISPLAY_NAME);
SummaryPage item = wizard.save().publish();
assertTrue(item.attachments().attachmentExists(DISPLAY_NAME));

Expand All @@ -49,7 +48,7 @@ public void unlockAndResumeItem() {

control = wizard.universalControl(2);
control
.editResource(new YouTubeUniversalControlType(control), DISPLAY_NAME)
.editResource(new UrlUniversalControlType(control), DISPLAY_NAME)
.setDisplayName(RENAMED_NAME)
.save();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.tle.webtests.pageobject.wizard.ContributePage;
import com.tle.webtests.pageobject.wizard.WizardPageTab;
import com.tle.webtests.pageobject.wizard.controls.UniversalControl;
import com.tle.webtests.pageobject.wizard.controls.universal.YouTubeUniversalControlType;
import com.tle.webtests.pageobject.wizard.controls.universal.UrlUniversalControlType;
import com.tle.webtests.test.AbstractCleanupAutoTest;
import com.tle.webtests.test.files.Attachments;
import java.net.URL;
Expand All @@ -15,8 +15,8 @@
public class MaxAttachmentsTest extends AbstractCleanupAutoTest {
private static final String COLLECTION = "Max attachments restriction";
private final URL[] ATTACHMENTS = {Attachments.get("page.html"), Attachments.get("pageB.html")};
private final String ORIGINAL_TITLE = "Peter Andre - Mysterious Girl (Official Music Video)";
private final String YOUTUBE_TITLE = "good song";
private final String LINK_ATTACHMENT_URL = "https://www.google.com";
private final String LINK_ATTACHMENT_NAME = "Google";

@Test
public void maxFiles() {
Expand All @@ -25,19 +25,15 @@ public void maxFiles() {
wizard.editbox(1, fullName);
UniversalControl control = wizard.universalControl(2);

YouTubeUniversalControlType youTubeControl =
control.addResource(new YouTubeUniversalControlType(control));
youTubeControl.search("mysterious girl peter andre", null).selectVideo(1, ORIGINAL_TITLE);
control
.editResource(youTubeControl.editPage(), ORIGINAL_TITLE)
.setDisplayName(YOUTUBE_TITLE)
.save();
UrlUniversalControlType urlControl = control.addResource(new UrlUniversalControlType(control));
urlControl.addUrl(LINK_ATTACHMENT_URL, LINK_ATTACHMENT_NAME);

wizard.addFiles(2, false, ATTACHMENTS);
wizard.save().finishInvalid(wizard);
Assert.assertEquals(
wizard.getErrorMessage(2),
"This control is restricted to a maximum of 2 attachments. Please remove 1 attachment(s).");
control.deleteResource(YOUTUBE_TITLE);
control.deleteResource(LINK_ATTACHMENT_NAME);
wizard.save().publish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void testHtml5Player() {
public void testLTIViewer() {
SummaryPage summary = SearchPage.searchAndView(context, "lti viewer item");
LTIViewerPage lti =
summary.attachments().viewAttachment("youtube tool", new LTIViewerPage(context));
summary.attachments().viewAttachment("Vimeo tool", new LTIViewerPage(context));
lti.searchYoutube("ghosts");
lti.embedYTResult(4);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ object LoginNoticeMenuPropertiesSerial extends ShotProperties("Login Notice Menu
withLogon(autoTestLogon) { context =>
val page = LoginNoticePage(context).load()
val equellaGithubAvatarURL =
"https://raw.githubusercontent.com/equella/Equella/f22b0083767aab13f701777a3a2d85974b010780/autotest/Tests/tests/fiveo/institution/items/42/216490/cat1.jpg"
"https://raw.githubusercontent.com/openequella/openEQUELLA/develop/autotest/Tests/tests/fiveo/institution/items/42/216490/cat1.jpg"
page.setPreLoginNoticeWithImageURL(equellaGithubAvatarURL)

val page2 = LoginPage(context).load()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
<string>StoreJs</string>
<string>if (request.get(&apos;doit&apos;) == &apos;Create binary file&apos;)
{
var connection = utils.getConnection(&quot;https://github.com/equella/Equella/blob/cfd7f9027de68635d73b60958079196bab165ead/Installer/resources/images/logo.gif?raw=true&quot;);
var connection = utils.getConnection(&quot;https://raw.githubusercontent.com/openequella/openEQUELLA/develop/Installer/resources/images/logo.gif?raw=true&quot;);
var response = connection.getResponse(true);
staging.writeBinaryFile(&quot;equellaLogo.gif &quot;,response.getAsBinaryData());
}
Expand Down Expand Up @@ -350,4 +350,4 @@ if(request.get(&quot;doit&quot;) == &apos;Get File Details&apos;)
</itemSummarySections>
</slow>
<denyDirectContribution>false</denyDirectContribution>
</com.tle.beans.entity.itemdef.ItemDefinition>
</com.tle.beans.entity.itemdef.ItemDefinition>
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ if(request.get(&apos;doit&apos;) == &apos;Edit text file&apos;)

if (request.get(&apos;doit&apos;) == &apos;Create binary attachment&apos;)
{
var response = utils.getConnection(&quot;https://github.com/equella/Equella/blob/cfd7f9027de68635d73b60958079196bab165ead/Installer/resources/images/logo.gif?raw=true&quot;).getResponse(true);
var response = utils.getConnection(&quot;https://raw.githubusercontent.com/openequella/openEQUELLA/develop/Installer/resources/images/logo.gif?raw=true&quot;).getResponse(true);
attachments.createBinaryFileAttachment(&quot;equellaLogo.gif &quot;,&quot;EQUELLA Logo&quot;,response.getAsBinaryData());
attachments.addExistingFileAsAttachment(&quot;equellaLogo.gif &quot;,&quot;EQUELLA Logo&quot;);

Expand Down Expand Up @@ -362,4 +362,4 @@ Contents:
</itemSummarySections>
</slow>
<denyDirectContribution>false</denyDirectContribution>
</com.tle.beans.entity.itemdef.ItemDefinition>
</com.tle.beans.entity.itemdef.ItemDefinition>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<status>0</status>
<time class="sql-timestamp">2009-04-16 15:49:15.643</time>
<from class="sql-timestamp">2009-04-16 15:49:02.687</from>
<until class="sql-timestamp">2020-04-01 11:00:00.0</until>
<until class="sql-timestamp">2100-12-31 11:00:00.0</until>
<course entityclass="com.tle.beans.item.cal.request.CourseInfo" uuid="313213e6-049a-8834-46d1-230be99f4490"/>
<citation>Harvard</citation>
<description>, &apos;Part Two&apos; in</description>
</com.tle.beans.activation.ActivateRequest>
</list>
</list>
Loading

0 comments on commit dd48f40

Please sign in to comment.