Java 类com.vmware.vim25.LocalizedMethodFault 实例源码

项目:photon-model    文件:LeaseProgressUpdater.java   
/**
 * Wait up to a minute for the nfcLease to become READY.
 * @throws Exception
 */
public void awaitReady() throws Exception {
    int i = 60;

    while (i-- > 0) {
        HttpNfcLeaseState state = getState();
        if (state.equals(HttpNfcLeaseState.ERROR)) {
            LocalizedMethodFault leaseError = this.get.entityProp(this.nfcLease, PROP_ERROR);
            logger.warn("nfcLease error: {}", leaseError.getLocalizedMessage(), leaseError);
            VimUtils.rethrow(leaseError);
        }

        if (state.equals(HttpNfcLeaseState.READY)) {
            return;
        }

        logger.debug("Waiting for nfcLease {}", VimUtils.convertMoRefToString(this.nfcLease), state);

        Thread.sleep(LEASE_READY_RETRY_MILLIS);
    }

    throw new IllegalStateException("Lease not ready within configured timeout");
}
项目:photon-model    文件:VimUtils.java   
/**
 * This method never returns but throws an Exception wrapping the fault.
 *
 * @param lmf
 * @param <T>
 * @return
 * @throws Exception
 */
public static <T> T rethrow(LocalizedMethodFault lmf) throws Exception {
    Class<?> type = lmf.getFault().getClass();
    String possibleWrapperType = type.getName() + EXCEPTION_SUFFIX;

    Exception ex;
    try {
        ClassLoader cl = type.getClassLoader();
        Class<?> faultClass = cl.loadClass(possibleWrapperType);
        Constructor<?> ctor = faultClass.getConstructor(String.class, type);
        ex = (Exception) ctor.newInstance(lmf.getLocalizedMessage(), lmf.getFault());
    } catch (ReflectiveOperationException e) {
        throw new GenericVimFault(lmf.getLocalizedMessage(), lmf.getFault());
    }

    throw ex;
}
项目:photon-model    文件:VimUtilsTest.java   
@Test
public void retrhowKnownException() {
    DuplicateName dn = new DuplicateName();

    LocalizedMethodFault lmf = new LocalizedMethodFault();
    lmf.setLocalizedMessage("msg");
    lmf.setFault(dn);

    try {
        VimUtils.rethrow(lmf);
        fail();
    } catch (DuplicateNameFaultMsg msg) {
        assertSame(dn, msg.getFaultInfo());
        assertSame(lmf.getLocalizedMessage(), msg.getMessage());
    } catch (Exception e) {
        fail();
    }
}
项目:photon-model    文件:VimUtilsTest.java   
@Test
public void retrhowUnknownException() {
    ConnectedIso dn = new ConnectedIso();

    LocalizedMethodFault lmf = new LocalizedMethodFault();
    lmf.setLocalizedMessage("msg");
    lmf.setFault(dn);

    try {
        VimUtils.rethrow(lmf);
        fail();
    } catch (GenericVimFault msg) {
        assertSame(dn, msg.getFaultInfo());
        assertSame(lmf.getLocalizedMessage(), msg.getMessage());
    } catch (Exception e) {
        fail();
    }
}
项目:vsphere-automation-sdk-java    文件:WaitForValues.java   
/**
 * This method returns a boolean value specifying whether the Task is
 * succeeded or failed.
 *
 * @param task
 *            ManagedObjectReference representing the Task.
 * @return boolean value representing the Task result.
 * @throws InvalidCollectorVersionFaultMsg
 *
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidPropertyFaultMsg
 */
