0001: /*
0002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003: *
0004: * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * The contents of this file are subject to the terms of either the GNU
0007: * General Public License Version 2 only ("GPL") or the Common Development
0008: * and Distribution License("CDDL") (collectively, the "License"). You
0009: * may not use this file except in compliance with the License. You can obtain
0010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
0011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
0012: * language governing permissions and limitations under the License.
0013: *
0014: * When distributing the software, include this License Header Notice in each
0015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
0016: * Sun designates this particular file as subject to the "Classpath" exception
0017: * as provided by Sun in the GPL Version 2 section of the License file that
0018: * accompanied this code. If applicable, add the following below the License
0019: * Header, with the fields enclosed by brackets [] replaced by your own
0020: * identifying information: "Portions Copyrighted [year]
0021: * [name of copyright owner]"
0022: *
0023: * Contributor(s):
0024: *
0025: * If you wish your version of this file to be governed by only the CDDL or
0026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
0027: * elects to include this software in this distribution under the [CDDL or GPL
0028: * Version 2] license." If you don't indicate a single choice of license, a
0029: * recipient has the option to distribute your version of this file under
0030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
0031: * its licensees as provided above. However, if you add GPL Version 2 code
0032: * and therefore, elected the GPL Version 2 license, then the option applies
0033: * only if the new code is made subject to such option by the copyright
0034: * holder.
0035: */
0036: package com.sun.jbi.jsf.handlers;
0037:
0038: import com.sun.data.provider.FieldKey;
0039: import com.sun.data.provider.RowKey;
0040: import com.sun.data.provider.impl.ObjectListDataProvider;
0041: import com.sun.enterprise.tools.admingui.util.FileUtil;
0042: import com.sun.enterprise.tools.admingui.util.GuiUtil;
0043: import com.sun.jbi.jsf.bean.AlertBean;
0044: import com.sun.jbi.jsf.bean.DeletionBean;
0045: import com.sun.jbi.jsf.bean.InstallationBean;
0046: import com.sun.jbi.jsf.bean.InstallationTarget;
0047: import com.sun.jbi.jsf.bean.OperationBean;
0048: import com.sun.jbi.jsf.bean.ShowBean;
0049: import com.sun.jbi.jsf.util.AlertUtilities;
0050: import com.sun.jbi.jsf.util.BeanUtilities;
0051: import com.sun.jbi.jsf.util.ClusterUtilities;
0052: import com.sun.jbi.jsf.util.CompConfigUtils;
0053: import com.sun.jbi.jsf.util.I18nUtilities;
0054: import com.sun.jbi.jsf.util.JBIConstants;
0055: import com.sun.jbi.jsf.util.JBILogger;
0056: import com.sun.jbi.jsf.util.SharedConstants;
0057: import com.sun.jbi.jsf.util.TableUtilities;
0058: import com.sun.jbi.ui.common.JBIAdminCommands;
0059: import com.sun.jsftemplating.annotation.Handler;
0060: import com.sun.jsftemplating.annotation.HandlerInput;
0061: import com.sun.jsftemplating.annotation.HandlerOutput;
0062: import com.sun.jsftemplating.layout.descriptors.handler.HandlerContext;
0063: import com.sun.webui.jsf.component.TableRowGroup;
0064: import com.sun.webui.jsf.model.Option;
0065: import java.util.ArrayList;
0066: import java.util.Iterator;
0067: import java.util.List;
0068: import java.util.Properties;
0069: import java.util.logging.Logger;
0070:
0071: /**
0072: * Provides jsftemplating handlers for installation, deployment, and table
0073: * actions on selected rows, such as undeployment and uninstallation
0074: *
0075: * @author Sun Microsystems Inc.
0076: */
0077: public final class InstallationHandlers {
0078:
0079: /**
0080: * <p>
0081: *
0082: * Delegates JBI deletion requests for each selected row; accumulates
0083: * failures into alert <p>
0084: *
0085: * Input value: "tableRowGroup" -- Type: <code> com.sun.webui.jsf.component.TableRowGroup</code>
0086: * </p> <p>
0087: *
0088: * Input value: "tableType" -- Type: <code> java.lang.String</code> <p>
0089: *
0090: * Output value: "isAlertNeeded" -- Type: <code>java.lang.Boolean</code>
0091: * </p> <p>
0092: *
0093: * Output value: "alertSummary" -- Type: <code>String</code>/</p> <p>
0094: *
0095: * Output value: "alertDetails" -- Type: <code>String</code>/</p> Valid
0096: * types: 'deployments,' 'bindingsEngines,' or 'libraries.'
0097: *
0098: * @param handlerCtx <code>HandlerContext</code> provides inputs and
0099: * outputs.
0100: */
0101: @Handler(id="jbiDeleteSelectedRows",input={@HandlerInput(name="tableRowGroup",type=TableRowGroup.class,required=true),@HandlerInput(name="tableType",type=String.class,required=true)},output={@HandlerOutput(name="isAlertNeeded",type=Boolean.class),@HandlerOutput(name="alertSummary",type=String.class),@HandlerOutput(name="alertDetails",type=String.class)})
0102: public static void jbiDeleteSelectedRows(HandlerContext handlerCtx) {
0103:
0104: TableRowGroup trg = (TableRowGroup) handlerCtx
0105: .getInputValue("tableRowGroup");
0106: String tableType = (String) handlerCtx
0107: .getInputValue("tableType");
0108:
0109: sLog.fine("InstallationHandlers.jbiDeleteSelectedRows(" + trg
0110: + ", " + tableType + ")");
0111:
0112: List deletionRows = TableUtilities
0113: .getSelectedRowProperties(trg);
0114: Iterator rowIt = deletionRows.iterator();
0115:
0116: int countFailedDeletions = 0;
0117: int countSuccessfulDeletions = 0;
0118: int countWarningDeletions = 0;
0119:
0120: boolean isAlertNeeded = false;
0121:
0122: String alertDetails = "";
0123: String alertType = "";
0124:
0125: while (rowIt.hasNext()) {
0126: Properties rowProperties = (Properties) rowIt.next();
0127: String rowName = (String) rowProperties
0128: .getProperty(SharedConstants.KEY_NAME);
0129: String rowType = (String) rowProperties
0130: .getProperty(SharedConstants.KEY_TYPE);
0131:
0132: List targets = new ArrayList();
0133: List listOfTargets = new ArrayList();
0134:
0135: if (IS_CLUSTER_PROFILE) {
0136: listOfTargets = ClusterUtilities
0137: .findTargetsForNameByType(rowName, rowType);
0138: if (listOfTargets.size() == 0) {
0139: targets.add(JBIAdminCommands.DOMAIN_TARGET_KEY);
0140: } else {
0141: for (Iterator it = listOfTargets.iterator(); it
0142: .hasNext();) {
0143: Properties targetProperties = (Properties) it
0144: .next();
0145: String tgt = (String) targetProperties
0146: .getProperty(SharedConstants.KEY_NAME);
0147: targets.add(tgt);
0148: }
0149: }
0150: } else {
0151: // developer-profile
0152:
0153: targets.add(JBIAdminCommands.SERVER_TARGET_KEY);
0154: }
0155:
0156: sLog
0157: .fine("InstallationHandlers.jbiDeleteSelectedRows(), targets="
0158: + targets + ")");
0159:
0160: // When deleting a row from the table, (via a button) we do not want to
0161: // retain the the retain the component/assembly/library in the domain.
0162: boolean retainFlag = false;
0163:
0164: delete(rowProperties, retainFlag, targets);
0165:
0166: String successResult = (String) rowProperties
0167: .getProperty(SharedConstants.SUCCESS_RESULT);
0168:
0169: if (null != successResult) {
0170: ++countSuccessfulDeletions;
0171: sLog
0172: .fine("InstallationHandlers.jbiDeleteSelectedRows(...), "
0173: + " success for "
0174: + rowProperties
0175: + ", countFailedDeletions="
0176: + countFailedDeletions
0177: + ", countSuccessfulDeletions="
0178: + countSuccessfulDeletions);
0179: } else {
0180: String failureResult = (String) rowProperties
0181: .getProperty(SharedConstants.FAILURE_RESULT);
0182:
0183: if (failureResult.trim().startsWith("WARNING")) {
0184: ++countWarningDeletions;
0185: } else {
0186: ++countFailedDeletions;
0187: }
0188:
0189: sLog
0190: .fine("InstallationHandlers.jbiDeleteSelectedRows(...), "
0191: + " failure for "
0192: + rowProperties
0193: + ", countFailedDeletions="
0194: + countFailedDeletions
0195: + ", countSuccessfulDeletions="
0196: + countSuccessfulDeletions);
0197:
0198: String details = "";
0199: String exceptionMessage = AlertUtilities
0200: .getMessage(failureResult);
0201: if ("".equals(exceptionMessage)) {
0202: details = failureResult;
0203: } else {
0204: details = exceptionMessage;
0205: }
0206:
0207: Object[] args = { rowName, details };
0208: alertDetails += GuiUtil
0209: .getMessage(
0210: I18nUtilities
0211: .getResourceString("jbi.deletion.failed.for.row"),
0212: args)
0213: + "<br />";
0214: }
0215: }
0216:
0217: String alertSummary = "";
0218: if (0 < countFailedDeletions) {
0219: if ((0 < countSuccessfulDeletions)
0220: || (0 < countWarningDeletions)) {
0221: if (1 == countFailedDeletions) {
0222: alertSummary = I18nUtilities
0223: .getResourceString("jbi.delete.one.failed.alert.summary.text");
0224: } else {
0225: alertSummary = I18nUtilities
0226: .getResourceString("jbi.delete.some.failed.alert.summary.text");
0227: }
0228: } else {
0229: alertSummary = I18nUtilities
0230: .getResourceString("jbi.delete.all.failed.alert.summary.text");
0231: }
0232: alertDetails = BeanUtilities
0233: .addAlertFooterMessage(alertDetails);
0234: } else if (0 < countWarningDeletions) {
0235: alertSummary = I18nUtilities
0236: .getResourceString("jbi.deletion.warning.summary");
0237: alertType = "warning";
0238: AlertBean alertBean = BeanUtilities.getAlertBean();
0239: alertBean.setAlertType(alertType);
0240: }
0241:
0242: if ((countFailedDeletions > 0) || (countWarningDeletions > 0)) {
0243: isAlertNeeded = true;
0244: }
0245: handlerCtx.setOutputValue("isAlertNeeded", Boolean
0246: .toString(isAlertNeeded));
0247: handlerCtx.setOutputValue("alertSummary", alertSummary);
0248: handlerCtx.setOutputValue("alertDetails", alertDetails);
0249:
0250: sLog.fine("InstallationHandlers.jbiDeleteSelectedRows(...), "
0251: + " isAlertNeeded=" + isAlertNeeded + ", alertSummary="
0252: + alertSummary + ", alertDetails=" + alertDetails);
0253: }
0254:
0255: /**
0256: * <p>
0257: *
0258: * Delegates installation request for table type <p>
0259: *
0260: * Input value: "archivePath" -- Type: <code> java.lang.String</code> path
0261: * to validated archive <p>
0262: *
0263: * Input value: "jbiName" -- Type: <code> java.lang.String</code> JBI name
0264: * from validated archive <p>
0265: *
0266: * Input value: "jbiType" -- Type: <code> java.lang.String</code> JBI type
0267: * from validated archive <p>
0268: *
0269: * Input value: "isToBeVerifiedOnDeploy" -- Type: <code> java.lang.Boolean</code>
0270: * verify if true <p>
0271: *
0272: * Input value: "isEnabledAfterInstallOrDeploy" -- Type: <code> java.lang.Boolean</code>
0273: * start if true <p>
0274: *
0275: * Input value: "redirectOnFailure" -- Type: <code> java.lang.String</code>
0276: * what to show if it fails <p>
0277: *
0278: * Input value: "redirectOnSuccess" -- Type: <code> java.lang.String</code>
0279: * what to show if it works <p>
0280: *
0281: * Input value: "installList" -- Type: <code> java.util.List</code> Where
0282: * to install (if cluster-profile) <p>
0283: *
0284: * Output value: "isAlertNeeded" -- Type: <code>java.lang.Boolean</code>
0285: * show alert or not</p> <p>
0286: *
0287: * Output value: "alertSummary" -- Type: <code>String</code>summary, if
0288: * failure</p> <p>
0289: *
0290: * Output value: "alertDetails" -- Type: <code>String</code>details, if
0291: * failure</p> <p>
0292: *
0293: * Output value: "redirectTo" -- Type: <code>String</code> Where to go
0294: * next, based on success/failure</p>
0295: *
0296: * @param handlerCtx <code>HandlerContext</code> provides inputs and
0297: * outputs.
0298: */
0299: @Handler(id="jbiInstallValidatedArchive",input={@HandlerInput(name="archivePath",type=String.class,required=true),@HandlerInput(name="jbiName",type=String.class,required=true),@HandlerInput(name="jbiType",type=String.class,required=true),@HandlerInput(name="isToBeVerifiedOnDeploy",type=Boolean.class,required=false),@HandlerInput(name="isEnabledAfterInstallOrDeploy",type=Boolean.class,required=true),@HandlerInput(name="redirectOnFailure",type=String.class,required=true),@HandlerInput(name="redirectOnSuccess",type=String.class,required=true),@HandlerInput(name="installList",type=java.util.List.class,required=false)},output={@HandlerOutput(name="isAlertNeeded",type=Boolean.class),@HandlerOutput(name="alertSummary",type=String.class),@HandlerOutput(name="alertDetails",type=String.class),@HandlerOutput(name="redirectTo",type=String.class)})
0300: public static void jbiInstallValidatedArchive(
0301: HandlerContext handlerCtx) {
0302: String archivePath = (String) handlerCtx
0303: .getInputValue("archivePath");
0304: String jbiName = (String) handlerCtx.getInputValue("jbiName");
0305: String jbiType = (String) handlerCtx.getInputValue("jbiType");
0306: String redirectOnFailure = (String) handlerCtx
0307: .getInputValue("redirectOnFailure");
0308: String redirectOnSuccess = (String) handlerCtx
0309: .getInputValue("redirectOnSuccess");
0310: String redirectTo = redirectOnSuccess;
0311:
0312: Boolean isToBeVerifiedOnDeploy = (Boolean) handlerCtx
0313: .getInputValue("isToBeVerifiedOnDeploy");
0314: if (null == isToBeVerifiedOnDeploy) {
0315: isToBeVerifiedOnDeploy = new Boolean(false);
0316: }
0317: Boolean isEnabledAfterInstallOrDeploy = (Boolean) handlerCtx
0318: .getInputValue("isEnabledAfterInstallOrDeploy");
0319:
0320: sLog
0321: .fine("InstallationHandlers.jbiInstallValidatedArchive(), archivePath="
0322: + archivePath
0323: + ", jbiName="
0324: + jbiName
0325: + ", jbiType="
0326: + jbiType
0327: + ", isToBeVerifiedOnDeploy="
0328: + isToBeVerifiedOnDeploy
0329: + ", isEnabledAfterInstallOrDeploy="
0330: + isEnabledAfterInstallOrDeploy
0331: + ", redirectOnFailure="
0332: + redirectOnFailure
0333: + ", redirectOnSuccess=" + redirectOnSuccess);
0334:
0335: String alertDetails = "";
0336: String alertSummary = "";
0337: String internalError = "";
0338: String successResult = "";
0339: String failureResult = "";
0340:
0341: boolean failureFlag = false;
0342: boolean internalErrorFlag = false;
0343: boolean isAlertNeeded = false;
0344: boolean noTargetFlag = false;
0345:
0346: List successTargets = new ArrayList();
0347: List targets = new ArrayList();
0348:
0349: int countSuccessfulStart = 0;
0350: int countFailedStart = 0;
0351: int countSuccessfulInstalls = 0;
0352: int countFailedInstalls = 0;
0353:
0354: Properties installProperties = new Properties();
0355: installProperties.setProperty(KEY_PATH, archivePath);
0356: installProperties
0357: .setProperty(SharedConstants.KEY_NAME, jbiName);
0358: installProperties
0359: .setProperty(SharedConstants.KEY_TYPE, jbiType);
0360:
0361: if (IS_CLUSTER_PROFILE) {
0362: // InstallationBean installationBean = BeanUtilities.getInstallationBean();
0363: // String[] selectedNames = installationBean.getTargetNames();
0364: // targets = Arrays.asList(selectedNames);
0365: targets = (List) handlerCtx.getInputValue("installList");
0366:
0367: if (targets.size() == 0) {
0368: targets = new ArrayList();
0369: targets.add(JBIAdminCommands.DOMAIN_TARGET_KEY);
0370: noTargetFlag = true;
0371: }
0372: } else {
0373: targets.add(JBIAdminCommands.SERVER_TARGET_KEY);
0374: }
0375:
0376: boolean verificationFailed = false;
0377: if ((JBIConstants.JBI_SERVICE_ASSEMBLY_TYPE.equals(jbiType))
0378: && isToBeVerifiedOnDeploy) {
0379: InstallationBean installationBean = BeanUtilities
0380: .getInstallationBean();
0381:
0382: int verifyCount = 0;
0383: for (Iterator it = targets.iterator(); it.hasNext();) {
0384: String target = (String) it.next();
0385:
0386: sLog
0387: .fine("InstallationHandler.jbiInstallValidatedArchive()"
0388: + ", run verifier on archivePath="
0389: + archivePath
0390: + " against target="
0391: + target);
0392: Properties verifierProperties = installationBean
0393: .runAppConfigVerifier(archivePath, target);
0394: ++verifyCount;
0395: failureResult = (String) verifierProperties
0396: .get("failure-result");
0397: if (null != failureResult) {
0398: verificationFailed = true;
0399: alertDetails += failureResult;
0400: sLog
0401: .fine("InstallationHandler.jbiInstallValidatedArchive()"
0402: + ", verificationFailed="
0403: + verificationFailed
0404: + ", failureResult="
0405: + failureResult);
0406: break;
0407: }
0408: sLog
0409: .fine("InstallationHandler.jbiInstallValidatedArchive()"
0410: + ", run verifier on archivePath="
0411: + archivePath
0412: + " against target="
0413: + target
0414: + ", verifierProperties="
0415: + verifierProperties
0416: + ", verifyCount="
0417: + verifyCount);
0418: }
0419: sLog
0420: .fine("InstallationHandler.jbiInstallValidatedArchive()"
0421: + ", ran verifier against "
0422: + verifyCount
0423: + " targets.");
0424: } else {
0425: sLog
0426: .fine("InstallationHandler.jbiInstallValidatedArchive()"
0427: + ", skipping verifier for non SA archive");
0428: }
0429:
0430: if (!verificationFailed) {
0431: for (Iterator it = targets.iterator(); it.hasNext();) {
0432: String target = (String) it.next();
0433: installProperties = install(installProperties, target);
0434:
0435: successResult = (String) installProperties
0436: .getProperty(SharedConstants.SUCCESS_RESULT);
0437: internalError = (String) installProperties
0438: .getProperty(SharedConstants.INTERNAL_ERROR);
0439:
0440: if (null != internalError) {
0441: internalErrorFlag = true;
0442: break;
0443: }
0444:
0445: if (null != successResult) {
0446: ++countSuccessfulInstalls;
0447: Properties succcessProperties = new Properties();
0448: succcessProperties.setProperty(
0449: SharedConstants.KEY_NAME, target);
0450: successTargets.add(succcessProperties);
0451: } else {
0452: failureFlag = true;
0453: ++countFailedInstalls;
0454: failureResult = (String) installProperties
0455: .getProperty(SharedConstants.FAILURE_RESULT);
0456: alertDetails += failureResult + "<br>";
0457: }
0458: }
0459: } else {
0460: failureFlag = true;
0461: }
0462:
0463: // Setup the alert message if a failure was encountered during install
0464: if (failureFlag || internalErrorFlag) {
0465: isAlertNeeded = true;
0466: if (internalErrorFlag) {
0467: alertSummary = I18nUtilities
0468: .getResourceString("jbi.internal.error.summary");
0469: alertDetails = internalError;
0470: } else {
0471: if (JBIConstants.JBI_SERVICE_ASSEMBLY_TYPE
0472: .equals(jbiType)) {
0473: if (verificationFailed) {
0474: alertSummary = I18nUtilities
0475: .getResourceString("jbi.app.verification.verify.failed");
0476: alertDetails += I18nUtilities
0477: .getResourceString("jbi.app.verification.deployment.not.attempted")
0478: + "<br />";
0479: } else {
0480: alertSummary = I18nUtilities
0481: .getResourceString("jbi.deployment.failed.alert.summary.text");
0482: }
0483: } else {
0484: alertSummary = I18nUtilities
0485: .getResourceString("jbi.installation.failed.alert.summary.text");
0486: }
0487: }
0488: }
0489:
0490: else {
0491: // Check to see if the enable check box was selected
0492: if ((null != isEnabledAfterInstallOrDeploy)
0493: && (isEnabledAfterInstallOrDeploy)) {
0494: // If the component/assembly was successfully installed on at least
0495: // one target, then go ahead and try to start it. Note, it will
0496: // only try to start it on the targets that install was successful
0497: if (countSuccessfulInstalls > 0) {
0498: Properties startProperties = new Properties();
0499:
0500: // This will be true if the component was installed only to the DAS
0501: if (noTargetFlag) {
0502: sLog.fine("*** noTargetFlag set");
0503: isAlertNeeded = true;
0504: String typeText = "";
0505: if (jbiType
0506: .equalsIgnoreCase(SharedConstants.COMPONENT_TABLE_TYPE)) {
0507: typeText = I18nUtilities
0508: .getResourceString("jbi.failed.no.target.component");
0509: } else {
0510: typeText = I18nUtilities
0511: .getResourceString("jbi.failed.no.target.deployment");
0512: }
0513: ++countFailedStart;
0514:
0515: Object[] args = { typeText, jbiName };
0516: failureResult = GuiUtil
0517: .getMessage(
0518: I18nUtilities
0519: .getResourceString("jbi.failed.no.target"),
0520: args);
0521:
0522: alertDetails += failureResult + "<br>";
0523: alertSummary = I18nUtilities
0524: .getResourceString("jbi.failed.start.after.install");
0525: }
0526:
0527: else {
0528: startProperties.setProperty(
0529: SharedConstants.KEY_NAME, jbiName);
0530: startProperties.setProperty(
0531: SharedConstants.KEY_TYPE, jbiType);
0532: OperationBean operationBean = BeanUtilities
0533: .getOperationBean();
0534: startProperties = operationBean.start(
0535: startProperties, successTargets);
0536:
0537: successResult = (String) startProperties
0538: .getProperty(SharedConstants.SUCCESS_RESULT);
0539: if (null != successResult) {
0540: ++countSuccessfulStart;
0541: } else {
0542: isAlertNeeded = true;
0543: ++countFailedStart;
0544: failureResult = startProperties
0545: .getProperty(SharedConstants.FAILURE_RESULT);
0546: alertDetails += failureResult + "<br>";
0547: alertSummary = I18nUtilities
0548: .getResourceString("jbi.failed.start.after.install");
0549: }
0550: }
0551: sLog
0552: .fine("InstallationHandlers.jbiInstallValidatedArchive(...), startProperties="
0553: + startProperties);
0554: }
0555: }
0556: //Sucessful installation done, now delete the temporarily uploaded file
0557: deleteTempFile(archivePath);
0558: }
0559:
0560: if (countSuccessfulInstalls > 0) {
0561: //Success
0562:
0563: redirectTo = redirectOnSuccess;
0564: //Partial Success should navigate back to List View/Originating Page and the alert
0565: //Should be displayed in List View/Originating page
0566: if (isAlertNeeded) {
0567: //Success with warnings
0568:
0569: alertDetails = BeanUtilities
0570: .addAlertFooterMessage(alertDetails);
0571: }
0572: } else if (isAlertNeeded) {
0573: //Total Failure
0574:
0575: alertDetails = BeanUtilities
0576: .addAlertFooterMessage(alertDetails);
0577: redirectTo = redirectOnFailure;
0578: }
0579:
0580: handlerCtx.setOutputValue("isAlertNeeded", Boolean
0581: .toString(isAlertNeeded));
0582: handlerCtx.setOutputValue("alertSummary", alertSummary);
0583: handlerCtx.setOutputValue("alertDetails", alertDetails);
0584: handlerCtx.setOutputValue("redirectTo", redirectTo);
0585:
0586: sLog
0587: .fine("InstallationHandlers.jbiInstallValidatedArchive(...), "
0588: + " isAlertNeeded="
0589: + isAlertNeeded
0590: + ", alertSummary="
0591: + alertSummary
0592: + ", alertDetails="
0593: + alertDetails
0594: + ", redirectTo=" + redirectTo);
0595: }
0596:
0597: /**
0598: * <p>
0599: *
0600: * Delegates update request for table type <p>
0601: *
0602: * Input value: "compName" -- Type: <code> java.lang.String</code> JBI
0603: * name from validated archive <p>
0604: *
0605: * Input value: "compType" -- Type: <code> java.lang.String</code> JBI
0606: * type from validated archive
0607: *
0608: * @param handlerCtx <code>HandlerContext</code> provides inputs and
0609: * outputs.
0610: */
0611: @Handler(id="jbiSetInstallConfigPS",input={@HandlerInput(name="compName",type=String.class,required=true),@HandlerInput(name="compType",type=String.class,required=true)})
0612: public static void jbiSetInstallConfigPS(HandlerContext handlerCtx) {
0613: String compName = (String) handlerCtx.getInputValue("compName");
0614: String compType = (String) handlerCtx.getInputValue("compType");
0615:
0616: sLog.fine("InstallationHandlers.jbiSetInstallConfigPS()"
0617: + ", compName=" + compName + ", compType=" + compType);
0618:
0619: boolean result = CompConfigUtils.setConfigPS(
0620: CompConfigUtils.CONFIG_TYPE_INSTALLATION, compName,
0621: compType, null);
0622: sLog
0623: .fine("InstallationHandlers.jbiSetInstallConfigPS(), result="
0624: + result);
0625: }
0626:
0627: /**
0628: * <p>
0629: *
0630: * Delegates update request for table type <p>
0631: *
0632: * Input value: "archivePath" -- Type: <code> java.lang.String</code> path
0633: * to validated archive <p>
0634: *
0635: * Input value: "jbiName" -- Type: <code> java.lang.String</code> JBI name
0636: * from validated archive <p>
0637: *
0638: * Input value: "jbiType" -- Type: <code> java.lang.String</code> JBI type
0639: * from validated archive <p>
0640: *
0641: * Input value: "isEnabledAfterInstallOrDeploy" -- Type: <code> java.lang.Boolean</code>
0642: * start if true <p>
0643: *
0644: * Input value: "redirectOnFailure" -- Type: <code> java.lang.String</code>
0645: * what to show if it fails <p>
0646: *
0647: * Input value: "redirectOnSuccess" -- Type: <code> java.lang.String</code>
0648: * what to show if it works <p>
0649: *
0650: * Input value: "installList" -- Type: <code> java.util.List</code> Where
0651: * to install (if cluster-profile) <p>
0652: *
0653: * Output value: "isAlertNeeded" -- Type: <code>java.lang.Boolean</code>
0654: * show alert or not</p> <p>
0655: *
0656: * Output value: "alertSummary" -- Type: <code>String</code>summary, if
0657: * failure</p> <p>
0658: *
0659: * Output value: "alertDetails" -- Type: <code>String</code>details, if
0660: * failure</p> <p>
0661: *
0662: * Output value: "redirectTo" -- Type: <code>String</code> Where to go
0663: * next, based on success/failure</p>
0664: *
0665: * @param handlerCtx <code>HandlerContext</code> provides inputs and
0666: * outputs.
0667: */
0668: @Handler(id="jbiUpdateValidatedArchive",input={@HandlerInput(name="archivePath",type=String.class,required=true),@HandlerInput(name="jbiName",type=String.class,required=true),@HandlerInput(name="jbiType",type=String.class,required=true),@HandlerInput(name="isEnabledAfterInstallOrDeploy",type=Boolean.class,required=true),@HandlerInput(name="redirectOnFailure",type=String.class,required=true),@HandlerInput(name="redirectOnSuccess",type=String.class,required=true),@HandlerInput(name="installList",type=java.util.List.class,required=false)},output={@HandlerOutput(name="isAlertNeeded",type=Boolean.class),@HandlerOutput(name="alertSummary",type=String.class),@HandlerOutput(name="alertDetails",type=String.class),@HandlerOutput(name="redirectTo",type=String.class)})
0669: public static void jbiUpdateValidatedArchive(
0670: HandlerContext handlerCtx) {
0671: String archivePath = (String) handlerCtx
0672: .getInputValue("archivePath");
0673: String jbiName = (String) handlerCtx.getInputValue("jbiName");
0674: String jbiType = (String) handlerCtx.getInputValue("jbiType");
0675: String redirectOnFailure = (String) handlerCtx
0676: .getInputValue("redirectOnFailure");
0677: String redirectOnSuccess = (String) handlerCtx
0678: .getInputValue("redirectOnSuccess");
0679: String redirectTo = redirectOnSuccess;
0680:
0681: Boolean isEnabledAfterInstallOrDeploy = (Boolean) handlerCtx
0682: .getInputValue("isEnabledAfterInstallOrDeploy");
0683:
0684: sLog
0685: .fine("InstallationHandlers.jbiUpdateValidatedArchive(), archivePath="
0686: + archivePath
0687: + ", jbiName="
0688: + jbiName
0689: + ", jbiType="
0690: + jbiType
0691: + ", isEnabledAfterInstallOrDeploy="
0692: + isEnabledAfterInstallOrDeploy
0693: + ", redirectOnFailure="
0694: + redirectOnFailure
0695: + ", redirectOnSuccess=" + redirectOnSuccess);
0696:
0697: String alertDetails = "";
0698: String alertSummary = "";
0699: String internalError = "";
0700: String successResult = "";
0701: String failureResult = "";
0702:
0703: boolean failureFlag = false;
0704: boolean internalErrorFlag = false;
0705: boolean isAlertNeeded = false;
0706: boolean noTargetFlag = false;
0707:
0708: int countSuccessfulStart = 0;
0709: int countFailedStart = 0;
0710: int countSuccessfulInstalls = 0;
0711: int countFailedInstalls = 0;
0712:
0713: Properties updateProperties = new Properties();
0714: updateProperties.setProperty(KEY_PATH, archivePath);
0715: updateProperties.setProperty(SharedConstants.KEY_NAME, jbiName);
0716: updateProperties.setProperty(SharedConstants.KEY_TYPE, jbiType);
0717:
0718: // TBD implement update component use-case when common client and runtime supports it
0719: // updateProperties = update(updateProperties)
0720:
0721: successResult = (String) updateProperties
0722: .getProperty(SharedConstants.SUCCESS_RESULT);
0723: internalError = (String) updateProperties
0724: .getProperty(SharedConstants.INTERNAL_ERROR);
0725:
0726: if (null != internalError) {
0727: internalErrorFlag = true;
0728: }
0729:
0730: //Sucessful update done, now delete the temporarily uploaded file
0731: deleteTempFile(archivePath);
0732:
0733: if (false) {
0734: redirectTo = redirectOnSuccess;
0735: } else {
0736: isAlertNeeded = true;
0737: alertSummary = "Update Failed";
0738: alertDetails = "Not Yet Implemented";
0739: redirectTo = redirectOnFailure;
0740: }
0741:
0742: handlerCtx.setOutputValue("isAlertNeeded", Boolean
0743: .toString(isAlertNeeded));
0744: handlerCtx.setOutputValue("alertSummary", alertSummary);
0745: handlerCtx.setOutputValue("alertDetails", alertDetails);
0746: handlerCtx.setOutputValue("redirectTo", redirectTo);
0747:
0748: sLog
0749: .fine("InstallationHandlers.jbiUpdateValidatedArchive(...), "
0750: + " isAlertNeeded="
0751: + isAlertNeeded
0752: + ", alertSummary="
0753: + alertSummary
0754: + ", alertDetails="
0755: + alertDetails
0756: + ", redirectTo=" + redirectTo);
0757: }
0758:
0759: /**
0760: * <p>
0761: *
0762: * Deletes the uploaded/installed archives from temporary location on disk
0763: * <p>
0764: *
0765: * Input value: "archiveStatus" -- Type: <code>Boolean</code></p> <p>
0766: *
0767: * Input value: "archivePath" -- Type: <code>String</code></p>
0768: *
0769: * @param handlerContext Description of Parameter
0770: */
0771: @Handler(id="deleteUploadedArchiveFromTmpDir",input={@HandlerInput(name="archivePath",type=String.class,required=true)})
0772: public static void deleteUploadedArchiveFromTmpDir(
0773: HandlerContext handlerContext) {
0774: String archivePath = (String) handlerContext
0775: .getInputValue("archivePath");
0776: deleteTempFile(archivePath);
0777: }
0778:
0779: /**
0780: * <p>
0781: *
0782: * Will set the filter type in the ListBean. <p>
0783: *
0784: * Input value: "operation" -- Type: <code> java.lang.String</code> Valid
0785: * operations: The filter type
0786: *
0787: * @param handlerCtx <code>HandlerContext</code> provides inputs and
0788: * outputs.
0789: */
0790: @Handler(id="initializeTargetShowList")
0791: public static void initializeTargetShowList(
0792: HandlerContext handlerCtx) {
0793: ShowBean showBean = BeanUtilities.getShowBean();
0794: showBean.initTargetNames();
0795: }
0796:
0797: /**
0798: * <p>
0799: *
0800: * This handler returns a list of Standalone server in sorted order </p>
0801: * <p>
0802: *
0803: * Input value: "list1" -- Type: <code> java.util.List</code> list one <p>
0804: *
0805: * Input value: "list2" -- Type: <code> java.util.List</code> list two <p>
0806: *
0807: * Output value: "optionList" -- Type: <code>java.util.List</code>/</p>
0808: *
0809: * @param handlerCtx The feature to be added to the ListToOptions
0810: * attribute
0811: */
0812: @Handler(id="addListToOptions",input={@HandlerInput(name="inputList",type=java.util.List.class,required=true),@HandlerInput(name="inputOptions",type=java.util.List.class,required=true)},output={@HandlerOutput(name="outputOptions",type=java.util.List.class)})
0813: public static void addListToOptions(HandlerContext handlerCtx) {
0814: List inputList = (List) handlerCtx.getInputValue("inputList");
0815: List inputOptions = (List) handlerCtx
0816: .getInputValue("inputOptions");
0817: ArrayList outputOptions = new ArrayList();
0818: if (inputOptions != null) {
0819: outputOptions.addAll(inputOptions);
0820: }
0821: for (int i = 0; i < inputList.size(); i++) {
0822: Option o = new Option((String) inputList.get(i),
0823: (String) inputList.get(i));
0824: outputOptions.add(o);
0825: }
0826: handlerCtx.setOutputValue("outputOptions", outputOptions);
0827: }
0828:
0829: /**
0830: * <p>
0831: *
0832: * will installled and uninstall the current component based on the
0833: * targets in the input lists </p> Valid operations: The filter type <p>
0834: *
0835: * Input value: "installList" -- Type: <code> java.util.List</code> list
0836: * of target to install to </p> <p>
0837: *
0838: * Input value: "uninstallList" -- Type: <code> java.util.List</code> list
0839: * of target to uninstall from </p> <p>
0840: *
0841: * Output value: "isAlertNeeded" -- Type: <code>java.lang.Boolean</code>
0842: * </p> <p>
0843: *
0844: * Output value: "alertSummary" -- Type: <code>String</code>/</p> <p>
0845: *
0846: * Output value: "alertDetails" -- Type: <code>String</code>/</p> Valid
0847: * types: 'deployments,' 'bindingsEngines,' or 'libraries.'
0848: *
0849: * @param handlerCtx <code>HandlerContext</code> provides inputs and
0850: * outputs.
0851: */
0852: @Handler(id="jbiManageTargets",input={@HandlerInput(name="installList",type=java.util.List.class,required=true),@HandlerInput(name="uninstallList",type=java.util.List.class,required=true)},output={@HandlerOutput(name="isAlertNeeded",type=Boolean.class),@HandlerOutput(name="alertSummary",type=String.class),@HandlerOutput(name="alertDetails",type=String.class)})
0853: public static void jbiManageTargets(HandlerContext handlerCtx) {
0854:
0855: List installList = (List) handlerCtx
0856: .getInputValue("installList");
0857: List uninstallList = (List) handlerCtx
0858: .getInputValue("uninstallList");
0859: // Retrieve the needed information from the show bean
0860: ShowBean showBean = BeanUtilities.getShowBean();
0861: // String[] selectedNames = showBean.getTargetNames();
0862: // String[] originalNames = showBean.getOriginalTargetNames();
0863: String name = showBean.getName();
0864: String type = showBean.getType();
0865:
0866: String alertDetails = "";
0867: String alertSummary = "";
0868: String internalError = "";
0869: String successResult = "";
0870: String failureResult = "";
0871:
0872: // Convert the arrays to list, so we can easily determine what has
0873: // been added or removed from the selected entries.
0874: // List selected = Arrays.asList(selectedNames);
0875: // List original = Arrays.asList(originalNames);
0876:
0877: Properties prop = new Properties();
0878: prop.setProperty(SharedConstants.KEY_NAME, name);
0879: prop.setProperty(SharedConstants.KEY_TYPE, type);
0880: prop.setProperty(KEY_ARCHIVE_NAME, name);
0881:
0882: int countFailedDeletions = 0;
0883: int countSuccessfulDeletions = 0;
0884: int countFailedInstalls = 0;
0885: int countSuccessfulInstalls = 0;
0886:
0887: boolean failureFlag = false;
0888: boolean internalErrorFlag = false;
0889: boolean isAlertNeeded = false;
0890:
0891: // First we will uninstall any component/assembly that was in the original list,
0892: // but is not in the new selected list.
0893: /*
0894: * for (Iterator it=original.iterator(); it.hasNext(); )
0895: * {
0896: * String target = (String)it.next();
0897: * if (!(selected.contains(target)))
0898: * {
0899: * ArrayList targetList = new ArrayList();
0900: * targetList.add(target);
0901: */
0902: for (Iterator it = uninstallList.iterator(); it.hasNext();) {
0903: String target = (String) it.next();
0904:
0905: ArrayList<String> targetList = new ArrayList<String>();
0906: targetList.add(target);
0907:
0908: // When managing targets, when we remove a component/assembly/library
0909: // we want to make sure it is retained in the domain.
0910: boolean retainFlag = true;
0911:
0912: delete(prop, retainFlag, targetList);
0913:
0914: successResult = (String) prop
0915: .getProperty(SharedConstants.SUCCESS_RESULT);
0916: internalError = (String) prop
0917: .getProperty(SharedConstants.INTERNAL_ERROR);
0918:
0919: if (null != internalError) {
0920: internalErrorFlag = true;
0921: break;
0922: }
0923:
0924: if (null != successResult) {
0925: ++countSuccessfulDeletions;
0926: }
0927:
0928: else {
0929: failureFlag = true;
0930: ++countFailedDeletions;
0931: failureResult = (String) prop
0932: .getProperty(SharedConstants.FAILURE_RESULT);
0933: alertDetails += failureResult + "<br>";
0934: }
0935: }
0936: //}
0937:
0938: prop = new Properties();
0939: prop.setProperty(SharedConstants.KEY_NAME, name);
0940: prop.setProperty(SharedConstants.KEY_TYPE, type);
0941: prop.setProperty(KEY_ARCHIVE_NAME, name);
0942:
0943: // Next we will install any component that is in the new selected list, but
0944: // was not in the original list.
0945: if (!(internalErrorFlag)) {
0946: for (Iterator it = installList.iterator(); it.hasNext();) {
0947: String target = (String) it.next();
0948: // if (!(original.contains(target)))
0949: // {
0950: prop = install(prop, target);
0951:
0952: successResult = (String) prop
0953: .getProperty(SharedConstants.SUCCESS_RESULT);
0954: internalError = (String) prop
0955: .getProperty(SharedConstants.INTERNAL_ERROR);
0956:
0957: if (null != internalError) {
0958: internalErrorFlag = true;
0959: break;
0960: }
0961:
0962: if (null != successResult) {
0963: ++countSuccessfulInstalls;
0964: }
0965:
0966: else {
0967: failureFlag = true;
0968: ++countFailedInstalls;
0969: failureResult = (String) prop
0970: .getProperty(SharedConstants.FAILURE_RESULT);
0971: alertDetails += failureResult + "<br>";
0972: }
0973: }
0974: }
0975: // }
0976:
0977: // Display the alert message if a failure was encountered during manage targets
0978: if (failureFlag || internalErrorFlag) {
0979: isAlertNeeded = true;
0980: if (internalErrorFlag) {
0981: alertSummary = I18nUtilities
0982: .getResourceString("jbi.internal.error.summary");
0983: alertDetails = internalError;
0984: } else {
0985: //if ((countFailedInstalls > 0) && (countFailedDeletions > 0))
0986: //{
0987: // alertSummary = I18nUtilities.getResourceString ("jbi.manage.targets.install.and.delete.failure");
0988: //}
0989: //else if (countFailedInstalls > 0)
0990: //{
0991: // alertSummary = I18nUtilities.getResourceString ("jbi.manage.targets.install.failure");
0992: //}
0993: //else if (countFailedDeletions > 0)
0994: //{
0995: // alertSummary = I18nUtilities.getResourceString ("jbi.manage.targets.install.failure");
0996: //}
0997: }
0998: alertSummary = I18nUtilities
0999: .getResourceString("jbi.manage.targets.failure");
1000: alertDetails = BeanUtilities
1001: .addAlertFooterMessage(alertDetails);
1002: }
1003: handlerCtx.setOutputValue("isAlertNeeded", Boolean
1004: .toString(isAlertNeeded));
1005: handlerCtx.setOutputValue("alertSummary", alertSummary);
1006: handlerCtx.setOutputValue("alertDetails", alertDetails);
1007:
1008: sLog.fine("InstallationHandlers.manageTargets(...), "
1009: + " isAlertNeeded=" + isAlertNeeded + ", alertSummary="
1010: + alertSummary + ", alertDetails=" + alertDetails);
1011:
1012: sLog.fine("InstallationHandlers.manageTargets(...), "
1013: + " countSuccessfulDeletions="
1014: + countSuccessfulDeletions
1015: + ", countSuccessfulInstalls="
1016: + countSuccessfulInstalls + ", countFailedInstalls="
1017: + countFailedInstalls + ", countFailedDeletions="
1018: + countFailedDeletions);
1019:
1020: }
1021:
1022: /**
1023: * <p>
1024: *
1025: * Delegates JBI removal requests for each selected row; accumulates
1026: * failures into alert <p>
1027: *
1028: * Input value: "tableRowGroup" -- Type: <code> com.sun.webui.jsf.component.TableRowGroup</code>
1029: * </p> <p>
1030: *
1031: * Input value: "targetName" -- Type: <code> java.lang.String</code> <p>
1032: *
1033: * Output value: "isAlertNeeded" -- Type: <code>java.lang.Boolean</code>
1034: * </p> <p>
1035: *
1036: * Output value: "alertSummary" -- Type: <code>String</code>/</p> <p>
1037: *
1038: * Output value: "alertDetails" -- Type: <code>String</code>/</p>
1039: *
1040: * @param handlerCtx <code>HandlerContext</code> provides inputs and
1041: * outputs.
1042: */
1043: @Handler(id="jbiRemoveSelectedSingleTargetRows",input={@HandlerInput(name="tableRowGroup",type=TableRowGroup.class,required=true),@HandlerInput(name="targetName",type=String.class,required=true)},output={@HandlerOutput(name="isAlertNeeded",type=Boolean.class),@HandlerOutput(name="alertSummary",type=String.class),@HandlerOutput(name="alertDetails",type=String.class)})
1044: public static void jbiRemoveSelectedSingleTargetRows(
1045: HandlerContext handlerCtx) {
1046:
1047: TableRowGroup trg = (TableRowGroup) handlerCtx
1048: .getInputValue("tableRowGroup");
1049: String targetName = (String) handlerCtx
1050: .getInputValue("targetName");
1051: sLog
1052: .fine("InstallationHandlers.jbiRemoveSelectedSingleTargetRows("
1053: + trg + ", " + targetName + ")");
1054:
1055: // TBD logic goes here...
1056: List deletionRows = TableUtilities
1057: .getSelectedRowProperties(trg);
1058: Iterator rowIt = deletionRows.iterator();
1059:
1060: int countFailedDeletions = 0;
1061: int countSuccessfulDeletions = 0;
1062:
1063: String alertDetails = "";
1064: String alertSummary = "";
1065: boolean isAlertNeeded = false;
1066:
1067: while (rowIt.hasNext()) {
1068: Properties rowProperties = (Properties) rowIt.next();
1069: String rowName = (String) rowProperties
1070: .getProperty(SharedConstants.KEY_NAME);
1071: String rowType = (String) rowProperties
1072: .getProperty(SharedConstants.KEY_TYPE);
1073:
1074: List targets = new ArrayList();
1075: targets.add(targetName);
1076:
1077: // When deleting a row (component, deployment, or library) from the
1078: // shared single target (cluster or stand-alone instance) table, (via a button)
1079: // we always want to retain the component, deployment, or library in the domain.
1080: boolean retainFlag = true;
1081:
1082: delete(rowProperties, retainFlag, targets);
1083:
1084: String successResult = (String) rowProperties
1085: .getProperty(SharedConstants.SUCCESS_RESULT);
1086:
1087: if (null != successResult) {
1088: ++countSuccessfulDeletions;
1089: sLog
1090: .fine("InstallationHandlers.jbiRemoveSelectedSingleTargetRows(...), "
1091: + " success for "
1092: + rowProperties
1093: + ", countFailedDeletions="
1094: + countFailedDeletions
1095: + ", countSuccessfulDeletions="
1096: + countSuccessfulDeletions);
1097: } else {
1098: isAlertNeeded = true;
1099: // at least one failure
1100: alertSummary = I18nUtilities
1101: .getResourceString("jbi.remove.from.target.failed");
1102:
1103: ++countFailedDeletions;
1104: sLog
1105: .fine("InstallationHandlers.jbiRemoveSelectedSingleTargetRows(...), "
1106: + " failure for "
1107: + rowProperties
1108: + ", countFailedDeletions="
1109: + countFailedDeletions
1110: + ", countSuccessfulDeletions="
1111: + countSuccessfulDeletions);
1112: String failureResult = (String) rowProperties
1113: .getProperty(SharedConstants.FAILURE_RESULT);
1114:
1115: String details = "";
1116: String exceptionMessage = AlertUtilities
1117: .getMessage(failureResult);
1118: if ("".equals(exceptionMessage)) {
1119: details = failureResult;
1120: } else {
1121: details = exceptionMessage;
1122: }
1123: Object[] args = { rowName, details };
1124: String alertDet = GuiUtil
1125: .getMessage(
1126: I18nUtilities
1127: .getResourceString("jbi.deletion.failed.for.row"),
1128: args);
1129: alertDetails += alertDet + "<br />";
1130: }
1131:
1132: }
1133:
1134: handlerCtx.setOutputValue("isAlertNeeded", Boolean
1135: .toString(isAlertNeeded));
1136: handlerCtx.setOutputValue("alertSummary", alertSummary);
1137: handlerCtx.setOutputValue("alertDetails", alertDetails);
1138:
1139: sLog
1140: .fine("InstallationHandlers.jbiInstallValidatedArchive(...), "
1141: + " isAlertNeeded="
1142: + isAlertNeeded
1143: + ", alertSummary="
1144: + alertSummary
1145: + ", alertDetails=" + alertDetails);
1146: }
1147:
1148: /*
1149: * <p> This handler returns a 2 list of Installation target classes. One
1150: * for avialable installation targets for the current component and
1151: * second the targets list where the current component currently installed </p>
1152: * <p> Input value: "list1" -- Type: <code> java.util.List</code> list one
1153: * <p> Input value: "list2" -- Type: <code> java.util.List</code> list two
1154: * <p> Input value: "isJBIArcheiveAvailable" -- Type: <code> java.lang.Boolean </code>
1155: * <p> Output value: "avialableTargetList" -- Type: <code>java.util.List</code>/</p>
1156: * <p> Output value: "installedTargetList" -- Type: <code>java.util.List</code>/</p>
1157: * @param context The HandlerContext.
1158: */
1159: /**
1160: * Description of the Method
1161: *
1162: * @param handlerCtx Description of Parameter
1163: */
1164: @Handler(id="jbiGetTargetsLists",input={@HandlerInput(name="inputList",type=java.util.List.class,required=true),@HandlerInput(name="inputOptions",type=java.util.List.class,required=true),@HandlerInput(name="isJBIArchiveAvailable",type=Boolean.class,required=true)},output={@HandlerOutput(name="availableTargetList",type=java.util.List.class),@HandlerOutput(name="installedTargetList",type=java.util.List.class)})
1165: public static void jbiGetTargetsLists(HandlerContext handlerCtx) {
1166: List inputList = (List) handlerCtx.getInputValue("inputList");
1167: List inputOptions = (List) handlerCtx
1168: .getInputValue("inputOptions");
1169: Boolean isJBIArcheiveAvailable = (Boolean) handlerCtx
1170: .getInputValue("isJBIArchiveAvailable");
1171: ArrayList<InstallationTarget> targetsList = new ArrayList<InstallationTarget>();
1172: ArrayList<InstallationTarget> availableTargetList = new ArrayList<InstallationTarget>();
1173: ArrayList<InstallationTarget> installedTargetList = new ArrayList<InstallationTarget>();
1174: if (inputOptions != null) {
1175: for (Iterator iter = inputOptions.iterator(); iter
1176: .hasNext();) {
1177: Option targetOption = (Option) iter.next();
1178: String targetName = (String) targetOption.getValue();
1179: InstallationTarget it = new InstallationTarget(
1180: targetName);
1181: if (!isJBIArcheiveAvailable
1182: && targetName.equals(InstallationTarget.SERVER)) {
1183: // clear the preselected "server"
1184: it.setSelected(false);
1185: }
1186: targetsList.add(it);
1187: }
1188: }
1189: if (inputList != null) {
1190: for (Iterator iter = inputList.iterator(); iter.hasNext();) {
1191: String targetOption = (String) iter.next();
1192: InstallationTarget it = new InstallationTarget(
1193: targetOption);
1194: targetsList.add(it);
1195: }
1196: }
1197: if (!isJBIArcheiveAvailable) {
1198: // identify the installed and avialable targets
1199: // will be used by manage targets screen.
1200: ShowBean showBean = BeanUtilities.getShowBean();
1201: for (InstallationTarget target : targetsList) {
1202: String targetName = target.getName();
1203: String status = showBean.check(targetName);
1204: if (null != status) {
1205: installedTargetList.add(target);
1206: } else {
1207: availableTargetList.add(target);
1208: }
1209: }
1210:
1211: } else {
1212: availableTargetList.addAll(targetsList);
1213: }
1214:
1215: handlerCtx.setOutputValue("availableTargetList",
1216: availableTargetList);
1217: handlerCtx.setOutputValue("installedTargetList",
1218: installedTargetList);
1219: }
1220:
1221: /**
1222: * <p>
1223: *
1224: * return a list of selected targets name from the avialable table <p>
1225: *
1226: * Input value: "availableTargetTableRowGroup" -- Type: <code> com.sun.webui.jsf.component.TableRowGroup</code>
1227: * </p> <p>
1228: *
1229: * Output value: "selectedAvailableTargetsList" -- Type: <code>String</code>
1230: * /</p>
1231: *
1232: * @param handlerCtx <code>HandlerContext</code> provides inputs and
1233: * outputs.
1234: */
1235: @Handler(id="jbiGetSelectedTargetsFromAvailableTable",input={@HandlerInput(name="availableTableRowGroup",type=TableRowGroup.class,required=true)},output={@HandlerOutput(name="selectedAvailableTargetsList",type=java.util.List.class)})
1236: public static void jbiGetSelectedTargetsFromAvailableTable(
1237: HandlerContext handlerCtx) {
1238:
1239: ArrayList<String> selectedList = new ArrayList<String>();
1240: String[] targetsName = null;
1241: TableRowGroup trg = (TableRowGroup) handlerCtx
1242: .getInputValue("availableTableRowGroup");
1243:
1244: ObjectListDataProvider dp = (ObjectListDataProvider) trg
1245: .getSourceData();
1246: dp.commitChanges();
1247:
1248: if (null != dp && dp.getRowCount() > 0) {
1249: FieldKey targetname = dp.getFieldKey(KEY_NAME);
1250: RowKey[] rowKeys = trg.getSelectedRowKeys();
1251: targetsName = new String[rowKeys.length];
1252: for (int index = 0; index < rowKeys.length; index++) {
1253: String name = (String) dp.getValue(targetname,
1254: rowKeys[index]);
1255: selectedList.add(name);
1256: targetsName[index] = name;
1257: }
1258: }
1259: InstallationBean installationBean = BeanUtilities
1260: .getInstallationBean();
1261: installationBean.setTargetNames(targetsName);
1262:
1263: handlerCtx.setOutputValue("selectedAvailableTargetsList",
1264: selectedList);
1265: }
1266:
1267: /**
1268: * <p>
1269: *
1270: * return a list of selected targets name from the installed table <p>
1271: *
1272: * Input value: "availableTargetTableRowGroup" -- Type: <code> com.sun.webui.jsf.component.TableRowGroup</code>
1273: * </p> <p>
1274: *
1275: * Output value: "selectedInstalledTargetsList" -- Type: <code>String</code>
1276: * /</p>
1277: *
1278: * @param handlerCtx <code>HandlerContext</code> provides inputs and
1279: * outputs.
1280: */
1281: @Handler(id="jbiGetSelectedTargetsFromInstalledTable",input={@HandlerInput(name="installedTableRowGroup",type=TableRowGroup.class,required=true)},output={@HandlerOutput(name="selectedInstalledTargetsList",type=java.util.List.class)})
1282: public static void jbiGetSelectedTargetsFromInstalledTable(
1283: HandlerContext handlerCtx) {
1284:
1285: ArrayList<String> selectedList = new ArrayList<String>();
1286: String[] targetsName = null;
1287: TableRowGroup trg = (TableRowGroup) handlerCtx
1288: .getInputValue("installedTableRowGroup");
1289:
1290: ObjectListDataProvider dp = (ObjectListDataProvider) trg
1291: .getSourceData();
1292: dp.commitChanges();
1293:
1294: if (null != dp && dp.getRowCount() > 0) {
1295: FieldKey targetname = dp.getFieldKey(KEY_NAME);
1296: RowKey[] rowKeys = trg.getSelectedRowKeys();
1297: targetsName = new String[rowKeys.length];
1298: for (int index = 0; index < rowKeys.length; index++) {
1299: String name = (String) dp.getValue(targetname,
1300: rowKeys[index]);
1301: selectedList.add(name);
1302: targetsName[index] = name;
1303: }
1304: }
1305: InstallationBean installationBean = BeanUtilities
1306: .getInstallationBean();
1307: installationBean.setTargetNames(targetsName);
1308:
1309: handlerCtx.setOutputValue("selectedInstalledTargetsList",
1310: selectedList);
1311: }
1312:
1313: /**
1314: * <p>
1315: *
1316: * return a list of targets built from a single target <p>
1317: *
1318: * Input value: "singleTarget" -- Type: <code>String</code></p> <p>
1319: *
1320: * Output value: "installTargetsList" -- Type: <code>java.util.List</code>
1321: * /</p>
1322: *
1323: * @param handlerCtx <code>HandlerContext</code> provides inputs and
1324: * outputs.
1325: */
1326: @Handler(id="jbiCreateSingleTargetList",input={@HandlerInput(name="singleTarget",type=String.class,required=true)},output={@HandlerOutput(name="installTargetsList",type=java.util.List.class)})
1327: public static void jbiCreateSingleTargetList(
1328: HandlerContext handlerCtx) {
1329:
1330: ArrayList<String> installTargetsList = new ArrayList<String>();
1331: String singleTarget = (String) handlerCtx
1332: .getInputValue("singleTarget");
1333:
1334: installTargetsList.add(singleTarget);
1335: sLog.fine("InstallationHandlers.jbiCreateSingleTargetList("
1336: + singleTarget + "): " + installTargetsList);
1337:
1338: handlerCtx.setOutputValue("installTargetsList",
1339: installTargetsList);
1340: }
1341:
1342: /**
1343: * Description of the Field
1344: */
1345: public static final String KEY_ARCHIVE_NAME = "archiveName";
1346: /**
1347: * Description of the Field
1348: */
1349: public static final String KEY_PATH = "path";
1350: /**
1351: * Description of the Field
1352: */
1353: public static final String KEY_NAME = "name";
1354:
1355: /**
1356: * This method deletes the uploaded file from the temporary location on
1357: * local hard disk once the install is completed successfully or cancel
1358: * button is clicked
1359: *
1360: * @param aTempFile Description of Parameter
1361: */
1362: private static void deleteTempFile(String aTempFile) {
1363: InstallationBean installationBean = BeanUtilities
1364: .getInstallationBean();
1365: if (installationBean.getUploadSelected()) {
1366: sLog
1367: .fine("InstallationHandlers.deleteTempFile(...), delete archive..."
1368: + aTempFile);
1369: Boolean deletedUploadedFileInTmpDir = FileUtil
1370: .delete(aTempFile);
1371: sLog
1372: .fine("InstallationHandlers.deleteUploadedArchiveFromTmpDir(...), deletedUploadedFileInTmpDir="
1373: + deletedUploadedFileInTmpDir);
1374: }
1375: }
1376:
1377: /**
1378: * Description of the Method
1379: *
1380: * @param aRowProperties Description of Parameter
1381: * @param aRetainFlag Description of Parameter
1382: * @param aTargetsList Description of Parameter
1383: */
1384: private static void delete(Properties aRowProperties,
1385: boolean aRetainFlag, List aTargetsList) {
1386: sLog.fine("InstallationHandlers.delete(" + aRowProperties
1387: + ", " + aTargetsList + ")");
1388: DeletionBean deletionBean = BeanUtilities.getDeletionBean();
1389: // aRowProperties =
1390: deletionBean.delete(aRowProperties, aRetainFlag, aTargetsList);
1391:
1392: // TBD accumulate results
1393: }
1394:
1395: /**
1396: * Install using the information from the specified in the properties
1397: * variable to the specified target.
1398: *
1399: * @param aProp Description of Parameter
1400: * @param aTarget the name of the target to install to
1401: * @return result Properteis contain the result information
1402: */
1403: private static Properties install(Properties aProp, String aTarget) {
1404: InstallationBean installationBean = BeanUtilities
1405: .getInstallationBean();
1406: aProp = installationBean
1407: .installValidatedArchive(aProp, aTarget);
1408: return aProp;
1409: }
1410:
1411: /**
1412: * Description of the Method
1413: *
1414: * @param anInstallationProperties Description of Parameter
1415: * @return Description of the Returned Value
1416: */
1417: private static Properties install(
1418: Properties anInstallationProperties) {
1419: Properties result = null;
1420: sLog.fine("InstallationHandlers.install()");
1421: InstallationBean installationBean = BeanUtilities
1422: .getInstallationBean();
1423: anInstallationProperties = installationBean
1424: .installValidatedArchive(anInstallationProperties);
1425:
1426: // TBD show result
1427: result = anInstallationProperties;
1428: sLog.fine("InstallationHandlers.install(), result=" + result);
1429: return result;
1430: }
1431:
1432: private static final boolean IS_CLUSTER_PROFILE = ClusterUtilities
1433: .isClusterProfile();
1434:
1435: //Get Logger to log fine mesages for debugging
1436: private static Logger sLog = JBILogger.getInstance();
1437:
1438: /**
1439: * prevents instantiation
1440: */
1441: private InstallationHandlers() {
1442: }
1443:
1444: }
|