Skip to content

Commit 25b17cf

Browse files
committed
Merge branch 'hotfix/2021.1.2'
2 parents 28b28e9 + 08d62ed commit 25b17cf

File tree

12 files changed

+65
-15
lines changed

12 files changed

+65
-15
lines changed

Source/Plugins/Core/com.equella.core/scalasrc/com/tle/web/api/search/SearchHelper.scala

+8-2
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,14 @@ object SearchHelper {
324324
*/
325325
def getBrokenAttachmentStatusForResourceAttachment(
326326
customAttachment: CustomAttachment): Boolean = {
327-
val key = new ItemId(customAttachment.getData("uuid").asInstanceOf[String],
328-
customAttachment.getData("version").asInstanceOf[Int])
327+
val uuid = customAttachment.getData("uuid").asInstanceOf[String]
328+
// If version of the linked Item is 0, find the latest version of this Item.
329+
val version = customAttachment.getData("version").asInstanceOf[Int] match {
330+
case 0 => LegacyGuice.itemService.getLatestVersion(uuid)
331+
case realVersion => realVersion
332+
}
333+
334+
val key = new ItemId(uuid, version)
329335
if (customAttachment.getType != "resource") {
330336
return false;
331337
}

Source/Plugins/Core/com.equella.core/src/com/tle/integration/lti/canvasextension/CanvasContentItemPlacementReturn.java

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public SectionResult renderHtml(RenderEventContext context) throws Exception {
122122
}
123123
}
124124
formTag.addReadyStatements(
125+
integrationService.updateFormSubmittingFlag(true),
125126
Js.statement(
126127
Js.methodCall(Jq.$('#' + formTag.getElementId(context)), Js.function("submit"))));
127128
return null;

Source/Plugins/Core/com.equella.core/src/com/tle/integration/lti/generic/GenericLtiContentItemPlacementReturn.java

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public SectionResult renderHtml(RenderEventContext context) throws Exception {
124124
}
125125

126126
formTag.addReadyStatements(
127+
integrationService.updateFormSubmittingFlag(true),
127128
Js.statement(
128129
Js.methodCall(Jq.$('#' + formTag.getElementId(context)), Js.function("submit"))));
129130
return null;

Source/Plugins/Core/com.equella.core/src/com/tle/web/externaltools/viewer/ExternalToolViewerSection.java

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import com.tle.core.institution.InstitutionService;
5757
import com.tle.core.services.ApplicationVersion;
5858
import com.tle.core.services.http.Request.Method;
59+
import com.tle.web.integration.service.IntegrationService;
5960
import com.tle.web.lti.LtiData.OAuthData;
6061
import com.tle.web.lti.usermanagement.LtiUserState;
6162
import com.tle.web.oauth.service.OAuthWebService;
@@ -104,6 +105,7 @@ public class ExternalToolViewerSection
104105
@Named("external.tool.contact.email")
105106
private String externalToolContactEmail = "";
106107

108+
@Inject private IntegrationService integrationService;
107109
@Inject private ExternalToolsService toolService;
108110
@Inject private OAuthWebService oauthWebService;
109111
@Inject private InstitutionService institutionService;
@@ -235,6 +237,7 @@ public SectionResult view(RenderContext context, ViewItemResource resource) thro
235237
// a neater way of calling "submit" than to have a dedicated one-line
236238
// javascript file
237239
formTag.addReadyStatements(
240+
integrationService.updateFormSubmittingFlag(true),
238241
Js.statement(
239242
Js.methodCall(Jq.$('#' + formTag.getElementId(context)), Js.function("submit"))));
240243
return null;

Source/Plugins/Core/com.equella.core/src/com/tle/web/integration/service/IntegrationService.java

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.tle.web.integration.IntegrationSessionData;
2828
import com.tle.web.integration.SingleSignonForm;
2929
import com.tle.web.sections.SectionInfo;
30+
import com.tle.web.sections.js.JSStatements;
3031
import com.tle.web.selection.SelectionSession;
3132

3233
@SuppressWarnings("nls")
@@ -77,4 +78,12 @@ void standardForward(
7778
SingleSignonForm form);
7879

7980
void checkIntegrationAllowed() throws AccessDeniedException;
81+
82+
/**
83+
* Function to return a script which controls whether to allow submitting the LTI Launch form.
84+
*
85+
* @param isAllowed `true` to allow submitting the form.
86+
* @return A JS script which will update the flag.
87+
*/
88+
JSStatements updateFormSubmittingFlag(boolean isAllowed);
8089
}

