UNPKG

@broadcom/endevor-bridge-for-git-for-zowe-cli

Version:

Endevor Bridge for Git plug-in for Zowe CLI

96 lines 4.87 kB
"use strict"; /* * Copyright (c) 2019 Broadcom. All Rights Reserved. The term * "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This software and all information contained therein is * confidential and proprietary and shall not be duplicated, * used, disclosed, or disseminated in any way except as * authorized by the applicable license agreement, without the * express written permission of Broadcom. All authorized * reproductions must be marked with this language. * * EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO * THE EXTENT PERMITTED BY APPLICABLE LAW, BROADCOM PROVIDES THIS * SOFTWARE WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT * LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL BROADCOM * BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR * DAMAGE, DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE, * INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS * INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF BROADCOM IS * EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.WorkAreaUnreserve = void 0; const imperative_1 = require("@zowe/imperative"); const object_1 = require("../../../utils/object"); const BuildUtils_1 = require("../../utils/BuildUtils"); const EndevorService_1 = require("../../service/EndevorService"); const EndevorResponseType_1 = require("../../utils/EndevorResponseType"); const EndevorResponseUtils_1 = require("../../utils/EndevorResponseUtils"); /** * Functions used for unreserve a work area. Called by WorkAreaUnreserve.Handler * * @export * @class WorkAreaUnreserve */ class WorkAreaUnreserve { /** * Unreserves the work area * * @param workArea * @param endevorInstance * @param endevorSession * @param task * @throws an error if it was not possible to unreserve the work area */ static unreserveWorkArea(workArea, endevorInstance, endevorSession, task) { return __awaiter(this, void 0, void 0, function* () { imperative_1.Logger.getAppLogger().trace(`WorkAreaUnreserve - Try to unreserve work area '${workArea.id}'`); // Step1. get entry stage const elementSpec = BuildUtils_1.BuildUtils.getLockElementSpec(workArea, endevorInstance); let entryStage; try { entryStage = yield EndevorService_1.EndevorService.getEntryStage(endevorSession, endevorInstance, elementSpec.environment); } catch (err) { throw new imperative_1.ImperativeError({ msg: `Failed to unreserve work area '${workArea.id}'\n`, causeErrors: err }); } elementSpec.stageNumber = String(entryStage); if ((0, object_1.isNotNil)(task)) { task.statusMessage = `Process unreserving`; task.percentComplete = imperative_1.TaskProgress.FIFTY_PERCENT; } // Step2. delete lock element const requestBody = { ccid: "unreserve", comment: "Unreserve for developer build", oveSign: "yes" }; const response = EndevorResponseUtils_1.EndevorResponseUtils.convert(yield EndevorService_1.EndevorService.deleteElement(endevorSession, endevorInstance, elementSpec, requestBody)); if (EndevorResponseUtils_1.EndevorResponseUtils.is(response, EndevorResponseType_1.EndevorResponseType.ELEMENT_NOT_FOUND)) { throw new imperative_1.ImperativeError({ msg: `Failed to unreserve work area '${workArea.id}'. It was not reserved.` }); } else if (!EndevorResponseUtils_1.EndevorResponseUtils.is(response, EndevorResponseType_1.EndevorResponseType.SUCCESSFUL)) { EndevorResponseUtils_1.EndevorResponseUtils.throwError(response, `Failed to unreserve work area '${workArea.id}'`); } }); } } exports.WorkAreaUnreserve = WorkAreaUnreserve; //# sourceMappingURL=WorkAreaUnreserve.js.map