Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ private JobUtils()
*/
public static boolean isSerializable(JobStatus status)
{
if (status.getRequest().getId() == null || !status.isSerialized()) {
if (status == null || status.getRequest() == null || status.getRequest().getId() == null
|| !status.isSerialized()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.File;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;
Expand Down Expand Up @@ -51,18 +52,29 @@ public abstract class AbstractJobStatusFolderResolver implements JobStatusFolder
@Override
public File getFolder(List<String> id)
{
File folder = getBaseFolder();
File folder = this.configuration.getStorage();

if (id != null) {
// Create a different folder for each element
for (String fullIdElement : id) {
folder = addIDElement(fullIdElement, folder);
}
for (String pathSegment : getFolderSegments(id)) {
folder = new File(folder, pathSegment);
}

return folder;
}

@Override
public List<String> getFolderSegments(List<String> jobID)
{
List<String> result = new ArrayList<>(getBaseFolderSegments());

if (jobID != null) {
for (String idElement : jobID) {
result.addAll(encodeAndSplit(idElement));
}
}

return result;
}

protected String nullAwareURLEncode(String value)
{
String encoded;
Expand All @@ -76,10 +88,17 @@ protected String nullAwareURLEncode(String value)
return encoded;
}

protected File getBaseFolder()
/**
* @return the base folder segments for the job status folder, override to provide a custom base folder
*/
protected List<String> getBaseFolderSegments()
{
return this.configuration.getStorage();
return List.of();
}

protected abstract File addIDElement(String idElement, File folder);
/**
* @param idElement the id element to encode and split
* @return the encoded and split id element
*/
protected abstract List<String> encodeAndSplit(String idElement);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* @version $Id$
* @since 4.0M1
* @deprecated since 6.1M2, use {@link org.xwiki.job.internal.DefaultJobStatusStore} instead
* @deprecated since 6.1M2, use {@link DefaultJobStatusStore} instead
*/
@Component
@Singleton
Expand Down
Loading