Source/Plugins/Core/com.equella.core/src/com/tle/web/integration/service/impl/IntegrationServiceImpl.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
import com.tle.web.sections.SectionsController;
5252
import com.tle.web.sections.SectionsRuntimeException;
5353
import com.tle.web.sections.generic.AbstractSectionFilter;
54+
import com.tle.web.sections.js.JSStatements;
55+
import com.tle.web.sections.js.generic.Js;
56+
import com.tle.web.sections.js.generic.expression.ScriptExpression;
5457
import com.tle.web.selection.*;
5558
import com.tle.web.selection.section.RootSelectionSection.Layout;
5659
import com.tle.web.viewable.ViewableItemResolver;
@@ -70,6 +73,7 @@
7073
import javax.inject.Inject;
7174
import javax.inject.Named;
7275
import javax.inject.Singleton;
76+
import org.apache.commons.collections.CollectionUtils;
7377

7478
@SuppressWarnings("nls")
7579
@Bind(IntegrationService.class)
@@ -471,8 +475,13 @@ public void checkIntegrationAllowed() throws AccessDeniedException {
471475

472476
private void updateIntegrationMimeTypes(SectionInfo info, IntegrationSection integrationSection) {
473477
SelectionSession selectionSession = selectionService.getCurrentSession(info);
474-
if (selectionSession != null && !selectionSession.getMimeTypes().isEmpty()) {
478+
if (selectionSession != null && !CollectionUtils.isEmpty(selectionSession.getMimeTypes())) {
475479
integrationSection.updateModelMimeTypes(info, selectionSession.getMimeTypes());
476480
}
477481
}
482+
483+
@Override
484+
public JSStatements updateFormSubmittingFlag(boolean isAllowed) {
485+
return Js.statement(new ScriptExpression("g_bSubmitting = " + isAllowed));
486+
}
478487
}

autotest/OldTests/src/test/java/com/tle/webtests/test/viewing/ItemSummaryTest.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void testViewCount() {
134134
public void testAttachmentViewCount() {
135135
final String linkAttachment = "https://archive.org/";
136136

137-
final String archiveOrgPreambleString = "div.preamble-whoweare";
137+
final By title = By.xpath("//title[contains(text(),'Internet Archive')]");
138138
logon(AUTOTEST_LOGON, AUTOTEST_PASSWD);
139139

140140
final WizardPageTab wizard = new ContributePage(context).load().openWizard(COLLECTION3);
@@ -145,9 +145,7 @@ public void testAttachmentViewCount() {
145145
checkViews(summary, 1, linkAttachment, 0);
146146

147147
// view the attachment and go back
148-
summary
149-
.attachments()
150-
.viewLinkAttachment(linkAttachment, By.cssSelector(archiveOrgPreambleString));
148+
summary.attachments().viewLinkAttachment(linkAttachment, title);
151149
final WebDriver.Navigation navigate = context.getDriver().navigate();
152150
navigate.back();
153151
// navigate.refresh();
@@ -157,9 +155,7 @@ public void testAttachmentViewCount() {
157155
checkViews(summary, 2, linkAttachment, 1);
158156

159157
// view the attachment again and go back
160-
summary
161-
.attachments()
162-
.viewLinkAttachment(linkAttachment, By.cssSelector(archiveOrgPreambleString));
158+
summary.attachments().viewLinkAttachment(linkAttachment, title);
163159
navigate.back();
164160
// navigate.refresh();
165161

autotest/OldTests/src/test/java/com/tle/webtests/test/webservices/rest/ItemApiViewTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private void assertAttachments(JsonNode tree) {
195195
assertPackageResource(attachments.get(8));
196196
assertPackage(attachments.get(9));
197197
assertZip(attachments.get(11));
198-
assertEquals(attachments.size(), 12);
198+
assertEquals(attachments.size(), 13);
199199
}
200200

201201
private void assertAll(ObjectNode tree) {

autotest/Tests/tests/rest/institution/items/4/117508.xml

+25-1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,30 @@
251251
<preview>false</preview>
252252
<restricted>false</restricted>
253253
</com.tle.beans.item.attachments.ZipAttachment>
254+
<com.tle.beans.item.attachments.CustomAttachment>
255+
<id>39144</id>
256+
<uuid>0287b02d-a69d-403e-92a5-a87a7c92977c</uuid>
257+
<url></url>
258+
<description>SearchApiTest - Edits</description>
259+
<value1>resource</value1>
260+
<data>
261+
<entry>
262+
<string>type</string>
263+
<string>p</string>
264+
</entry>
265+
<entry>
266+
<string>uuid</string>
267+
<string>8a9ea41c-e28d-45de-b0a5-d75bca48d701</string>
268+
</entry>
269+
<entry>
270+
<string>version</string>
271+
<int>0</int>
272+
</entry>
273+
</data>
274+
<preview>false</preview>
275+
<restricted>false</restricted>
276+
<erroredIndexing>false</erroredIndexing>
277+
</com.tle.beans.item.attachments.CustomAttachment>
254278
</attachments>
255279
<itemDefinition entityclass="com.tle.beans.entity.itemdef.ItemDefinition" uuid="9a1ddb24-6bf5-db3d-d8fe-4fca20ecf69c"/>
256280
<collaborators>
@@ -545,4 +569,4 @@
545569
<manualNavigation>false</manualNavigation>
546570
</navigationSettings>
547571
<thumb>initial</thumb>
548-
</com.tle.beans.item.Item>
572+
</com.tle.beans.item.Item>
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
<xml><item><attachments><attachment1>63862d54-1b6d-4dce-9a79-44b3a8c9e107</attachment1><attachment1>32f45d7c-6df7-44d8-926a-3d6f841c2009</attachment1><attachment1>32a79ea6-8b67-4b38-af85-341b2d512f09</attachment1><attachment1>78a2de74-96de-48de-8865-22856c22ae49</attachment1><attachment1>b24aa5fa-de50-4021-b7c4-ac4d3a918129</attachment1><attachment1>dd26b4ac-9592-4062-bd15-cb9691bfe9a3</attachment1><attachment1>221b8a48-3a35-4d29-ad3a-0f04a1536b3b</attachment1><attachment1>20196bbc-7f5f-44a4-980d-55dab4e6eec9</attachment1><attachment1>034dfcb7-b66a-45bf-98c8-03da9011c74d</attachment1><attachment1>4398bcda-4127-41d7-ab42-d2f0f8b9b100</attachment1></attachments><name>ItemApiViewTest - All attachments</name></item></xml>
1+
<xml><item><attachments><attachment1>63862d54-1b6d-4dce-9a79-44b3a8c9e107</attachment1><attachment1>32f45d7c-6df7-44d8-926a-3d6f841c2009</attachment1><attachment1>32a79ea6-8b67-4b38-af85-341b2d512f09</attachment1><attachment1>78a2de74-96de-48de-8865-22856c22ae49</attachment1><attachment1>b24aa5fa-de50-4021-b7c4-ac4d3a918129</attachment1><attachment1>dd26b4ac-9592-4062-bd15-cb9691bfe9a3</attachment1><attachment1>221b8a48-3a35-4d29-ad3a-0f04a1536b3b</attachment1><attachment1>20196bbc-7f5f-44a4-980d-55dab4e6eec9</attachment1><attachment1>034dfcb7-b66a-45bf-98c8-03da9011c74d</attachment1><attachment1>4398bcda-4127-41d7-ab42-d2f0f8b9b100</attachment1><attachment1>0287b02d-a69d-403e-92a5-a87a7c92977c</attachment1></attachments>
2+
<name>ItemApiViewTest - All attachments</name></item></xml>

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ name := "Equella"
116116

117117
equellaMajor in ThisBuild := 2021
118118
equellaMinor in ThisBuild := 1
119-
equellaPatch in ThisBuild := 1
119+
equellaPatch in ThisBuild := 2
120120
equellaStream in ThisBuild := "Stable"
121121
equellaBuild in ThisBuild := buildConfig.value.getString("build.buildname")
122122

buildspec.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ phases:
1111
commands:
1212
- env | sort | grep -vi -e key -e secret -e password
1313
- setupBuild
14-
- . $NVM_DIR/nvm.sh && nvm install # version from nvmrc
14+
- . $NVM_DIR/nvm.sh && set +a && nvm install # version from nvmrc
1515
- npm config set unsafe-perm true
1616
install:
1717
commands:

0 commit comments

Comments
 (0)