Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/hotfix/2019.1.3' into stable-2019.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeach47 committed Jan 27, 2020
2 parents ecbf6db + 976366c commit 53c4133
Show file tree
Hide file tree
Showing 26 changed files with 535 additions and 249 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ public static boolean delete(Path f, FileCallback callback) {

public static boolean delete(Path f, @Nullable FileCallback callback, boolean failOnError)
throws IOException {
if (LOGGER.isTraceEnabled()) {
// Exposes the code flows that delete files
Exception tracer = new Exception("Debug stack trace - about to delete - " + f.toString());
LOGGER.trace(tracer.getMessage(), tracer);
}
if (!Files.exists(f, LinkOption.NOFOLLOW_LINKS)) {
LOGGER.debug("File does not exist. Could not delete [" + f.toString() + "]");
return true;
}
if (Files.isDirectory(f, LinkOption.NOFOLLOW_LINKS)) {
LOGGER.debug("File is a folder, deleting contents");
LOGGER.debug("File [" + f.toString() + "] is a folder, deleting contents");
try {
final DeleteVisitor visitor = new DeleteVisitor(callback);
Files.walkFileTree(f, EnumSet.noneOf(FileVisitOption.class), Integer.MAX_VALUE, visitor);
Expand Down Expand Up @@ -325,6 +331,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx
}
try {
Files.delete(dir);
LOGGER.warn("Deleting folder " + dir.toString());
} catch (Exception e) {
success = false;
LOGGER.warn("Folder deletion failed. Could not delete " + dir.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
@Entity
@AccessType("field")
public class LtiConsumer extends BaseEntity {
public static final String ATT_CUSTOM_USER_ID = "ATT_CUSTOM_USER_ID";
public static final String ATT_CUSTOM_USERNAME = "ATT_CUSTOM_USERNAME";
public static final String ATT_CUSTOM_ENABLE_ID_PREFIX = "ATT_CUSTOM_ENABLE_ID_PREFIX";

@Index(name = "consumerKey")
@Column(length = 255, nullable = false)
private String consumerKey;
Expand Down
28 changes: 14 additions & 14 deletions Source/Plugins/Core/com.equella.core/plugin-jpf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<parameter id="class" value="com.tle.core.xslt.guice.XsltModule" />
<parameter id="class" value="com.tle.integration.lti.brightspace.guice.BrightspaceIntegrationModule" />
<parameter id="class" value="com.tle.integration.lti.canvasextension.guice.CanvasIntegrationModule" />
<parameter id="class" value="com.tle.integration.lti.blackboard.guice.BlackboardLtiIntegrationModule" />
<parameter id="class" value="com.tle.integration.lti.generic.guice.GenericLtiIntegrationModule" />
<parameter id="class" value="com.tle.integration.standard.guice.StandardIntegrationModule" />
<parameter id="class" value="com.tle.mycontent.guice.MyContentModule" />
<parameter id="class" value="com.tle.mypages.guice.MyPagesModule" />
Expand Down Expand Up @@ -2173,9 +2173,9 @@
<parameter id="id" value="canvas" />
<parameter id="class" value="bean:com.tle.integration.lti.canvasextension.CanvasIntegration" />
</extension>
<extension plugin-id="com.tle.web.integration" point-id="integration" id="blackboardltiintegration">
<parameter id="id" value="blackboardlti" />
<parameter id="class" value="bean:com.tle.integration.lti.blackboard.BlackboardLtiIntegration" />
<extension plugin-id="com.tle.web.integration" point-id="integration" id="genericltiintegration">
<parameter id="id" value="lti" />
<parameter id="class" value="bean:com.tle.integration.lti.generic.GenericLtiIntegration" />
</extension>
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="signon_2">
<parameter id="path" value="/canvassignon.do" />
Expand All @@ -2185,23 +2185,23 @@
<parameter id="path" value="/canvascipreturn.do" />
<parameter id="root" value="bean:/canvascipreturn" />
</extension>
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="signon_blackboardLti">
<parameter id="path" value="/blackboardltisignon.do" />
<parameter id="root" value="bean:/blackboardltisignon" />
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="signon_lti">
<parameter id="path" value="/ltisignon.do" />
<parameter id="root" value="bean:/ltisignon" />
</extension>
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="contentItemPlacementsReturnBlackboardLti">
<parameter id="path" value="/blackboardlticipreturn.do" />
<parameter id="root" value="bean:/blackboardlticipreturn" />
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="contentItemPlacementsReturnLti">
<parameter id="path" value="/lticipreturn.do" />
<parameter id="root" value="bean:/lticipreturn" />
</extension>
<extension plugin-id="com.tle.web.lti" point-id="ltiWrapperExtension" id="canvasLtiExt">
<parameter id="id" value="canvas" />
<parameter id="bean" value="bean:com.tle.integration.lti.canvasextension.CanvasLtiWrapperExtension" />
<parameter id="order" value="1000" />
</extension>
<extension plugin-id="com.tle.web.lti" point-id="ltiWrapperExtension" id="blackboardLtiExt">
<parameter id="id" value="bblti" />
<parameter id="bean" value="bean:com.tle.integration.lti.blackboard.BlackboardLtiWrapperExtension" />
<parameter id="order" value="1000" />
<extension plugin-id="com.tle.web.lti" point-id="ltiWrapperExtension" id="genericLtiExt">
<parameter id="id" value="genlti" />
<parameter id="bean" value="bean:com.tle.integration.lti.generic.GenericLtiWrapperExtension" />
<parameter id="order" value="9000" />
</extension>
<extension plugin-id="com.tle.web.connectors" point-id="connectorEditor" id="moodleEditor">
<parameter id="id" value="moodle" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,10 @@ editor.container.option.default=Default
editor.container.option.embed=Embed
editor.container.option.newwindow=New window
editor.customparams=Custom parameters
editor.custom.lti.params.help=The following custom LTI parameters are only in effect for the /ltisignon.do endpoint
editor.custom.lti.params.user.id=Custom user ID
editor.custom.lti.params.username=Custom username attribute
editor.custom.lti.params.prefix.id=Prefix the user ID with a value unique to this consumer
editor.dropdown.option.choosetype=Choose a connector type...
editor.email=Share launcher's email with tool
editor.error.accessdenied=You do not have the required permission to access this page\: {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<#include "/com.tle.web.sections.standard@/dropdown.ftl" />
<#include "/com.tle.web.sections.standard@/textfield.ftl"/>
<#include "/com.tle.web.sections.standard@/autocomplete.ftl"/>

<@css "editconsumer.css" />

<@setting label=b.key("editor.key") mandatory=true error=m.errors["key"]>
Expand All @@ -21,6 +20,18 @@
<@setting label=b.key("editor.postfix") help=b.key("editor.username.help")>
<@textfield section=s.postfixField maxlength=50 />
</@setting>
<hr/>
<@setting label='' help=b.key('editor.custom.lti.params.help') />
<@setting label=b.key("editor.custom.lti.params.user.id")>
<@textfield section=s.customUserIdParameterField maxlength=128 />
</@setting>
<@setting label=b.key("editor.custom.lti.params.username")>
<@textfield section=s.customUsernameParameterField maxlength=128 />
</@setting>
<@setting label=''>
<div class="input checkbox"><@render s.customEnableIdPrefixField /></div>
</@setting>
<hr/>
<@a.div id="allowed">
<@setting label=b.key("editor.allowed.label") help=b.key("editor.allowed.help")>
${m.prettyExpression}
Expand All @@ -40,8 +51,8 @@
</@a.div>
<@a.div id="customrole">
<@setting label=b.key("editor.role.custom.label") error=m.errors["nocustomrole"] help=b.key("editor.role.custom.help")>
<@render section=s.customRolesTable />
<@autocomplete section=s.customRoleField class="custom-role" placeholder=b.key("editor.role.custom.placeholder") />
<@render section=s.customRolesTable />
<@autocomplete section=s.customRoleField class="custom-role" placeholder=b.key("editor.role.custom.placeholder") />
<@render section=s.customRoleDialog.opener class="add">${b.key("editor.table.roles.add")}</@render>
</@setting>
</@a.div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ public void removeStagingArea(StagingFile staging, boolean removeFiles) {
if (s == null) {
LOGGER.error("Staging area does not exist");
} else {
LOGGER.debug("Deleting Staging entry in DB [" + s.getStagingID() + "]");
stagingDao.delete(s);
}

if (removeFiles) {
LOGGER.debug("Removing Staging area in the filestore [" + s.getStagingID() + "]");
fileSystemService.removeFile(staging);
}
}
Expand Down Expand Up @@ -100,9 +102,10 @@ public void matched(Path file, String relFilepath) {
String uuid = file.getFileName().toString();
if (!stagingExists(uuid)) {
try {
LOGGER.debug("Deleting staging area [" + uuid + "]");
FileUtils.delete(file, null, true);
} catch (IOException ex) {
LOGGER.warn("Could not delete staging area: " + uuid, ex);
LOGGER.warn("Could not delete staging area [" + uuid + "]", ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ public class SchedulerModule extends OptionalConfigModule {
protected void configure() {
bindInt("com.tle.core.tasks.RemoveDeletedItems.daysBeforeRemoval");
bindInt("com.tle.core.tasks.RemoveOldAuditLogs.daysBeforeRemoval");
bindBoolean("com.tle.core.tasks.RemoveStagingAreas.enable", true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,29 @@
import com.tle.core.guice.Bind;
import com.tle.core.scheduler.ScheduledTask;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.log4j.Logger;

/** @author Nicholas Read */
@Bind
@Singleton
public class RemoveStagingAreas implements ScheduledTask {
private static final Logger LOGGER = Logger.getLogger(RemoveStagingAreas.class);

@Inject private StagingService stagingService;

@com.google.inject.Inject(optional = true)
@Named("com.tle.core.tasks.RemoveStagingAreas.enable")
// Can be overrode by the optional-config.properties
private boolean enableTask = true;

@Override
public void execute() {
stagingService.removeUnusedStagingAreas();
if (enableTask) {
stagingService.removeUnusedStagingAreas();
} else {
LOGGER.debug("RemoveStagingAreas is disabled. Not running task.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public FileInfo write(
} catch (AccessDeniedException ex) {
String serviceUser = System.getProperty("user.name");
throw new IOException(
"Couldn't create directories on file store. Are you sure that EQUELLA running as '"
"Couldn't create directories on file store. Are you sure that openEQUELLA running as '"
+ serviceUser
+ "' user has the correct permissions?",
ex);
Expand Down Expand Up @@ -426,29 +426,44 @@ public void commitFiles(TemporaryFileHandle staging, String folder, FileHandle d
File from = getFile(staging, folder);
File to = getFile(destination);

LOGGER.info("commitFiles: from " + from.getAbsolutePath());
LOGGER.info("commitFiles: to " + to.getAbsolutePath());
final String fromStr = from.getAbsolutePath();
final String toStr = to.getAbsolutePath();
LOGGER.info("commitFiles: from [" + fromStr + "] to [" + toStr + "]");

File trash = null;
if (FileSystemHelper.exists(to)) {
LOGGER.debug("Destination exists renaming");
LOGGER.debug("Destination [" + to + "] exists. Moving to a staging 'trash' folder");
trash = getFile(new TrashFile(staging));
LOGGER.debug("Moving current to trash");
LOGGER.debug("Moving current [" + to + "] to trash [" + trash + "]");

if (!FileSystemHelper.rename(to, trash, false)) {
FileSystemHelper.rename(trash, to, true);
throw new FileSystemException("Couldn't move to Trash.");
throw new FileSystemException("Couldn't move [" + to + "] to trash [" + trash + "].");
}
}

LOGGER.debug("About to rename staging to real item");
LOGGER.debug("About to rename staging [" + from + "] to real item [" + to + "].");
if (!FileSystemHelper.exists(from)) {
LOGGER.debug("no files to commit - making blank dir");
LOGGER.debug("no files to commit - making blank dir [" + to + "]");
FileSystemHelper.mkdir(to);
} else {
LOGGER.debug("Renaming staging to real item");
LOGGER.debug("Renaming staging [" + from + "] to real item [" + to + "]");
if (!FileSystemHelper.rename(from, to, false)) {
LOGGER.debug(
"The rename of staging ["
+ from
+ "] to real item ["
+ to
+ "] didn't work. Trying rename of trash to real item.");
if (trash != null) {
FileSystemHelper.rename(trash, to, true);
if (!FileSystemHelper.rename(trash, to, true)) {
LOGGER.debug(
"The rename of trash ["
+ trash
+ "] to real item ["
+ to
+ "] didn't work. Silently proceeding.");
}
}
throw new FileSystemException(
"Failed to commit to staging: "
Expand All @@ -459,10 +474,10 @@ public void commitFiles(TemporaryFileHandle staging, String folder, FileHandle d
}

if (trash != null) {
LOGGER.debug("Deleting trash");
LOGGER.debug("Deleting trash [" + trash + "]");
FileUtils.delete(trash.toPath(), null);
}
LOGGER.debug("Done");
LOGGER.debug("Done committing files from [" + staging + "] to [" + to + "]");
}

@Override
Expand Down

This file was deleted.

Loading

0 comments on commit 53c4133

Please sign in to comment.