forked from xwikisas/application-admintools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide the ability to upload patches xwikisas#78
* created upload job request and status * renamed HealthCheckResult to CustomJobResult and HealthCheckResultLevel to CustomJobResultLevel * created a new rest endpoint for package upload with the role of instantiating a job with the given reference and time stamp * added a new endpoint to ServerInfo interface for retrieving the XWiki installation path * implemented the logic of package archive upload which includes: original file search and backup creation, batch file save (file replacement), batch backup restore in case of an error * created the ImportPackage page for user interface * created the hidden PackagesStore for archive storage * created liveData table for saving a package and starting the upload process * created liveData table (with PackagesJSON document) for showing the already uploaded packages * created a template for executing and showing the progress of a package upload * code refactoring * added transalations
- Loading branch information
1 parent
0ad01fd
commit ed7f637
Showing
44 changed files
with
1,979 additions
and
229 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
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
72 changes: 72 additions & 0 deletions
72
...ation-admintools-api/src/main/java/com/xwiki/admintools/jobs/PackageUploadJobRequest.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,72 @@ | ||
/* | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package com.xwiki.admintools.jobs; | ||
|
||
import java.util.List; | ||
|
||
import org.xwiki.job.AbstractRequest; | ||
import org.xwiki.stability.Unstable; | ||
|
||
/** | ||
* Represents a request to start a package upload job. | ||
* | ||
* @version $Id$ | ||
* @since 1.1 | ||
*/ | ||
@Unstable | ||
public class PackageUploadJobRequest extends AbstractRequest | ||
{ | ||
private String fileRef; | ||
|
||
/** | ||
* Default constructor. | ||
*/ | ||
public PackageUploadJobRequest() | ||
{ | ||
setDefaultId(); | ||
} | ||
|
||
/** | ||
* Creates a specific request for package upload job. | ||
* | ||
* @param fileRef the attachment reference. | ||
* @param jobId the ID of the request. | ||
*/ | ||
public PackageUploadJobRequest(String fileRef, List<String> jobId) | ||
{ | ||
this.fileRef = fileRef; | ||
setId(jobId); | ||
} | ||
|
||
/** | ||
* Get the attachment reference. | ||
* | ||
* @return a {@link String} representing the attachment reference. | ||
*/ | ||
public String getFileRef() | ||
{ | ||
return this.fileRef; | ||
} | ||
|
||
private void setDefaultId() | ||
{ | ||
setId(List.of("adminTools", "import")); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...cation-admintools-api/src/main/java/com/xwiki/admintools/jobs/PackageUploadJobStatus.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,87 @@ | ||
/* | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package com.xwiki.admintools.jobs; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.xwiki.job.DefaultJobStatus; | ||
import org.xwiki.logging.LoggerManager; | ||
import org.xwiki.observation.ObservationManager; | ||
import org.xwiki.stability.Unstable; | ||
|
||
/** | ||
* The status of a package upload job. | ||
* | ||
* @version $Id$ | ||
* @since 1.1 | ||
*/ | ||
@Unstable | ||
public class PackageUploadJobStatus extends DefaultJobStatus<PackageUploadJobRequest> | ||
{ | ||
private List<CustomJobResult> uploadLogs = new LinkedList<>(); | ||
|
||
/** | ||
* Create a new import job status. | ||
* | ||
* @param jobType the job type. | ||
* @param request the request provided when the job was started. | ||
* @param observationManager the observation manager. | ||
* @param loggerManager the logger manager. | ||
*/ | ||
public PackageUploadJobStatus(String jobType, PackageUploadJobRequest request, | ||
ObservationManager observationManager, LoggerManager loggerManager) | ||
{ | ||
super(jobType, request, null, observationManager, loggerManager); | ||
setCancelable(true); | ||
} | ||
|
||
/** | ||
* Get the list result list from the job. | ||
* | ||
* @return list with {@link CustomJobResult} containing the results. | ||
*/ | ||
public List<CustomJobResult> getJobResults() | ||
{ | ||
return uploadLogs; | ||
} | ||
|
||
/** | ||
* Add a new log to the job results. | ||
* | ||
* @param statusLog the new log result. | ||
*/ | ||
public void addLog(CustomJobResult statusLog) | ||
{ | ||
uploadLogs.add(statusLog); | ||
} | ||
|
||
/** | ||
* Check if any job result has a specific level of severity. | ||
* | ||
* @param level represents the searched level of severity. | ||
* @return {@code true} if there is any match for the given level, or {@code false} otherwise. | ||
*/ | ||
public boolean hasLevel(CustomJobResultLevel level) | ||
{ | ||
return this.uploadLogs.stream().anyMatch(checkResult -> Objects.equals(level, checkResult.getLevel())); | ||
} | ||
} |
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.