Example usage for org.apache.commons.lang BooleanUtils isTrue

List of usage examples for org.apache.commons.lang BooleanUtils isTrue

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils isTrue.

Prototype

public static boolean isTrue(Boolean bool) 

Source Link

Document

Checks if a Boolean value is true, handling null by returning false.

 BooleanUtils.isTrue(Boolean.TRUE)  = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null)          = false 

Usage

From source file:au.org.theark.study.web.component.subject.SearchResultListPanel.java

private AjaxLink buildLink(Item<SubjectVO> item, final AbstractDetailModalWindow modalWindow,
        final List<RelationshipVo> relatives, final FeedbackPanel feedbackPanel) {

    AjaxLink link = null;/*  www .  j a  v  a  2 s. c  om*/
    final SubjectVO subject = item.getModelObject();
    if ("Male".equalsIgnoreCase(subject.getLinkSubjectStudy().getPerson().getGenderType().getName())) {
        subject.setParentType("Father");
    } else {
        subject.setParentType("Mother");
    }

    Boolean inbreedAllowed = (Boolean) SecurityUtils.getSubject().getSession()
            .getAttribute(Constants.INBREED_ALLOWED);

    if (BooleanUtils.isTrue(inbreedAllowed)) {
        final String result = getCircularRelationships(subject, relatives);
        item.getModelObject().setMessage(result);
        if (isConsiderParentAge(subject) && result != null) {
            link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                    new StringResourceModel("pedigree.parent.dob.circular.warning", this, item.getModel()),
                    item.getModel()) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        } else if (isConsiderParentAge(subject)) {
            link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                    new StringResourceModel("pedigree.parent.dob.warning", this, item.getModel()),
                    item.getModel()) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        } else if (result != null) {
            link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                    new StringResourceModel("pedigree.parent.circular.warning", this, item.getModel()),
                    item.getModel()) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        } else {
            link = new ArkBusyAjaxLink(Constants.SUBJECT_UID) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        }

    } else {
        if (isConsiderParentAge(subject)) {
            link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                    new StringResourceModel("pedigree.parent.dob.warning", this, item.getModel()),
                    item.getModel()) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        } else {
            link = new ArkBusyAjaxLink(Constants.SUBJECT_UID) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        }
    }
    Label nameLinkLabel = new Label(Constants.SUBJECT_KEY_LBL, subject.getLinkSubjectStudy().getSubjectUID());
    link.add(nameLinkLabel);
    return link;
}

From source file:com.evolveum.midpoint.testing.wstest.AbstractWebserviceTest.java

private void checkAuditEnabled(SystemConfigurationType configurationType) throws FaultMessage {
    LoggingConfigurationType loggingConfig = configurationType.getLogging();
    AuditingConfigurationType auditConfig = loggingConfig.getAuditing();
    if (auditConfig == null) {
        auditConfig = new AuditingConfigurationType();
        auditConfig.setEnabled(true);//from  ww w  . j  av a 2 s.c o m
        loggingConfig.setAuditing(auditConfig);
    } else {
        if (BooleanUtils.isTrue(auditConfig.isEnabled())) {
            return;
        }
        auditConfig.setEnabled(true);
    }

    ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(SystemConfigurationType.class,
            SystemObjectsType.SYSTEM_CONFIGURATION.value(), "logging", ModificationTypeType.REPLACE,
            loggingConfig);

    ObjectDeltaOperationListType deltaOpList = modelPort.executeChanges(deltaList, null);

    assertSuccess(deltaOpList);
}

From source file:com.square.tarificateur.noyau.service.implementations.TarificateurServiceImpl.java

/**
 * {@inheritDoc}// w w  w  .  ja va 2  s  .co m
 */
