Skip to content

Commit

Permalink
Merge branch 'hotfix/2021.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
PenghaiZhang committed Nov 12, 2021
2 parents 28b28e9 + 08d62ed commit 25b17cf
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,14 @@ object SearchHelper {
*/
def getBrokenAttachmentStatusForResourceAttachment(
customAttachment: CustomAttachment): Boolean = {
val key = new ItemId(customAttachment.getData("uuid").asInstanceOf[String],
customAttachment.getData("version").asInstanceOf[Int])
val uuid = customAttachment.getData("uuid").asInstanceOf[String]
// If version of the linked Item is 0, find the latest version of this Item.
val version = customAttachment.getData("version").asInstanceOf[Int] match {
case 0 => LegacyGuice.itemService.getLatestVersion(uuid)
case realVersion => realVersion
}

val key = new ItemId(uuid, version)
if (customAttachment.getType != "resource") {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public SectionResult renderHtml(RenderEventContext context) throws Exception {
}
}
formTag.addReadyStatements(
integrationService.updateFormSubmittingFlag(true),
Js.statement(
Js.methodCall(Jq.$('#' + formTag.getElementId(context)), Js.function("submit"))));
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public SectionResult renderHtml(RenderEventContext context) throws Exception {
}

formTag.addReadyStatements(
integrationService.updateFormSubmittingFlag(true),
Js.statement(
Js.methodCall(Jq.$('#' + formTag.getElementId(context)), Js.function("submit"))));
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.tle.core.institution.InstitutionService;
import com.tle.core.services.ApplicationVersion;
import com.tle.core.services.http.Request.Method;
import com.tle.web.integration.service.IntegrationService;
import com.tle.web.lti.LtiData.OAuthData;
import com.tle.web.lti.usermanagement.LtiUserState;
import com.tle.web.oauth.service.OAuthWebService;
Expand Down Expand Up @@ -104,6 +105,7 @@ public class ExternalToolViewerSection
@Named("external.tool.contact.email")
private String externalToolContactEmail = "";

@Inject private IntegrationService integrationService;
@Inject private ExternalToolsService toolService;
@Inject private OAuthWebService oauthWebService;
@Inject private InstitutionService institutionService;
Expand Down Expand Up @@ -235,6 +237,7 @@ public SectionResult view(RenderContext context, ViewItemResource resource) thro
// a neater way of calling "submit" than to have a dedicated one-line
// javascript file
formTag.addReadyStatements(
integrationService.updateFormSubmittingFlag(true),
Js.statement(
Js.methodCall(Jq.$('#' + formTag.getElementId(context)), Js.function("submit"))));
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.tle.web.integration.IntegrationSessionData;
import com.tle.web.integration.SingleSignonForm;
import com.tle.web.sections.SectionInfo;
import com.tle.web.sections.js.JSStatements;
import com.tle.web.selection.SelectionSession;

@SuppressWarnings("nls")
Expand Down Expand Up @@ -77,4 +78,12 @@ void standardForward(
SingleSignonForm form);

void checkIntegrationAllowed() throws AccessDeniedException;

/**
* Function to return a script which controls whether to allow submitting the LTI Launch form.
*
* @param isAllowed `true` to allow submitting the form.
* @return A JS script which will update the flag.
*/
JSStatements updateFormSubmittingFlag(boolean isAllowed);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
import com.tle.web.sections.SectionsController;
import com.tle.web.sections.SectionsRuntimeException;
import com.tle.web.sections.generic.AbstractSectionFilter;
import com.tle.web.sections.js.JSStatements;
import com.tle.web.sections.js.generic.Js;
import com.tle.web.sections.js.generic.expression.ScriptExpression;
import com.tle.web.selection.*;
import com.tle.web.selection.section.RootSelectionSection.Layout;
import com.tle.web.viewable.ViewableItemResolver;
Expand All @@ -70,6 +73,7 @@
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.commons.collections.CollectionUtils;

@SuppressWarnings("nls")
@Bind(IntegrationService.class)
Expand Down Expand Up @@ -471,8 +475,13 @@ public void checkIntegrationAllowed() throws AccessDeniedException {

private void updateIntegrationMimeTypes(SectionInfo info, IntegrationSection integrationSection) {
SelectionSession selectionSession = selectionService.getCurrentSession(info);
if (selectionSession != null && !selectionSession.getMimeTypes().isEmpty()) {
if (selectionSession != null && !CollectionUtils.isEmpty(selectionSession.getMimeTypes())) {
integrationSection.updateModelMimeTypes(info, selectionSession.getMimeTypes());
}
}

@Override
public JSStatements updateFormSubmittingFlag(boolean isAllowed) {
return Js.statement(new ScriptExpression("g_bSubmitting = " + isAllowed));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void testViewCount() {
public void testAttachmentViewCount() {
final String linkAttachment = "https://archive.org/";

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

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

// view the attachment and go back
summary
.attachments()
.viewLinkAttachment(linkAttachment, By.cssSelector(archiveOrgPreambleString));
summary.attachments().viewLinkAttachment(linkAttachment, title);
final WebDriver.Navigation navigate = context.getDriver().navigate();
navigate.back();
// navigate.refresh();
Expand All @@ -157,9 +155,7 @@ public void testAttachmentViewCount() {
checkViews(summary, 2, linkAttachment, 1);

// view the attachment again and go back
summary
.attachments()
.viewLinkAttachment(linkAttachment, By.cssSelector(archiveOrgPreambleString));
summary.attachments().viewLinkAttachment(linkAttachment, title);
navigate.back();
// navigate.refresh();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private void assertAttachments(JsonNode tree) {
assertPackageResource(attachments.get(8));
assertPackage(attachments.get(9));
assertZip(attachments.get(11));
assertEquals(attachments.size(), 12);
assertEquals(attachments.size(), 13);
}

private void assertAll(ObjectNode tree) {
Expand Down
26 changes: 25 additions & 1 deletion autotest/Tests/tests/rest/institution/items/4/117508.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,30 @@
<preview>false</preview>
<restricted>false</restricted>
</com.tle.beans.item.attachments.ZipAttachment>
<com.tle.beans.item.attachments.CustomAttachment>
<id>39144</id>
<uuid>0287b02d-a69d-403e-92a5-a87a7c92977c</uuid>
<url></url>
<description>SearchApiTest - Edits</description>
<value1>resource</value1>
<data>
<entry>
<string>type</string>
<string>p</string>
</entry>
<entry>
<string>uuid</string>
<string>8a9ea41c-e28d-45de-b0a5-d75bca48d701</string>
</entry>
<entry>
<string>version</string>
<int>0</int>
</entry>
</data>
<preview>false</preview>
<restricted>false</restricted>
<erroredIndexing>false</erroredIndexing>
</com.tle.beans.item.attachments.CustomAttachment>
</attachments>
<itemDefinition entityclass="com.tle.beans.entity.itemdef.ItemDefinition" uuid="9a1ddb24-6bf5-db3d-d8fe-4fca20ecf69c"/>
<collaborators>
Expand Down Expand Up @@ -545,4 +569,4 @@
<manualNavigation>false</manualNavigation>
</navigationSettings>
<thumb>initial</thumb>
</com.tle.beans.item.Item>
</com.tle.beans.item.Item>
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<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>
<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>
<name>ItemApiViewTest - All attachments</name></item></xml>
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ name := "Equella"

equellaMajor in ThisBuild := 2021
equellaMinor in ThisBuild := 1
equellaPatch in ThisBuild := 1
equellaPatch in ThisBuild := 2
equellaStream in ThisBuild := "Stable"
equellaBuild in ThisBuild := buildConfig.value.getString("build.buildname")

Expand Down
2 changes: 1 addition & 1 deletion buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ phases:
commands:
- env | sort | grep -vi -e key -e secret -e password
- setupBuild
- . $NVM_DIR/nvm.sh && nvm install # version from nvmrc
- . $NVM_DIR/nvm.sh && set +a && nvm install # version from nvmrc
- npm config set unsafe-perm true
install:
commands:
Expand Down

0 comments on commit 25b17cf

Please sign in to comment.