public boolean getTaskResultAfterDone(ManagedObjectReference task)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg,
        InvalidCollectorVersionFaultMsg {

    boolean retVal = false;

    // info has a property - state for state of the task
    Object[] result = wait(task,
            new String[] { "info.state", "info.error" },
            new String[] { "state" }, new Object[][] { new Object[] {
                TaskInfoState.SUCCESS, TaskInfoState.ERROR } });

    if (result[0].equals(TaskInfoState.SUCCESS)) {
        retVal = true;
    }
    if (result[1] instanceof LocalizedMethodFault) {
        throw new RuntimeException(
                ((LocalizedMethodFault) result[1]).getLocalizedMessage());
    }
    return retVal;
}
项目:cloudstack    文件:TaskMO.java   
public static String getTaskFailureInfo(VmwareContext context, ManagedObjectReference morTask) {
    StringBuffer sb = new StringBuffer();

    try {
        TaskInfo info = (TaskInfo)context.getVimClient().getDynamicProperty(morTask, "info");
        if (info != null) {
            LocalizedMethodFault fault = info.getError();
            if (fault != null) {
                sb.append(fault.getLocalizedMessage()).append(" ");

                if (fault.getFault() != null)
                    sb.append(fault.getFault().getClass().getName());
            }
        }
    } catch (Exception e) {
        s_logger.info("[ignored]"
                + "error retrieving failure info for task : " + e.getLocalizedMessage());
    }

    return sb.toString();
}
项目:cloudstack    文件:VMwareUtil.java   
public static boolean waitForTask(VMwareConnection connection, ManagedObjectReference task) throws Exception {
    try {
        Object[] result = waitForValues(connection, task, new String[] { "info.state", "info.error" }, new String[] { "state" },
                new Object[][] { new Object[] { TaskInfoState.SUCCESS, TaskInfoState.ERROR } });

        if (result[0].equals(TaskInfoState.SUCCESS)) {
            return true;
        }

        if (result[1] instanceof LocalizedMethodFault) {
            throw new Exception(((LocalizedMethodFault)result[1]).getLocalizedMessage());
        }
    } catch (WebServiceException we) {
        s_logger.debug("Cancelling vCenter task because the task failed with the following error: " + we.getLocalizedMessage());

        connection.getVimPortType().cancelTask(task);

        throw new Exception("The vCenter task failed due to the following error: " + we.getLocalizedMessage());
    }

    return false;
}
项目:photon-model    文件:LeaseProgressUpdater.java   
public void abort(LocalizedMethodFault e) {
    this.done.set(true);

    try {
        getVimPort().httpNfcLeaseAbort(this.nfcLease, e);
    } catch (RuntimeFaultFaultMsg | TimedoutFaultMsg | InvalidStateFaultMsg ex) {
        logger.warn("Error aborting nfcLease {}", VimUtils.convertMoRefToString(this.nfcLease), e);
    }
}
项目:photon-model    文件:VimUtilsTest.java   
@Test
public void convertToFault() {
    DuplicateName fault = new DuplicateName();
    String msg = "msg";
    Exception e = new DuplicateNameFaultMsg(msg, fault);

    LocalizedMethodFault lmf = VimUtils.convertExceptionToFault(e);
    assertSame(fault, lmf.getFault());
    assertSame(msg, lmf.getLocalizedMessage());
}
项目:photon-model    文件:VimUtilsTest.java   
@Test
public void convertToFaultGeneric() {
    String msg = "test";
    IOException e = new IOException(msg);

    LocalizedMethodFault lmf = VimUtils.convertExceptionToFault(e);
    assertNull(lmf.getFault());
    assertSame(msg, lmf.getLocalizedMessage());
}
项目:cs-actions    文件:OvfUtils.java   
public static String getHttpNfcLeaseErrorState(final ConnectionResources connectionResources, final ManagedObjectReference httpNfcLease) throws Exception {
    final ObjectContent objectContent = GetObjectProperties.getObjectProperty(connectionResources, httpNfcLease, "error");
    final List<DynamicProperty> dynamicProperties = objectContent.getPropSet();
    if (firstElementIsOfClass(dynamicProperties, LocalizedMethodFault.class)) {
        return ((LocalizedMethodFault) dynamicProperties.get(0).getVal()).getLocalizedMessage();
    }
    throw new Exception(LEASE_ERROR_STATE_COULD_NOT_BE_OBTAINED);
}
项目:cs-actions    文件:ResponseHelper.java   
protected boolean getTaskResultAfterDone(ConnectionResources connectionResources, ManagedObjectReference task)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {
    WaitForValues waitForValues = new WaitForValues(connectionResources.getConnection());
    Object[] result = waitForValues.wait(task, new String[]{ManagedObjectType.INFO_STATE.getValue(),
                    ManagedObjectType.INFO_ERROR.getValue()}, new String[]{ManagedObjectType.STATE.getValue()},
            new Object[][]{new Object[]{TaskInfoState.SUCCESS, TaskInfoState.ERROR}});

    if (result[1] instanceof LocalizedMethodFault) {
        throw new RuntimeException(((LocalizedMethodFault) result[1]).getLocalizedMessage());
    }

    return result[0].equals(TaskInfoState.SUCCESS);
}
项目:cs-actions    文件:DeployOvfTemplateService.java   
private void checkImportSpecResultForErrors(OvfCreateImportSpecResult importSpecResult) throws Exception {
    if (0 < importSpecResult.getError().size()) {
        StringBuilder stringBuilder = new StringBuilder();
        for (LocalizedMethodFault fault : importSpecResult.getError()) {
            stringBuilder.append(fault.getLocalizedMessage()).append(System.lineSeparator());
        }
        throw new Exception(stringBuilder.toString());
    }
}
项目:vijava    文件:HttpNfcLease.java   
public LocalizedMethodFault getError()
{
    return (LocalizedMethodFault) getCurrentProperty("error");
}
项目:vijava    文件:HttpNfcLease.java   
public void httpNfcLeaseAbort(LocalizedMethodFault fault) throws Timedout, InvalidState, RuntimeFault, RemoteException
{
    getVimService().httpNfcLeaseAbort(getMOR(), fault);
}
项目:vijava    文件:Task.java   
public void setTaskState(TaskInfoState tis, Object result, LocalizedMethodFault fault) throws InvalidState, RuntimeFault, RemoteException 
{
    getVimService().setTaskState(getMOR(), tis, result, fault);
}
项目:cloudstack    文件:TaskMO.java   
public void setTaskState(TaskInfoState state, Object result, LocalizedMethodFault fault) throws Exception {
    _context.getService().setTaskState(_mor, state, result, fault);
}
项目:cloudstack    文件:HttpNfcLeaseMO.java   
public LocalizedMethodFault getLeaseError() throws Exception {
    return (LocalizedMethodFault)_context.getVimClient().getDynamicProperty(_mor, "error");
}
项目:photon-model    文件:PbmPlacementCompatibilityResult.java   
/**
 * Gets the value of the warning property.
 * 
 * <p>
 * This accessor method returns a reference to the live list,
 * not a snapshot. Therefore any modification you make to the
 * returned list will be present inside the JAXB object.
 * This is why there is not a <CODE>set</CODE> method for the warning property.
 * 
 * <p>
 * For example, to add a new item, do as follows:
 * <pre>
 *    getWarning().add(newItem);
 * </pre>
 * 
 * 
 * <p>
 * Objects of the following type(s) are allowed in the list
 * {@link LocalizedMethodFault }
 * 
 * 
 */