@Override
public void enregistrerFinaliteDevis(EnregistrementFinaliteDevisDto enregistrementFinaliteDevisDto) {
    // Rcupration du devis
    logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_CLOTURE_DEVIS,
            new String[] { String.valueOf(enregistrementFinaliteDevisDto.getIdDevis()) }));

    final RapportDto rapportErreur = new RapportDto();
    if (enregistrementFinaliteDevisDto.getIdMotifDevis() == null) {
        rapportErreur.ajoutRapport("idMotifDevis", messageSourceUtil
                .get(MessageKeyUtil.ERROR_DEMANDE_CLOTURE_IMPOSSIBLE_MOTIF_DEVIS_NON_RENSEIGNE), true);
    }

    if (BooleanUtils.isTrue(rapportErreur.getEnErreur())) {
        RapportUtil.logRapport(rapportErreur, logger);
        throw new ControleIntegriteException(rapportErreur);
    }

    final Devis devis = devisDao.getDevis(enregistrementFinaliteDevisDto.getIdDevis());
    if (devis == null) {
        logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_CLOTURE_IMPOSSIBLE_DEVIS_INEXISTANT,
                new String[] { String.valueOf(enregistrementFinaliteDevisDto.getIdDevis()) }));
        throw new BusinessException(
                messageSourceUtil.get(MessageKeyUtil.ERROR_DEMANDE_CLOTURE_IMPOSSIBLE_DEVIS_INEXISTANT));
    }

    // Rcupration des lignes  modifier
    final Map<Long, Long> mapEnregistrementLignes = new HashMap<Long, Long>();
    for (EnregistrementFinaliteLigneDevisDto enregistrementLigne : enregistrementFinaliteDevisDto
            .getListeEnregistrementsFinaliteLignes()) {
        mapEnregistrementLignes.put(enregistrementLigne.getIdentifiantLigneDevis(),
                enregistrementLigne.getIdentifiantFinaliteLigneDevis());
    }

    final Long idMotifDevis = enregistrementFinaliteDevisDto.getIdMotifDevis();
    if (idMotifDevis != null) {
        final MotifDevis motifDevis = motifDevisDao.getMotifDevisById(idMotifDevis);
        if (motifDevis == null) {
            logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_MOTIF_DEVIS_INEXISTANT,
                    new String[] { String.valueOf(idMotifDevis) }));
            throw new BusinessException(messageSourceUtil.get(MessageKeyUtil.ERROR_MOTIF_DEVIS_INEXISTANT));
        }
        devis.setMotif(motifDevis);
    }

    // Si le devis ne contient aucune ligne, on ne fait rien
    if (devis.getListeLigneDevis().size() != 0) {
        // Mise  jour des lignes demandes
        for (LigneDevis ligne : devis.getListeLigneDevis()) {
            // Si la ligne doit tre modifie
            final Long idFinaliteLigne = mapEnregistrementLignes.get(ligne.getId());
            if (idFinaliteLigne != null) {

                final Finalite finalite = finaliteDao.getFinaliteById(idFinaliteLigne);
                if (finalite != null) {
                    ligne.setFinalite(finalite);
                    logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_FINALITE_LIGNE,
                            new String[] { String.valueOf(idFinaliteLigne), finalite.getLibelle() }));
                }
            }
        }
        // Recalcul de la finalit du devis et de l'opportunit
        devisUtil.recalculerFinaliteDevisEtOpportunite(devis);
    }
}

From source file:jp.primecloud.auto.process.puppet.PuppetComponentProcess.java

