Skip to content

Commit

Permalink
Merge remote-tracking branch 'edalex/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
edalex-ian committed Nov 6, 2024
2 parents a72cb85 + 63a492d commit 1b6672d
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class FileEntry implements Serializable {
private List<FileEntry> files = new ArrayList<FileEntry>();
private String name;
private long length;
private String systemPath;

public FileEntry(boolean folder) {
this.folder = folder;
Expand All @@ -39,6 +40,7 @@ public FileEntry(File file) {
this.name = file.getName();
this.folder = file.isDirectory();
this.length = (this.folder ? 0 : file.length());
this.systemPath = file.getAbsolutePath();
}

public List<FileEntry> getFiles() {
Expand Down Expand Up @@ -73,6 +75,10 @@ public void setLength(long length) {
this.length = length;
}

public String getSystemPath() {
return systemPath;
}

public List<String> foldToPaths() {
final List<String> paths = new ArrayList<String>();
foldToPathsHelper(this, "", paths, false); // $NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.io.CharStreams;
import com.rometools.utils.Strings;
import com.tle.common.Check;
import com.tle.common.URLUtils;
import com.tle.common.Utils;
import com.tle.common.beans.exception.NotFoundException;
import com.tle.common.filesystem.FileEntry;
Expand Down Expand Up @@ -561,7 +562,7 @@ public void propFindMethod(
return;
}

String uri = basepath + '/' + staging.getUuid() + '/' + filename;
String uri = basepath + '/' + staging.getUuid() + '/' + URLUtils.urlEncode(filename);
boolean isDir = fileSystemService.fileIsDir(staging, filename);
// http://www.webdav.org/specs/rfc2518.html#collection.resources
// folders should end with '/'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
import com.tle.common.URLUtils;
import com.tle.common.filesystem.FileEntry;
import com.tle.core.mimetypes.MimeTypeService;
import java.io.File;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

/** @author aholland */
Expand Down Expand Up @@ -90,6 +96,7 @@ public void addFileProps(String parentName, FileEntry file) {
addProp("resourcetype", "");
addProp("getcontenttype", mimeTypeService.getMimeTypeForFilename(filename));
addProp("getcontentlength", Long.toString(file.getLength()));
addProp("getlastmodified", getFileRFC1123Date(file));
addProp("iscollection", "0");
addProp("isfolder", "0");
addCommonProps(parentName, filename);
Expand Down Expand Up @@ -119,4 +126,25 @@ private void addCommonProps(String parentName, String filename) {
addProp("ishidden", "0");
addProp("isreadonly", "0");
}

/**
* Get the RFC 1123 formatted date for the last modified date of the file entry as this is the
* format required by WebDAV.
*
* @param file The file entry to get the last modified date for
* @return The RFC 1123 formatted date for the last modified date of the file entry
*/
private static String getFileRFC1123Date(FileEntry file) {
final long lastModified = new File(file.getSystemPath()).lastModified();
Instant lastModifiedInstant = Instant.ofEpochMilli(lastModified);
ZonedDateTime lastModifiedGMT = ZonedDateTime.ofInstant(lastModifiedInstant, ZoneId.of("GMT"));

// Create a formatter for RFC 1123 format
DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH)
.withZone(ZoneId.of("GMT"));

// Format the date and return
return lastModifiedGMT.format(formatter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public enum Operation {
private boolean lockedForEditing = false;
private boolean mergeDRMDefaults = false;
private boolean entryThroughEdit = false;
// Real version of the original item which indicates the new state is initiated through
// the option of "new version" in the summary page.
private int originalItemVer = 0;
private boolean noCancel = false;
private boolean newItem;
private boolean movedItem; // changed collection
Expand Down Expand Up @@ -482,4 +485,16 @@ public void setStateVersion(int stateVersion) {
public int getStateVersion() {
return stateVersion;
}

public int getOriginalItemVer() {
return originalItemVer;
}

public void setOriginalItemVer(int originalItemVer) {
this.originalItemVer = originalItemVer;
}

public boolean isEntryThroughNewVersion() {
return originalItemVer != 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.tle.beans.entity.FederatedSearch;
import com.tle.beans.entity.itemdef.ItemDefinition;
import com.tle.beans.item.ItemId;
import com.tle.beans.item.ItemKey;
import com.tle.common.Check;
import com.tle.core.collection.service.ItemDefinitionService;
import com.tle.core.fedsearch.FederatedSearchService;
Expand Down Expand Up @@ -93,6 +95,12 @@ public void execute(SectionInfo info, WizardSectionInfo winfo, String data) thro
// forward to viewing the item we are editing
final ViewItemUrl vurl = viewItemUrl.createItemUrl(info, state.getItemId());
vurl.forward(info);
} else if (state.isEntryThroughNewVersion()) {
ItemKey newItemKey = state.getItemId();
ItemKey originalItemKey = new ItemId(newItemKey.getUuid(), state.getOriginalItemVer());
// forward to viewing the original item
final ViewItemUrl vurl = viewItemUrl.createItemUrl(info, originalItemKey);
vurl.forward(info);
} else {
if (forwardToContribute(info)) {
// forward to contribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@
import com.tle.core.item.standard.operations.SaveOperation;
import com.tle.core.item.standard.operations.workflow.StatusOperation;
import com.tle.core.item.standard.service.MetadataMappingService;
import com.tle.core.plugins.*;
import com.tle.core.plugins.AbstractPluginService;
import com.tle.core.plugins.ClassBeanLocator;
import com.tle.core.plugins.FactoryMethodLocator;
import com.tle.core.plugins.PluginService;
import com.tle.core.plugins.PluginTracker;
import com.tle.core.quota.service.QuotaService;
import com.tle.core.scripting.service.StandardScriptContextParams;
import com.tle.core.services.FileSystemService;
Expand Down Expand Up @@ -448,6 +452,7 @@ public void newVersion(WizardState state) {
}

Item item = itemPack.getItem();
state.setOriginalItemVer(itemKey.getVersion());
state.setMergeDRMDefaults(false);
state.setItemPack(itemPack);
state.setItemId(new ItemId(item.getUuid(), item.getVersion()));
Expand Down
8 changes: 4 additions & 4 deletions Source/Plugins/Core/com.equella.reporting/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ lazy val Birt = config("birt")
lazy val CustomCompile = config("compile") extend Birt

libraryDependencies ++= Seq(
"com.github.openequella" % "birt-report-framework" % "4.16.0" artifacts Artifact(
"com.github.openequella" % "birt-report-framework" % "4.9.2" artifacts Artifact(
"birt-report-framework",
Artifact.DefaultType,
"zip"),
"com.github.openequella" % "birt-osgi" % "4.16.0" artifacts Artifact("birt-osgi",
Artifact.DefaultType,
"zip"),
"com.github.openequella" % "birt-osgi" % "4.9.2" artifacts Artifact("birt-osgi",
Artifact.DefaultType,
"zip"),
"com.github.equella.reporting" % "reporting-common" % "6.5",
"com.github.equella.reporting" % "reporting-oda" % "6.5",
"com.github.equella.reporting" % "reporting-oda-connectors" % "6.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.tle.webtests.test.AbstractCleanupTest;
import com.tle.webtests.test.files.Attachments;
import org.testng.annotations.Test;
import testng.annotation.RetryTest;

/**
* Test Reference: http://time/DTEC/test/editTest.aspx?testId=14957 Test Reference:
Expand All @@ -25,6 +26,7 @@
*
* @author larry, among others lost in the mists of time
*/
@RetryTest(5)
@TestInstitution("myresources")
public class MyResourcesTest extends AbstractCleanupTest {

Expand Down

0 comments on commit 1b6672d

Please sign in to comment.