-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/IJMP-2024' into 'release/v2.1.0'
IJMP-2024 USS files and folders: Properties change feature See merge request ijmp/for-mainframe!614
- Loading branch information
Showing
6 changed files
with
344 additions
and
64 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
91 changes: 91 additions & 0 deletions
91
src/main/kotlin/eu/ibagroup/formainframe/dataops/operations/UssChangeOwner.kt
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,91 @@ | ||
/* | ||
* Copyright (c) 2020-2024 IBA Group. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBA Group | ||
* Zowe Community | ||
*/ | ||
|
||
package eu.ibagroup.formainframe.dataops.operations | ||
|
||
import com.intellij.openapi.progress.ProgressIndicator | ||
import eu.ibagroup.formainframe.api.api | ||
import eu.ibagroup.formainframe.config.connect.ConnectionConfig | ||
import eu.ibagroup.formainframe.config.connect.authToken | ||
import eu.ibagroup.formainframe.dataops.DataOpsManager | ||
import eu.ibagroup.formainframe.dataops.exceptions.CallException | ||
import eu.ibagroup.formainframe.utils.cancelByIndicator | ||
import eu.ibagroup.formainframe.utils.log | ||
import org.zowe.kotlinsdk.ChangeOwner | ||
import org.zowe.kotlinsdk.DataAPI | ||
import org.zowe.kotlinsdk.FilePath | ||
|
||
/** | ||
* Class which represents factory for uss change owner operation runner. Defined in plugin.xml | ||
*/ | ||
class UssChangeOwnerFactory : OperationRunnerFactory { | ||
override fun buildComponent(dataOpsManager: DataOpsManager): OperationRunner<UssChangeOwnerOperation, Unit> { | ||
return UssChangeOwner() | ||
} | ||
} | ||
|
||
/** | ||
* Data class which represents input parameters for uss change owner operation | ||
* @param parameters instance of [ChangeOwner] object | ||
* @param path path of uss file | ||
*/ | ||
data class UssChangeOwnerParams( | ||
val parameters: ChangeOwner, | ||
val path: String, | ||
) | ||
|
||
/** | ||
* Data class which represents uss change owner operation object | ||
*/ | ||
data class UssChangeOwnerOperation( | ||
override val request: UssChangeOwnerParams, | ||
override val connectionConfig: ConnectionConfig, | ||
) : RemoteUnitOperation<UssChangeOwnerParams> | ||
|
||
/** | ||
* Class which represents uss change owner operation runner | ||
*/ | ||
class UssChangeOwner : OperationRunner<UssChangeOwnerOperation, Unit> { | ||
|
||
override val operationClass = UssChangeOwnerOperation::class.java | ||
override val resultClass = Unit::class.java | ||
override val log = log<UssChangeOwner>() | ||
|
||
/** | ||
* Runs an uss change owner operation | ||
* @param operation uss change owner operation to be run | ||
* @param progressIndicator progress indicator object | ||
* @throws CallException if request is not successful | ||
* @return Void | ||
*/ | ||
override fun run( | ||
operation: UssChangeOwnerOperation, progressIndicator: ProgressIndicator | ||
) { | ||
progressIndicator.checkCanceled() | ||
val response = api<DataAPI>(operation.connectionConfig).changeFileOwner( | ||
authorizationToken = operation.connectionConfig.authToken, | ||
filePath = FilePath(operation.request.path), | ||
body = operation.request.parameters | ||
).cancelByIndicator(progressIndicator).execute() | ||
if (!response.isSuccessful) { | ||
throw CallException( | ||
response, "Cannot change file owner on ${operation.request.path}" | ||
) | ||
} | ||
} | ||
|
||
override fun canRun(operation: UssChangeOwnerOperation): Boolean { | ||
return true | ||
} | ||
} |
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
Oops, something went wrong.