feat: AppResource (#15555)

forbid modification of system app
This commit is contained in:
Imri Paran 2024-03-13 16:41:02 +01:00 committed by GitHub
parent be4863a320
commit 2582ec60f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -268,6 +268,10 @@ public final class CatalogExceptionMessage {
return String.format("System entity [%s] of type %s can not be renamed.", name, entityType); return String.format("System entity [%s] of type %s can not be renamed.", name, entityType);
} }
public static String systemEntityModifyNotAllowed(String name, String entityType) {
return String.format("System entity [%s] of type %s can not be modified.", name, entityType);
}
public static String mutuallyExclusiveLabels(TagLabel tag1, TagLabel tag2) { public static String mutuallyExclusiveLabels(TagLabel tag1, TagLabel tag2) {
return String.format( return String.format(
"Tag labels %s and %s are mutually exclusive and can't be assigned together", "Tag labels %s and %s are mutually exclusive and can't be assigned together",

View File

@ -597,6 +597,10 @@ public class AppResource extends EntityResource<App, AppRepository> {
JsonPatch patch) JsonPatch patch)
throws SchedulerException { throws SchedulerException {
App app = repository.get(null, id, repository.getFields("bot,pipelines")); App app = repository.get(null, id, repository.getFields("bot,pipelines"));
if (app.getSystemApp()) {
throw new IllegalArgumentException(
CatalogExceptionMessage.systemEntityModifyNotAllowed(app.getName(), "SystemApp"));
}
AppScheduler.getInstance().deleteScheduledApplication(app); AppScheduler.getInstance().deleteScheduledApplication(app);
Response response = patchInternal(uriInfo, securityContext, id, patch); Response response = patchInternal(uriInfo, securityContext, id, patch);
App updatedApp = (App) response.getEntity(); App updatedApp = (App) response.getEntity();