/******************************************************************************* * Copyright (c) 2011, 2016 Eurotech and/or its affiliates * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eurotech *******************************************************************************/ package org.eclipse.kura.core.deployment.uninstall; import org.eclipse.kura.KuraErrorCode; import org.eclipse.kura.KuraException; import org.eclipse.kura.KuraInvalidMessageException; import org.eclipse.kura.core.deployment.DeploymentPackageOptions; import org.eclipse.kura.message.KuraPayload; import org.eclipse.kura.message.KuraRequestPayload; public class DeploymentPackageUninstallOptions extends DeploymentPackageOptions { // Metrics in RESOURCE_INSTALL public DeploymentPackageUninstallOptions(String deployUrl, String dpName, String dpVersion) { super(dpName, dpVersion); } public DeploymentPackageUninstallOptions(KuraPayload request) throws KuraException { super(null, null); super.setDpName((String) request.getMetric(METRIC_DP_NAME)); if (super.getDpName() == null) { throw new KuraInvalidMessageException("Missing deployment package name!"); } super.setJobId((Long) request.getMetric(METRIC_JOB_ID)); if (super.getJobId() == null) { throw new KuraInvalidMessageException("Missing jobId!"); } try { Object metric = request.getMetric(METRIC_DP_VERSION); if (metric != null) { super.setDpVersion((String) metric); } metric = request.getMetric(METRIC_DP_REBOOT); if (metric != null) { super.setReboot((Boolean) metric); } metric = request.getMetric(METRIC_DP_REBOOT_DELAY); if (metric != null) { super.setRebootDelay((Integer) metric); } metric = request.getMetric(KuraRequestPayload.REQUESTER_CLIENT_ID); if (metric != null) { super.setRequestClientId((String) metric); } } catch (Exception ex) { throw new KuraException(KuraErrorCode.INTERNAL_ERROR, ex); } } }