public List<LocalizedMethodFault> getWarning() {
    if (warning == null) {
        warning = new ArrayList<LocalizedMethodFault>();
    }
    return this.warning;
}
项目:photon-model    文件:PbmPlacementCompatibilityResult.java   
/**
 * Gets the value of the error property.
 * 
 * <p>
 * This accessor method returns a reference to the live list,
 * not a snapshot. Therefore any modification you make to the
 * returned list will be present inside the JAXB object.
 * This is why there is not a <CODE>set</CODE> method for the error property.
 * 
 * <p>
 * For example, to add a new item, do as follows:
 * <pre>
 *    getError().add(newItem);
 * </pre>
 * 
 * 
 * <p>
 * Objects of the following type(s) are allowed in the list
 * {@link LocalizedMethodFault }
 * 
 * 
 */
public List<LocalizedMethodFault> getError() {
    if (error == null) {
        error = new ArrayList<LocalizedMethodFault>();
    }
    return this.error;
}
项目:photon-model    文件:PbmRollupComplianceResult.java   
/**
 * Gets the value of the errorCause property.
 * 
 * <p>
 * This accessor method returns a reference to the live list,
 * not a snapshot. Therefore any modification you make to the
 * returned list will be present inside the JAXB object.
 * This is why there is not a <CODE>set</CODE> method for the errorCause property.
 * 
 * <p>
 * For example, to add a new item, do as follows:
 * <pre>
 *    getErrorCause().add(newItem);
 * </pre>
 * 
 * 
 * <p>
 * Objects of the following type(s) are allowed in the list
 * {@link LocalizedMethodFault }
 * 
 * 
 */
