-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial publish failure handling
- Loading branch information
Showing
39 changed files
with
1,673 additions
and
578 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
62 changes: 62 additions & 0 deletions
62
src/main/java/org/craftercms/studio/api/v2/event/task/TaskEvent.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,62 @@ | ||
/* | ||
* Copyright (C) 2007-2024 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.craftercms.studio.api.v2.event.task; | ||
|
||
import org.craftercms.studio.api.v2.event.BroadcastEvent; | ||
import org.craftercms.studio.api.v2.event.StudioEvent; | ||
import org.craftercms.studio.api.v2.task.TaskProgress; | ||
|
||
/** | ||
* Event triggered when a task is state changes | ||
*/ | ||
public class TaskEvent extends StudioEvent implements BroadcastEvent { | ||
public static final String EVENT_TYPE_TASK_COMPLETED = "TASK_COMPLETED"; | ||
public static final String EVENT_TYPE_TASK_STARTED = "TASK_STARTED"; | ||
public static final String EVENT_TYPE_TASK_PROGRESS = "TASK_PROGRESS"; | ||
|
||
private final TaskProgress<?, ?> progress; | ||
private final String eventType; | ||
|
||
public TaskEvent(final TaskProgress<?, ?> progress, final String eventType) { | ||
this.progress = progress; | ||
this.eventType = eventType; | ||
} | ||
|
||
/** | ||
* Get the {@link TaskProgress} associated with this event | ||
* | ||
* @return the task progress | ||
*/ | ||
public TaskProgress<?, ?> getProgress() { | ||
return progress; | ||
} | ||
|
||
@Override | ||
public String getEventType() { | ||
return eventType; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return """ | ||
TaskEvent {taskId=%s, timestamp=%s, eventType=%s, progress=%s} | ||
""".formatted(progress.getTask().getTaskId(), | ||
timestamp, | ||
getEventType(), | ||
progress); | ||
} | ||
} |
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
95 changes: 95 additions & 0 deletions
95
src/main/java/org/craftercms/studio/api/v2/repository/GitPublishCapableRepository.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,95 @@ | ||
/* | ||
* Copyright (C) 2007-2024 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.craftercms.studio.api.v2.repository; | ||
|
||
import org.craftercms.studio.api.v1.exception.ServiceLayerException; | ||
import org.craftercms.studio.api.v2.dal.publish.PublishPackage; | ||
import org.springframework.util.ObjectUtils; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
|
||
/** | ||
* Interface for publish operations of a git repository | ||
*/ | ||
public interface GitPublishCapableRepository extends GitContentRepository { | ||
/** | ||
* Publishes the given items to the given target | ||
* | ||
* @param publishPackage the publish package | ||
* @param publishingTarget the publishing target | ||
* @param publishItems the items to publish | ||
* @param <T> the type of the {@link PublishItemTO} objects | ||
* @return the change set listing the affected paths and new commit id | ||
* @throws ServiceLayerException if there is any error while publishing or publishItems is null or empty | ||
*/ | ||
<T extends PublishItemTO> GitPublishChangeSet<T> publish(PublishPackage publishPackage, | ||
String publishingTarget, | ||
Collection<T> publishItems) throws ServiceLayerException, IOException; | ||
|
||
/** | ||
* Publishes all changes for the given site and target | ||
* | ||
* @param publishPackage the publish package | ||
* @param publishingTarget the publishing target | ||
* @return the change set listing the affected paths and new commit ids (comparing the published repository target branch before and after the publish) | ||
*/ | ||
<T extends PublishItemTO> GitPublishChangeSet<T> publishAll(PublishPackage publishPackage, | ||
String publishingTarget) throws ServiceLayerException, IOException; | ||
|
||
/** | ||
* Execute initial publish for given site | ||
* | ||
* @param publishPackage the package to publish | ||
* @param ignorePaths the paths to ignore | ||
* @param target the target to publish to | ||
* @return commit id of the initial publish. | ||
*/ | ||
String initialPublish(PublishPackage publishPackage, Collection<String> ignorePaths, | ||
String target) throws ServiceLayerException; | ||
|
||
/** | ||
* Store the result of a publish operation | ||
* | ||
* @param successfulItems the paths that were updated | ||
* @param failedItems the paths that failed to publish, mapped to the error message | ||
* @param <T> the actual type of the {@link PublishItemTO} objects | ||
*/ | ||
record GitPublishChangeSet<T extends PublishItemTO>(String commitId, | ||
Collection<T> successfulItems, | ||
Collection<T> failedItems) { | ||
|
||
/** | ||
* Check if there are successfully published changes | ||
* | ||
* @return true if the package had successful changes and a commit was created, false otherwise | ||
*/ | ||
public boolean completed() { | ||
return !ObjectUtils.isEmpty(commitId); | ||
} | ||
|
||
/** | ||
* Check if there are failed items | ||
* | ||
* @return true if failed items list contains items, false otherwise | ||
*/ | ||
public boolean hasFailedItems() { | ||
return !ObjectUtils.isEmpty(failedItems); | ||
} | ||
} | ||
} |
Oops, something went wrong.