private void doConfigureInstance(Long componentNo, ComponentProcessContext context, boolean start,
        Long instanceNo, Map<String, Object> rootMap) {
    Component component = componentDao.read(componentNo);
    Instance instance = instanceDao.read(instanceNo);

    // ?/*from  w w  w  .ja v a2  s.com*/
    LoggingUtils.setInstanceNo(instanceNo);
    LoggingUtils.setInstanceName(instance.getInstanceName());
    LoggingUtils.setInstanceType(processLogger.getInstanceType(instanceNo));
    LoggingUtils.setPlatformNo(instance.getPlatformNo());

    if (log.isInfoEnabled()) {
        String code = start ? "IPROCESS-100221" : "IPROCESS-100223";
        log.info(MessageUtils.getMessage(code, componentNo, instanceNo, component.getComponentName(),
                instance.getInstanceName()));
    }

    // ?
    restoreManifest(componentNo, instanceNo);

    try {
        configureInstance(componentNo, context, start, instanceNo, rootMap);
    } catch (RuntimeException e) {
        if (start) {
            ComponentInstance componentInstance = componentInstanceDao.read(componentNo, instanceNo);
            ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus());

            // 
            if (BooleanUtils.isTrue(componentInstance.getConfigure())) {
                if (status == ComponentInstanceStatus.STARTING) {
                    processLogger.writeLogSupport(ProcessLogger.LOG_INFO, component, instance,
                            "ComponentStartFail", null);
                } else if (status == ComponentInstanceStatus.CONFIGURING) {
                    processLogger.writeLogSupport(ProcessLogger.LOG_INFO, component, instance,
                            "ComponentReloadFail", null);
                } else if (status == ComponentInstanceStatus.STOPPING) {
                    processLogger.writeLogSupport(ProcessLogger.LOG_INFO, component, instance,
                            "ComponentStopFail", null);
                }
            }

            // 
            if (status != ComponentInstanceStatus.WARNING
                    || BooleanUtils.isTrue(componentInstance.getConfigure())) {
                componentInstance.setStatus(ComponentInstanceStatus.WARNING.toString());
                componentInstance.setConfigure(false);
                componentInstanceDao.update(componentInstance);
            }

            throw e;
        } else {
            // ???????
            log.warn(e.getMessage());
        }
    } finally {
        if (start) {
            // ??
            backupManifest(componentNo, instanceNo);
        } else {
            // ???
            deleteManifest(componentNo, instanceNo);
        }
    }

    ComponentInstance componentInstance = componentInstanceDao.read(componentNo, instanceNo);
    ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus());

    // 
    if (BooleanUtils.isTrue(componentInstance.getConfigure())) {
        if (status == ComponentInstanceStatus.STARTING) {
            processLogger.writeLogSupport(ProcessLogger.LOG_INFO, component, instance, "ComponentStartFinish",
                    null);
        } else if (status == ComponentInstanceStatus.CONFIGURING) {
            processLogger.writeLogSupport(ProcessLogger.LOG_INFO, component, instance, "ComponentReloadFinish",
                    null);
        } else if (status == ComponentInstanceStatus.STOPPING) {
            processLogger.writeLogSupport(ProcessLogger.LOG_INFO, component, instance, "ComponentStopFinish",
                    null);
        }
    }

    // 
    if (start) {
        if (status == ComponentInstanceStatus.CONFIGURING || status == ComponentInstanceStatus.STARTING
                || BooleanUtils.isTrue(componentInstance.getConfigure())) {
            componentInstance.setStatus(ComponentInstanceStatus.RUNNING.toString());
            componentInstance.setConfigure(false);
            componentInstanceDao.update(componentInstance);
        }
    } else {
        if (status == ComponentInstanceStatus.STOPPING
                || BooleanUtils.isTrue(componentInstance.getConfigure())) {
            componentInstance.setStatus(ComponentInstanceStatus.STOPPED.toString());
            componentInstance.setConfigure(false);
            componentInstanceDao.update(componentInstance);
        }
    }

    if (!start) {
        // ?????
        deleteAssociate(componentNo, instanceNo);
    }

    if (log.isInfoEnabled()) {
        String code = start ? "IPROCESS-100222" : "IPROCESS-100224";
        log.info(MessageUtils.getMessage(code, componentNo, instanceNo, component.getComponentName(),
                instance.getInstanceName()));
    }
}

From source file:com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.java

/**
 * Loads filter entities, finds default filter and applies it if found
 *//*from  www .  j a  va2  s.com*/