public List<LocalizedMethodFault> getErrorCause() {
    if (errorCause == null) {
        errorCause = new ArrayList<LocalizedMethodFault>();
    }
    return this.errorCause;
}
项目:photon-model    文件:PbmComplianceResult.java   
/**
 * Gets the value of the errorCause property.
 * 
 * <p>
 * This accessor method returns a reference to the live list,
 * not a snapshot. Therefore any modification you make to the
 * returned list will be present inside the JAXB object.
 * This is why there is not a <CODE>set</CODE> method for the errorCause property.
 * 
 * <p>
 * For example, to add a new item, do as follows:
 * <pre>
 *    getErrorCause().add(newItem);
 * </pre>
 * 
 * 
 * <p>
 * Objects of the following type(s) are allowed in the list
 * {@link LocalizedMethodFault }
 * 
 * 
 */
public List<LocalizedMethodFault> getErrorCause() {
    if (errorCause == null) {
        errorCause = new ArrayList<LocalizedMethodFault>();
    }
    return this.errorCause;
}
项目:photon-model    文件:PbmQueryProfileResult.java   
/**
 * Gets the value of the fault property.
 * 
 * @return
 *     possible object is
 *     {@link LocalizedMethodFault }
 *     
 */
public LocalizedMethodFault getFault() {
    return fault;
}
项目:photon-model    文件:PbmQueryProfileResult.java   
/**
 * Sets the value of the fault property.
 * 
 * @param value
 *     allowed object is
 *     {@link LocalizedMethodFault }
 *     
 */
public void setFault(LocalizedMethodFault value) {
    this.fault = value;
}
项目:photon-model    文件:PbmProfileOperationOutcome.java   
/**
 * Gets the value of the fault property.
 * 
 * @return
 *     possible object is
 *     {@link LocalizedMethodFault }
 *     
 */
public LocalizedMethodFault getFault() {
    return fault;
}
项目:photon-model    文件:PbmProfileOperationOutcome.java   
/**
 * Sets the value of the fault property.
 * 
 * @param value
 *     allowed object is
 *     {@link LocalizedMethodFault }
 *     
 */
public void setFault(LocalizedMethodFault value) {
    this.fault = value;
}
项目:photon-model    文件:PbmDataServiceToPoliciesMap.java   
/**
 * Gets the value of the fault property.
 * 
 * @return
 *     possible object is
 *     {@link LocalizedMethodFault }
 *     
 */
public LocalizedMethodFault getFault() {
    return fault;
}
项目:photon-model    文件:PbmDataServiceToPoliciesMap.java   
/**
 * Sets the value of the fault property.
 * 
 * @param value
 *     allowed object is
 *     {@link LocalizedMethodFault }
 *     
 */
public void setFault(LocalizedMethodFault value) {
    this.fault = value;
}
项目:photon-model    文件:PbmQueryReplicationGroupResult.java   
/**
 * Gets the value of the fault property.
 * 
 * @return
 *     possible object is
 *     {@link LocalizedMethodFault }
 *     
 */
public LocalizedMethodFault getFault() {
    return fault;
}
项目:photon-model    文件:PbmQueryReplicationGroupResult.java   
/**
 * Sets the value of the fault property.
 * 
 * @param value
 *     allowed object is
 *     {@link LocalizedMethodFault }
 *     
 */
public void setFault(LocalizedMethodFault value) {
    this.fault = value;
}