-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site/folder validation UI improvements (#5557)
- Loading branch information
1 parent
e07ede3
commit 197eae2
Showing
7 changed files
with
372 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
core/src/org/labkey/core/admin/sitevalidation/SiteValidationJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.labkey.core.admin.sitevalidation; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.labkey.api.pipeline.PipeRoot; | ||
import org.labkey.api.pipeline.PipelineJob; | ||
import org.labkey.api.util.FileUtil; | ||
import org.labkey.api.util.StringUtilsLabKey; | ||
import org.labkey.api.util.URLHelper; | ||
import org.labkey.api.view.ActionURL; | ||
import org.labkey.api.view.JspTemplate; | ||
import org.labkey.api.view.ViewBackgroundInfo; | ||
import org.labkey.api.view.ViewContext; | ||
import org.labkey.core.admin.AdminController.SiteValidationForm; | ||
import org.labkey.core.admin.AdminController.ViewValidationResultsAction; | ||
|
||
import java.io.File; | ||
import java.io.PrintWriter; | ||
|
||
public class SiteValidationJob extends PipelineJob | ||
{ | ||
private final SiteValidationForm _form; | ||
|
||
@JsonCreator | ||
protected SiteValidationJob(@JsonProperty("_form") SiteValidationForm form) | ||
{ | ||
_form = form; | ||
} | ||
|
||
public SiteValidationJob(ViewBackgroundInfo info, PipeRoot pipeRoot, SiteValidationForm form) | ||
{ | ||
super("SiteValidation", info, pipeRoot); | ||
setLogFile(new File(pipeRoot.getLogDirectory(), FileUtil.makeFileNameWithTimestamp("site_validation", "log")).toPath()); | ||
_form = form; | ||
} | ||
|
||
@Override | ||
public URLHelper getStatusHref() | ||
{ | ||
return new ActionURL(ViewValidationResultsAction.class, getContainer()) | ||
.addParameter("fileName", getResultsFileName()); | ||
} | ||
|
||
@Override | ||
public String getDescription() | ||
{ | ||
return "Site Validation"; | ||
} | ||
|
||
@Override | ||
public void run() | ||
{ | ||
info("Site validation started"); | ||
PipelineJob.TaskStatus finalStatus = PipelineJob.TaskStatus.complete; | ||
_form.setLogger(s -> { | ||
getLogger().info(s); | ||
setStatus(s); | ||
}); | ||
JspTemplate<SiteValidationForm> template = new JspTemplate<>("/org/labkey/core/admin/sitevalidation/siteValidation.jsp", _form); | ||
ViewContext context = new ViewContext(getInfo()); | ||
template.setViewContext(context); | ||
File results = new File(getPipeRoot().getLogDirectory(), getResultsFileName()); | ||
|
||
try (PrintWriter out = new PrintWriter(results, StringUtilsLabKey.DEFAULT_CHARSET)) | ||
{ | ||
out.println(template.render()); | ||
} | ||
catch (Exception e) | ||
{ | ||
getLogger().error("Site validation failed", e); | ||
finalStatus = TaskStatus.error; | ||
} | ||
|
||
info("Site validation complete"); | ||
setStatus(finalStatus); | ||
} | ||
|
||
private String getResultsFileName() | ||
{ | ||
return getLogFile().getName().replace(".log", ".html"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.