@Override
public void loadFiltersAndApplyDefault() {
    initShortcutActions();
    initAdHocFilter();
    loadFilterEntities();
    FilterEntity defaultFilter = getDefaultFilter(filterEntities);
    initFilterSelectComponents();

    if (defaultFilter == null) {
        defaultFilter = adHocFilter;
    }

    try {
        setFilterEntity(defaultFilter);
    } catch (Exception e) {
        log.error("Exception on loading default filter '" + defaultFilter.getName() + "'", e);
        windowManager.showNotification(
                messages.formatMainMessage("filter.errorLoadingDefaultFilter", defaultFilter.getName()),
                Frame.NotificationType.ERROR);
        defaultFilter = adHocFilter;
        setFilterEntity(adHocFilter);
    }

    if (defaultFilter != adHocFilter && (filterMode == FilterMode.GENERIC_MODE)) {
        Window window = ComponentsHelper.getWindow(filter);
        if (!WindowParams.DISABLE_AUTO_REFRESH.getBool(window.getContext())) {
            if (getResultingManualApplyRequired()) {
                if (BooleanUtils.isTrue(defaultFilter.getApplyDefault())) {
                    apply(true);
                }
            } else
                apply(true);
            if (filterEntity != null) {
                window.setDescription(getFilterCaption(filterEntity));
            } else
                window.setDescription(null);
        }
    }
}

From source file:com.wineaccess.winepermit.WinePermitHelper.java

private static void populateNoPermitData(WinePermitPO winePermitPO, WineModel wineModel) {
    Boolean optionSelectedNoPermit = BooleanUtils
            .toBooleanObject(winePermitPO.getSellInAltStates().getIsSelectedNoPermit());
    Map<Long, Long> noPermitIdsMap = new ConcurrentHashMap<Long, Long>();
    List<Object[]> noPermitIdsList = WinePermitRepository.findWineNoPermitIdByWineId(wineModel.getId());
    for (Object[] ids : noPermitIdsList) {
        noPermitIdsMap.put((Long) ids[0], (Long) ids[1]);
    }/*from  w  ww .  j  a v  a  2s .  co m*/

    List<OptionSelectedNoPermit> noPermitList = winePermitPO.getSellInAltStates().getOptionSelectedNoPermit();
    if (CollectionUtils.isNotEmpty(noPermitList)) {

        for (OptionSelectedNoPermit noPermitModel : noPermitList) {
            WineLicenseNoPermit wineLicenseNoPermit = new WineLicenseNoPermit();
            Long masterDataId = Long.valueOf(noPermitModel.getMasterDataId());
            wineLicenseNoPermit.setWineNoPermit(MasterDataRepository.getMasterDataById(masterDataId));
            wineLicenseNoPermit.setProductId(wineModel);
            wineLicenseNoPermit.setId(noPermitIdsMap.get(masterDataId));
            if (BooleanUtils.isTrue(optionSelectedNoPermit)) {
                wineModel.setOptionSelectedAltstates(
                        EnumTypes.OptionSelectedAltStatesEnum.NO_PERMIT_FOR_ALT_STATES
                                .getOptionSelectedaltStates());
                wineLicenseNoPermit.setIsSelected(BooleanUtils.toBoolean(noPermitModel.getIsSelected()));
                wineLicenseNoPermit.setPriceFiled(noPermitModel.getNoPermitdate());
                wineLicenseNoPermit.setStatus(noPermitModel.getSc3TStatus());
            } else {
                wineLicenseNoPermit.setIsSelected(false);
                wineLicenseNoPermit.setPriceFiled(null);
                wineLicenseNoPermit.setStatus(null);
            }

            WinePermitRepository.saveWineLicenseNoPermit(wineLicenseNoPermit);

        }
    }
}

From source file:jp.primecloud.auto.process.ProcessManager.java

