Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added check on JobExecutions when modifying JobSteps
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
- Loading branch information
Showing
10 changed files
with
221 additions
and
37 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
49 changes: 49 additions & 0 deletions
49
.../src/main/java/org/eclipse/kapua/service/job/exception/CannotModifyJobStepsException.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,49 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.job.exception; | ||
|
||
import org.eclipse.kapua.model.id.KapuaId; | ||
import org.eclipse.kapua.service.job.Job; | ||
import org.eclipse.kapua.service.job.step.JobStep; | ||
|
||
/** | ||
* {@link JobServiceException} to throw when trying to modify {@link JobStep}s of a {@link Job} that already started once. | ||
* | ||
* @since 1.5.0 | ||
*/ | ||
public class CannotModifyJobStepsException extends JobServiceException { | ||
|
||
private final KapuaId jobId; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param jobId The {@link Job#getId()}. | ||
* @since 1.5.0 | ||
*/ | ||
public CannotModifyJobStepsException(KapuaId jobId) { | ||
super(JobServiceErrorCodes.CANNOT_MODIFY_JOB_STEPS, jobId); | ||
|
||
this.jobId = jobId; | ||
} | ||
|
||
/** | ||
* Gets the {@link Job#getId()}. | ||
* | ||
* @return The {@link Job#getId()}. | ||
* @since 1.5.0 | ||
*/ | ||
public KapuaId getJobId() { | ||
return jobId; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...e/job/api/src/main/java/org/eclipse/kapua/service/job/exception/JobServiceErrorCodes.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,30 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.job.exception; | ||
|
||
import org.eclipse.kapua.KapuaErrorCode; | ||
|
||
/** | ||
* {@link KapuaErrorCode}s for {@link JobServiceException} | ||
* | ||
* @since 1.5.0 | ||
*/ | ||
public enum JobServiceErrorCodes implements KapuaErrorCode { | ||
|
||
/** | ||
* See {@link CannotModifyJobStepsException}. | ||
* | ||
* @since 1.5.0 | ||
*/ | ||
CANNOT_MODIFY_JOB_STEPS, | ||
} |
63 changes: 63 additions & 0 deletions
63
...ce/job/api/src/main/java/org/eclipse/kapua/service/job/exception/JobServiceException.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,63 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.job.exception; | ||
|
||
import org.eclipse.kapua.KapuaException; | ||
|
||
/** | ||
* {@link KapuaException} base for Scheduler Service {@link Exception}s | ||
* | ||
* @since 1.5.0 | ||
*/ | ||
public abstract class JobServiceException extends KapuaException { | ||
|
||
private static final String KAPUA_ERROR_MESSAGES = "job-service-error-messages"; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param code The {@link JobServiceErrorCodes}. | ||
* @since 1.5.0 | ||
*/ | ||
public JobServiceException(JobServiceErrorCodes code) { | ||
super(code); | ||
} | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param code The {@link JobServiceErrorCodes}. | ||
* @param arguments Additional argument associated with the {@link JobServiceException}. | ||
* @since 1.5.0 | ||
*/ | ||
public JobServiceException(JobServiceErrorCodes code, Object... arguments) { | ||
super(code, arguments); | ||
} | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param code The {@link JobServiceErrorCodes}. | ||
* @param cause The root {@link Throwable} of this {@link JobServiceException}. | ||
* @param arguments Additional argument associated with the {@link JobServiceException}. | ||
* @since 1.5.0 | ||
*/ | ||
public JobServiceException(JobServiceErrorCodes code, Throwable cause, Object... arguments) { | ||
super(code, cause, arguments); | ||
} | ||
|
||
@Override | ||
protected String getKapuaErrorMessagesBundle() { | ||
return KAPUA_ERROR_MESSAGES; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
service/job/api/src/main/resources/job-service-error-messages.properties
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,14 @@ | ||
############################################################################### | ||
# Copyright (c) 2021 Eurotech and/or its affiliates and others | ||
# | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Eurotech - initial API and implementation | ||
# | ||
############################################################################### | ||
CANNOT_MODIFY_JOB_STEPS=Cannot modify JobSteps of Job {0} because it has already started once. |
Oops, something went wrong.