protected boolean processStopInstance(final Farm farm) {
    // ??//from   w  w w.ja v  a 2 s.  c  om
    List<Instance> instances = new ArrayList<Instance>();
    List<Instance> allInstances = instanceDao.readByFarmNo(farm.getFarmNo());
    for (Instance instance : allInstances) {
        // ??
        if (BooleanUtils.isTrue(instance.getLoadBalancer())) {
            continue;
        }

        if (BooleanUtils.isNotTrue(instance.getEnabled())) {
            instances.add(instance);
        }
    }

    // ????
    if (instances.isEmpty()) {
        return true;
    }

    // ??
    boolean processing = false;
    List<Long> targetInstanceNos = new ArrayList<Long>();
    for (Instance instance : instances) {
        InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus());

        if (status != InstanceStatus.STOPPED) {
            processing = true;

            if (status == InstanceStatus.RUNNING || status == InstanceStatus.WARNING) {
                targetInstanceNos.add(instance.getInstanceNo());
            }
        }
    }

    // ?????
    if (!targetInstanceNos.isEmpty()) {
        final User user = userDao.read(farm.getUserNo());
        for (final Long instanceNo : targetInstanceNos) {
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    LoggingUtils.setUserNo(user.getMasterUser());
                    LoggingUtils.setUserName(user.getUsername());
                    LoggingUtils.setFarmNo(farm.getFarmNo());
                    LoggingUtils.setFarmName(farm.getFarmName());
                    LoggingUtils.setLoginUserNo(user.getUserNo());
                    try {
                        log.debug("instanceProcess.stop(instanceNo):" + String.valueOf(instanceNo));
                        instanceProcess.stop(instanceNo);
                    } catch (MultiCauseException ignore) {
                    } catch (Throwable e) {
                        log.error(e.getMessage(), e);

                        // 
                        eventLogger.error("SystemError", new Object[] { e.getMessage() });
                    } finally {
                        LoggingUtils.removeContext();
                    }
                }
            };
            executorService.execute(runnable);
        }
    }

    // ?????
    if (processing) {
        return false;
    }

    return true;
}

From source file:com.iyonger.apm.web.service.PerfTestService.java

/**
 * Create {@link GrinderProperties} based on the passed {@link PerfTest}.
 *
 * @param perfTest      base data//w  w w. j av  a2 s. co m
 * @param scriptHandler scriptHandler
 * @return created {@link GrinderProperties} instance
 */
public GrinderProperties getGrinderProperties(PerfTest perfTest, ScriptHandler scriptHandler) {
    try {
        // Use default properties first
        GrinderProperties grinderProperties = new GrinderProperties(
                config.getHome().getDefaultGrinderProperties());

        User user = perfTest.getCreatedUser();

        // Get all files in the script path
        String scriptName = perfTest.getScriptName();
        FileEntry userDefinedGrinderProperties = fileEntryService.getOne(user,
                FilenameUtils.concat(FilenameUtils.getPath(scriptName), DEFAULT_GRINDER_PROPERTIES), -1L);
        if (!config.isSecurityEnabled() && userDefinedGrinderProperties != null) {
            // Make the property overridden by user property.
            GrinderProperties userProperties = new GrinderProperties();
            userProperties.load(new StringReader(userDefinedGrinderProperties.getContent()));
            grinderProperties.putAll(userProperties);
        }
        grinderProperties.setAssociatedFile(new File(DEFAULT_GRINDER_PROPERTIES));
        grinderProperties.setProperty(GRINDER_PROP_SCRIPT, scriptHandler.getScriptExecutePath(scriptName));

        grinderProperties.setProperty(GRINDER_PROP_TEST_ID, "test_" + perfTest.getId());
        grinderProperties.setInt(GRINDER_PROP_AGENTS, getSafe(perfTest.getAgentCount()));
        grinderProperties.setInt(GRINDER_PROP_PROCESSES, getSafe(perfTest.getProcesses()));
        grinderProperties.setInt(GRINDER_PROP_THREAD, getSafe(perfTest.getThreads()));
        if (perfTest.isThresholdDuration()) {
            grinderProperties.setLong(GRINDER_PROP_DURATION, getSafe(perfTest.getDuration()));
            grinderProperties.setInt(GRINDER_PROP_RUNS, 0);
        } else {
            grinderProperties.setInt(GRINDER_PROP_RUNS, getSafe(perfTest.getRunCount()));
            if (grinderProperties.containsKey(GRINDER_PROP_DURATION)) {
                grinderProperties.remove(GRINDER_PROP_DURATION);
            }
        }
        grinderProperties.setProperty(GRINDER_PROP_ETC_HOSTS,
                StringUtils.defaultIfBlank(perfTest.getTargetHosts(), ""));
        grinderProperties.setBoolean(GRINDER_PROP_USE_CONSOLE, true);
        if (BooleanUtils.isTrue(perfTest.getUseRampUp())) {
            grinderProperties.setBoolean(GRINDER_PROP_THREAD_RAMPUP, perfTest.getRampUpType() == RampUp.THREAD);
            grinderProperties.setInt(GRINDER_PROP_PROCESS_INCREMENT, getSafe(perfTest.getRampUpStep()));
            grinderProperties.setInt(GRINDER_PROP_PROCESS_INCREMENT_INTERVAL,
                    getSafe(perfTest.getRampUpIncrementInterval()));
            if (perfTest.getRampUpType() == RampUp.PROCESS) {
                grinderProperties.setInt(GRINDER_PROP_INITIAL_SLEEP_TIME,
                        getSafe(perfTest.getRampUpInitSleepTime()));
            } else {
                grinderProperties.setInt(GRINDER_PROP_INITIAL_THREAD_SLEEP_TIME,
                        getSafe(perfTest.getRampUpInitSleepTime()));
            }
            grinderProperties.setInt(GRINDER_PROP_INITIAL_PROCESS, getSafe(perfTest.getRampUpInitCount()));
        } else {
            grinderProperties.setInt(GRINDER_PROP_PROCESS_INCREMENT, 0);
        }

        if (BooleanUtils.isTrue(perfTest.getUseFixedRateRPS())) {
            grinderProperties.setDouble(GRINDER_PROP_FIXED_RPS_RATE, perfTest.getRps());
        }
        grinderProperties.setInt(GRINDER_PROP_REPORT_TO_CONSOLE, 500);
        grinderProperties.setProperty(GRINDER_PROP_USER, perfTest.getCreatedUser().getUserId());
        grinderProperties.setProperty(GRINDER_PROP_JVM_CLASSPATH, getCustomClassPath(perfTest));
        grinderProperties.setInt(GRINDER_PROP_IGNORE_SAMPLE_COUNT, getSafe(perfTest.getIgnoreSampleCount()));
        grinderProperties.setBoolean(GRINDER_PROP_SECURITY, config.isSecurityEnabled());
        // For backward agent compatibility.
        // If the security is not enabled, pass it as jvm argument.
        // If enabled, pass it to grinder.param. In this case, I drop the
        // compatibility.
        if (StringUtils.isNotBlank(perfTest.getParam())) {
            String param = perfTest.getParam().replace("'", "\\'").replace(" ", "");
            if (config.isSecurityEnabled()) {
                grinderProperties.setProperty(GRINDER_PROP_PARAM, StringUtils.trimToEmpty(param));
            } else {
                String property = grinderProperties.getProperty(GRINDER_PROP_JVM_ARGUMENTS, "");
                property = property + " -Dparam=" + param + " ";
                grinderProperties.setProperty(GRINDER_PROP_JVM_ARGUMENTS, property);
            }
        }
        LOGGER.info("Grinder Properties : {} ", grinderProperties);
        return grinderProperties;
    } catch (Exception e) {
        throw processException("error while prepare grinder property for " + perfTest.getTestName(), e);
    }
}

From source file:jp.primecloud.auto.process.zabbix.ZabbixHostProcess.java

private String getZabbixListenIp(ZabbixProcessClient zabbixProcessClient, Instance instance,
        Platform platform) {//from ww  w . j  a v  a  2s.  c  o  m
    String zabbixListenIp = instance.getPublicIp();
    if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) {
        if (BooleanUtils.isTrue(platform.getInternal())) {
            // ?AWS???privateIp????
            // ????????
            // Eucalyptus
            // AWS
            // ?VPC(VPC+VPN???)
            zabbixListenIp = instance.getPrivateIp();
        }
    }
    return zabbixListenIp;
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

protected JDialog showWindowDialog(final Window window, String caption, String description, OpenType openType,
        boolean forciblyDialog) {
    final DialogWindow dialog = new DialogWindow(frame, caption);
    dialog.setName(window.getId());/*w w  w  .  j  a  v a  2s . c om*/
    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    JComponent jComponent = DesktopComponentsHelper.getComposition(window);
    dialog.add(jComponent);

    dialog.addWindowListener(new ValidationAwareWindowClosingListener() {
        @Override
        public void windowClosingAfterValidation(WindowEvent e) {
            if (BooleanUtils.isNotFalse(window.getDialogOptions().getCloseable())) {
                if (!isCloseWithCloseButtonPrevented(window)) {
                    if (window.close("close")) {
                        dialog.dispose();
                    }
                }
            }
        }
    });

    Dimension dim = new Dimension();
    if (forciblyDialog) {
        // todo move it to desktop application preferences
        dim.width = 800;
        dim.height = 500;

        dialog.setResizable(BooleanUtils.isNotFalse(openType.getResizable()));
        if (!dialog.isResizable()) {
            dialog.setFixedHeight(dim.height);
            dialog.setFixedWidth(dim.width);
        }

        window.setHeight("100%");
    } else {
        dialog.setResizable(BooleanUtils.isTrue(openType.getResizable()));
        if (openType.getWidth() == null) {
            dim.width = 600;
            if (!dialog.isResizable()) {
                dialog.setFixedWidth(dim.width);
            }
        } else if (openType.getWidth() == DialogParams.AUTO_SIZE_PX) {
            window.setWidth(AUTO_SIZE);
        } else {
            if (openType.getWidthUnit() != null && openType.getWidthUnit() != SizeUnit.PIXELS) {
                throw new UnsupportedOperationException("Dialog size can be set only in pixels");
            }
            dim.width = openType.getWidth().intValue();
            if (!dialog.isResizable()) {
                dialog.setFixedWidth(dim.width);
            }
        }

        if (openType.getHeight() != null && openType.getHeight() != DialogParams.AUTO_SIZE_PX) {
            if (openType.getHeightUnit() != null && openType.getHeightUnit() != SizeUnit.PIXELS) {
                throw new UnsupportedOperationException("Dialog size can be set only in pixels");
            }
            dim.height = openType.getHeight().intValue();
            if (!dialog.isResizable()) {
                dialog.setFixedHeight(dim.height);
            }
            window.setHeight("100%");
        } else {
            window.setHeight(AUTO_SIZE);
        }
    }

    getDialogParams().reset();

    dialog.setMinimumSize(dim);
    dialog.pack();

    if (openType.getPositionY() == null && openType.getPositionX() == null) {
        dialog.setLocationRelativeTo(frame);
    } else {
        dialog.setLocation(openType.getPositionX() != null ? openType.getPositionX() : 0,
                openType.getPositionY() != null ? openType.getPositionY() : 0);
    }

    boolean modal = true;
    if (!hasModalWindow() && openType.getModal() != null) {
        modal = openType.getModal();
    }

    if (modal) {
        DialogWindow lastDialogWindow = getLastDialogWindow();
        if (lastDialogWindow == null)
            frame.deactivate(null);
        else
            lastDialogWindow.disableWindow(null);

        dialog.setSoftModal(true);
    }

    dialog.setVisible(true);

    JPopupMenu popupMenu = createWindowPopupMenu(window);
    if (popupMenu.getComponentCount() > 0) {
        jComponent.setComponentPopupMenu(popupMenu);
    }

    return dialog;
}