Example usage for java.lang Long equals

List of usage examples for java.lang Long equals

Introduction

In this page you can find the example usage for java.lang Long equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:net.spfbl.http.ServerHTTP.java

private static String getControlPanel(Locale locale, User user, Long begin, String filter) {
    StringBuilder builder = new StringBuilder();
    if (begin == null && filter == null) {
        //            builder.append("<!DOCTYPE html>\n");
        builder.append("<html lang=\"");
        builder.append(locale.getLanguage());
        builder.append("\">\n");
        builder.append("  <head>\n");
        builder.append("    <meta charset=\"UTF-8\">\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("    <title>Painel de controle do SPFBL</title>\n");
        } else {//from w  ww .  j  a v  a2 s  . c o  m
            builder.append("    <title>SPFBL control panel</title>\n");
        }
        // Styled page.
        builder.append("    <style type=\"text/css\">\n");
        builder.append("      body {\n");
        builder.append("        margin:180px 0px 30px 0px;\n");
        builder.append("        background:lightgray;\n");
        builder.append("      }\n");
        builder.append("      iframe {\n");
        builder.append("        border-width: 0px 0px 0px 0px;\n");
        builder.append("        width:100%;\n");
        builder.append("        height:150px;\n");
        builder.append("      }\n");
        builder.append("      .header {\n");
        builder.append("        background-color:lightgray;\n");
        builder.append("        border-width: 0px 0px 0px 0px;\n");
        builder.append("        position:fixed;\n");
        builder.append("        top:0px;\n");
        builder.append("        margin:auto;\n");
        builder.append("        z-index:1;\n");
        builder.append("        width:100%;\n");
        builder.append("        height:180px;\n");
        builder.append("      }\n");
        builder.append("      .bottom {\n");
        builder.append("        background-color:lightgray;\n");
        builder.append("        border-width: 0px 0px 0px 0px;\n");
        builder.append("        position:fixed;\n");
        builder.append("        bottom:0px;\n");
        builder.append("        margin:auto;\n");
        builder.append("        z-index:1;\n");
        builder.append("        width:100%;\n");
        builder.append("        height:30px;\n");
        builder.append("      }\n");
        builder.append("      .button {\n");
        builder.append("          background-color: #4CAF50;\n");
        builder.append("          border: none;\n");
        builder.append("          color: white;\n");
        builder.append("          padding: 16px 32px;\n");
        builder.append("          text-align: center;\n");
        builder.append("          text-decoration: none;\n");
        builder.append("          display: inline-block;\n");
        builder.append("          font-size: 16px;\n");
        builder.append("          margin: 4px 2px;\n");
        builder.append("          -webkit-transition-duration: 0.4s;\n");
        builder.append("          transition-duration: 0.4s;\n");
        builder.append("          cursor: pointer;\n");
        builder.append("      }\n");
        builder.append("      .sender {\n");
        builder.append("          background-color: white; \n");
        builder.append("          color: black; \n");
        builder.append("          border: 2px solid #008CBA;\n");
        builder.append("          width: 100%;\n");
        builder.append("          word-wrap: break-word;\n");
        builder.append("      }\n");
        builder.append("      .sender:hover {\n");
        builder.append("          background-color: #008CBA;\n");
        builder.append("          color: white;\n");
        builder.append("      }\n");
        builder.append("      .highlight {\n");
        builder.append("        background: #b4b9d2;\n");
        builder.append("        color:black;\n");
        builder.append("        border-top: 1px solid #22262e;\n");
        builder.append("        border-bottom: 1px solid #22262e;\n");
        builder.append("      }\n");
        builder.append("      .highlight:nth-child(odd) td {\n");
        builder.append("        background: #b4b9d2;\n");
        builder.append("      }\n");
        builder.append("      .click {\n");
        builder.append("        cursor:pointer;\n");
        builder.append("        cursor:hand;\n");
        builder.append("      }\n");
        builder.append("      table {\n");
        builder.append("        background: white;\n");
        builder.append("        table-layout:fixed;\n");
        builder.append("        border-collapse: collapse;\n");
        builder.append("        word-wrap:break-word;\n");
        builder.append("        border-radius:3px;\n");
        builder.append("        border-collapse: collapse;\n");
        builder.append("        margin: auto;\n");
        builder.append("        padding:2px;\n");
        builder.append("        width: 100%;\n");
        builder.append("        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);\n");
        builder.append("        animation: float 5s infinite;\n");
        builder.append("      }\n");
        builder.append("      th {\n");
        builder.append("        color:#FFFFFF;;\n");
        builder.append("        background:#1b1e24;\n");
        builder.append("        border-bottom:4px solid #9ea7af;\n");
        builder.append("        border-right: 0px;\n");
        builder.append("        font-size:16px;\n");
        builder.append("        font-weight: bold;\n");
        builder.append("        padding:4px;\n");
        builder.append("        text-align:left;\n");
        builder.append("        text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);\n");
        builder.append("        vertical-align:middle;\n");
        builder.append("        height:30px;\n");
        builder.append("      }\n");
        builder.append("      tr {\n");
        builder.append("        border-top: 1px solid #C1C3D1;\n");
        builder.append("        border-bottom-: 1px solid #C1C3D1;\n");
        builder.append("        font-size:16px;\n");
        builder.append("        font-weight:normal;\n");
        builder.append("        text-shadow: 0 1px 1px rgba(256, 256, 256, 0.1);\n");
        builder.append("      }\n");
        builder.append("      tr:nth-child(odd) td {\n");
        builder.append("        background:#EBEBEB;\n");
        builder.append("      }\n");
        builder.append("      td {\n");
        builder.append("        padding:2px;\n");
        builder.append("        vertical-align:middle;\n");
        builder.append("        font-size:16px;\n");
        builder.append("        text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1);\n");
        builder.append("        border-right: 1px solid #C1C3D1;\n");
        builder.append("      }\n");
        builder.append("      input[type=text], select {\n");
        builder.append("        width: 400px;\n");
        builder.append("        padding: 0px 4px;\n");
        builder.append("        margin: 1px 0;\n");
        builder.append("        display: inline-block;\n");
        builder.append("        background: #b4b9d2;\n");
        builder.append("        border: 1px solid #ccc;\n");
        builder.append("        border-radius: 4px;\n");
        builder.append("        box-sizing: border-box;\n");
        builder.append("      }\n");
        builder.append("    </style>\n");
        // JavaScript functions.
        TreeMap<Long, Query> queryMap = user.getQueryMap(null, null);
        builder.append(
                "    <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js\"></script>\n");
        builder.append("    <script type=\"text/javascript\">\n");
        builder.append("      window.onbeforeunload = function () {\n");
        builder.append("        document.getElementById('filterField').value = '';\n");
        builder.append("        window.scrollTo(0, 0);\n");
        builder.append("      }\n");
        builder.append("      var last = ");
        if (queryMap.isEmpty()) {
            builder.append(0);
        } else {
            builder.append(queryMap.lastKey());
        }
        builder.append(";\n");
        builder.append("      var filterText = '';\n");
        builder.append("      function view(query) {\n");
        builder.append("        if (query == undefined || query == 0) {\n");
        builder.append("          var viewer = document.getElementById('viewer');\n");
        builder.append("          viewer.src = 'about:blank';\n");
        builder.append("          last = 0;\n");
        builder.append("        } else if (last != query) {\n");
        builder.append("          var viewer = document.getElementById('viewer');\n");
        builder.append("          viewer.addEventListener('load', function() {\n");
        builder.append("            if (document.getElementById(last)) {\n");
        builder.append("              document.getElementById(last).className = 'tr';\n");
        builder.append("              document.getElementById(last).className = 'click';\n");
        builder.append("            }\n");
        builder.append("            document.getElementById(query).className = 'highlight';\n");
        builder.append("            last = query;\n");
        builder.append("          });\n");
        builder.append("          viewer.src = '");
        builder.append(Core.getURL());
        builder.append("' + query;\n");
        builder.append("        }\n");
        builder.append("      }\n");
        builder.append("      function more(query) {\n");
        builder.append("        var rowMore = document.getElementById('rowMore');\n");
        builder.append("        rowMore.onclick = '';\n");
        builder.append("        rowMore.className = 'tr';\n");
        builder.append("        var columnMore = document.getElementById('columnMore');\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("        columnMore.innerHTML = 'carregando mais registros';\n");
        } else {
            builder.append("        columnMore.innerHTML = 'loading more records';\n");
        }
        builder.append("        $.post(\n");
        builder.append("          '");
        builder.append(Core.getURL());
        builder.append(user.getEmail());
        builder.append("',\n");
        builder.append("          {filter:filterText,begin:query},\n");
        builder.append("          function(data, status) {\n");
        builder.append("            if (status == 'success') {\n");
        builder.append("              rowMore.parentNode.removeChild(rowMore);\n");
        builder.append("              $('#tableBody').append(data);\n");
        builder.append("            } else {\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append(
                    "              alert('Houve uma falha de sistema ao tentar realizar esta operao.');\n");
        } else {
            builder.append(
                    "              alert('There was a system crash while trying to perform this operation.');\n");
        }
        builder.append("            }\n");
        builder.append("          }\n");
        builder.append("        );\n");
        builder.append("      }\n");
        builder.append("      function refresh() {\n");
        builder.append("        filterText = document.getElementById('filterField').value;\n");
        builder.append("        $.post(\n");
        builder.append("          '");
        builder.append(Core.getURL());
        builder.append(user.getEmail());
        builder.append("',\n");
        builder.append("          {filter:filterText},\n");
        builder.append("          function(data, status) {\n");
        builder.append("            if (status == 'success') {\n");
        builder.append("              $('#tableBody').html(data);\n");
        builder.append("              view($('#tableBody tr').attr('id'));\n");
        builder.append("            } else {\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append(
                    "              alert('Houve uma falha de sistema ao tentar realizar esta operao.');\n");
        } else {
            builder.append(
                    "              alert('There was a system crash while trying to perform this operation.');\n");
        }
        builder.append("            }\n");
        builder.append("          }\n");
        builder.append("        );\n");
        builder.append("      }\n");
        builder.append("    </script>\n");
        builder.append("  </head>\n");
        // Body.
        builder.append("  <body>\n");
        builder.append("    <div class=\"header\">\n");
        if (queryMap.isEmpty()) {
            builder.append("      <iframe id=\"viewer\" src=\"about:blank\"></iframe>\n");
        } else {
            builder.append("      <iframe id=\"viewer\" src=\"");
            builder.append(Core.getURL());
            builder.append(queryMap.lastKey());
            builder.append("\"></iframe>\n");
        }
        // Construo da tabela de consultas.
        builder.append("      <table>\n");
        builder.append("        <thead>\n");
        builder.append("          <tr>\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("            <th style=\"width:120px;\">Recepo</th>\n");
            builder.append("            <th>Origem</th>\n");
            builder.append("            <th>Remetente</th>\n");
            builder.append("            <th>Contedo</th>\n");
            builder.append("            <th>Entrega</th>\n");
        } else {
            builder.append("            <th style=\"width:160px;\">Reception</th>\n");
            builder.append("            <th style=\"width:auto;\">Source</th>\n");
            builder.append("            <th style=\"width:auto;\">Sender</th>\n");
            builder.append("            <th style=\"width:auto;\">Content</th>\n");
            builder.append("            <th style=\"width:auto;\">Delivery</th>\n");
        }
        builder.append("          </tr>\n");
        builder.append("        </thead>\n");
        builder.append("      </table>\n");
        builder.append("    </div>\n");
        if (queryMap.isEmpty()) {
            builder.append("    <table>\n");
            builder.append("      <tbody>\n");
            builder.append("        <tr>\n");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append(
                        "          <td colspan=\"5\" align=\"center\">nenhum registro encontrado</td>\n");
            } else {
                builder.append("          <td colspan=\"5\" align=\"center\">no records found</td>\n");
            }
            builder.append("        </tr>\n");
            builder.append("      </tbody>\n");
            builder.append("    </table>\n");
        } else {
            DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
            GregorianCalendar calendar = new GregorianCalendar();
            Long nextQuery = null;
            while (queryMap.size() > User.QUERY_MAX_ROWS) {
                nextQuery = queryMap.pollFirstEntry().getKey();
            }
            builder.append("    <table>\n");
            builder.append("      <tbody id=\"tableBody\">\n");
            for (Long time : queryMap.descendingKeySet()) {
                User.Query query = queryMap.get(time);
                boolean highlight = time.equals(queryMap.lastKey());
                buildQueryRow(locale, builder, dateFormat, calendar, time, query, highlight);
            }
            if (nextQuery == null) {
                builder.append("      <tr>\n");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append(
                            "        <td colspan=\"5\" align=\"center\">no foram encontrados outros registros</td>\n");
                } else {
                    builder.append("        <td colspan=\"5\" align=\"center\">no more records found</td>\n");
                }
                builder.append("      </tr>\n");
            } else {
                builder.append("        <tr id=\"rowMore\" class=\"click\" onclick=\"more('");
                builder.append(nextQuery);
                builder.append("')\">\n");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append(
                            "          <td id=\"columnMore\" colspan=\"5\" align=\"center\">clique para ver mais registros</td>\n");
                } else {
                    builder.append(
                            "          <td id=\"columnMore\" colspan=\"5\" align=\"center\">click to see more records</td>\n");
                }
                builder.append("        </tr>\n");
            }
            builder.append("      </tbody>\n");
            builder.append("    </table>\n");
        }
        builder.append("    <div class=\"bottom\">\n");
        builder.append("      <table>\n");
        builder.append("        <tr>\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append(
                    "          <th>Pesquisar <input type=\"text\" id=\"filterField\" name=\"filterField\" onkeydown=\"if (event.keyCode == 13) refresh();\" autofocus></th>\n");
        } else {
            builder.append(
                    "          <th>Search <input type=\"text\" id=\"filterField\" name=\"filterField\" onkeydown=\"if (event.keyCode == 13) refresh();\" autofocus></th>\n");
        }
        builder.append("          <th style=\"text-align:right;\"><small>");
        builder.append(
                "Powered by <a target=\"_blank\" href=\"http://spfbl.net/\" style=\"color: #b4b9d2;\">SPFBL.net</a></small>");
        builder.append("</th>\n");
        builder.append("        </tr>\n");
        builder.append("      <table>\n");
        builder.append("    </div>\n");
        builder.append("  </body>\n");
        builder.append("</html>\n");
    } else {
        TreeMap<Long, Query> queryMap = user.getQueryMap(begin, filter);
        if (queryMap.isEmpty()) {
            builder.append("        <tr>\n");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append(
                        "          <td colspan=\"5\" align=\"center\">nenhum registro encontrado</td>\n");
            } else {
                builder.append("          <td colspan=\"5\" align=\"center\">no records found</td>\n");
            }
            builder.append("        </tr>\n");
        } else {
            DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
            GregorianCalendar calendar = new GregorianCalendar();
            Long nextQuery = null;
            while (queryMap.size() > User.QUERY_MAX_ROWS) {
                nextQuery = queryMap.pollFirstEntry().getKey();
            }
            for (Long time : queryMap.descendingKeySet()) {
                User.Query query = queryMap.get(time);
                buildQueryRow(locale, builder, dateFormat, calendar, time, query, false);
            }
            if (nextQuery == null) {
                builder.append("        <tr>\n");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append(
                            "          <td colspan=\"5\" align=\"center\">no foram encontrados outros registros</td>\n");
                } else {
                    builder.append("          <td colspan=\"5\" align=\"center\">no more records found</td>\n");
                }
                builder.append("        </tr>\n");
            } else {
                builder.append("        <tr id=\"rowMore\" class=\"click\" onclick=\"more('");
                builder.append(nextQuery);
                builder.append("')\">\n");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append(
                            "          <td id=\"columnMore\" colspan=\"5\" align=\"center\">clique para ver mais registros</td>\n");
                } else {
                    builder.append(
                            "          <td id=\"columnMore\" colspan=\"5\" align=\"center\">click to see more records</td>\n");
                }
                builder.append("        </tr>\n");
            }
        }
    }
    return builder.toString();
}

From source file:edu.harvard.iq.dvn.core.web.admin.OptionsPage.java

public boolean isNetworkDefaultForAll(Long templateId) {
    for (Long defaultTemplateId : defaultNetworkTemplateMap.values()) {
        if (!defaultTemplateId.equals(templateId)) {
            return false;
        }//from  w  w w  .  j  a  va 2  s  . c om
    }
    return true;
}

From source file:com.cloud.vm.VirtualMachineManagerImpl.java

private void orchestrateStorageMigration(final String vmUuid, final StoragePool destPool) {
    final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

    if (destPool == null) {
        throw new CloudRuntimeException("Unable to migrate vm: missing destination storage pool");
    }/*from  w  w  w .j a  v  a 2 s  .c o m*/

    try {
        stateTransitTo(vm, VirtualMachine.Event.StorageMigrationRequested, null);
    } catch (final NoTransitionException e) {
        s_logger.debug("Unable to migrate vm: " + e.toString());
        throw new CloudRuntimeException("Unable to migrate vm: " + e.toString());
    }

    final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
    boolean migrationResult = false;
    try {
        migrationResult = volumeMgr.storageMigration(profile, destPool);

        if (migrationResult) {
            //if the vm is migrated to different pod in basic mode, need to reallocate ip

            if (destPool.getPodId() != null && !destPool.getPodId().equals(vm.getPodIdToDeployIn())) {
                final DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(),
                        destPool.getPodId(), null, null, null, null);
                final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, null, null, null,
                        null);
                _networkMgr.reallocate(vmProfile, plan);
            }

            //when start the vm next time, don;'t look at last_host_id, only choose the host based on volume/storage pool
            vm.setLastHostId(null);
            vm.setPodIdToDeployIn(destPool.getPodId());

            // If VM was cold migrated between clusters belonging to two different VMware DCs,
            // unregister the VM from the source host and cleanup the associated VM files.
            if (vm.getHypervisorType().equals(HypervisorType.VMware)) {
                Long srcClusterId = null;
                Long srcHostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
                if (srcHostId != null) {
                    HostVO srcHost = _hostDao.findById(srcHostId);
                    srcClusterId = srcHost.getClusterId();
                }

                final Long destClusterId = destPool.getClusterId();
                if (srcClusterId != null && destClusterId != null && !srcClusterId.equals(destClusterId)) {
                    final String srcDcName = _clusterDetailsDao.getVmwareDcName(srcClusterId);
                    final String destDcName = _clusterDetailsDao.getVmwareDcName(destClusterId);
                    if (srcDcName != null && destDcName != null && !srcDcName.equals(destDcName)) {
                        s_logger.debug(
                                "Since VM's storage was successfully migrated across VMware Datacenters, unregistering VM: "
                                        + vm.getInstanceName() + " from source host: " + srcHostId);
                        final UnregisterVMCommand uvc = new UnregisterVMCommand(vm.getInstanceName());
                        uvc.setCleanupVmFiles(true);
                        try {
                            _agentMgr.send(srcHostId, uvc);
                        } catch (final AgentUnavailableException | OperationTimedoutException e) {
                            throw new CloudRuntimeException("Failed to unregister VM: " + vm.getInstanceName()
                                    + " from source host: " + srcHostId
                                    + " after successfully migrating VM's storage across VMware Datacenters");
                        }
                    }
                }
            }

        } else {
            s_logger.debug("Storage migration failed");
        }
    } catch (final ConcurrentOperationException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } catch (final InsufficientVirtualNetworkCapacityException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } catch (final InsufficientAddressCapacityException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } catch (final InsufficientCapacityException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } catch (final StorageUnavailableException e) {
        s_logger.debug("Failed to migration: " + e.toString());
        throw new CloudRuntimeException("Failed to migration: " + e.toString());
    } finally {
        try {
            stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null);
        } catch (final NoTransitionException e) {
            s_logger.debug("Failed to change vm state: " + e.toString());
            throw new CloudRuntimeException("Failed to change vm state: " + e.toString());
        }
    }
}

From source file:es.pode.administracion.presentacion.repositoriosExternos.modificarRepositoriosExternos.ModificarNodoSQIControllerImpl.java

public void modificarNodoSQI(ActionMapping mapping, ModificarNodoSQIForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    try {/*from   w ww  .j  a  va2 s . c  o m*/

        Long identificador = form.getId();
        String nombreNodo = form.getNombreNodo();
        String descripcionNodo = form.getDescripcionNodo();
        String url = form.getUrlServicio();
        String lenguajeConsulta = form.getLenguajeConsulta().toUpperCase();
        String lenguajeRespuesta = form.getLenguajeRespuesta().toUpperCase();
        String identificadorSesion = form.getIdentificadorSesion();
        String usuario = form.getUsuario();
        String clave = form.getClave();
        String gestorSesion = form.getGestorSesion();
        if (logger.isDebugEnabled())
            logger.debug("Hemos recogidos los datos del formulario, nombreNodo:[" + nombreNodo
                    + "], descripcionNodo:[" + descripcionNodo + "],url:[" + url + "], " + "lenguajeConsulta:["
                    + lenguajeConsulta + "],lenguajeRespuesta:[" + lenguajeRespuesta + "],identificadorSesion:["
                    + identificadorSesion + "], " + "usuario:[" + usuario + "], clave:[" + clave
                    + "] y gestorSesion:[" + gestorSesion + "]");

        //Validacion
        if (nombreNodo == null || nombreNodo.equals("")) {
            logger.error("El nombre del nodo SQI es obligatorio [" + nombreNodo + "]");
            throw new ValidatorException("{errors.altanodoSQI.nombre}");
        }
        if (url == null || url.equals("")) {
            logger.error("La URL del servicio es obligatorio [" + url + "]");
            throw new ValidatorException("{errors.altanodoSQI.url}");
        }
        if (descripcionNodo == null || descripcionNodo.equals("")) {
            logger.error("La descripcion del nodo SQI es obligatorio [" + descripcionNodo + "]");
            throw new ValidatorException("{errors.altanodoSQI.descripcion}");//Internacionalizar ( tambien en GestionSQI )
        }
        if (lenguajeConsulta != null && !lenguajeConsulta.equals("")) {
            if (!lenguajeConsulta.equalsIgnoreCase(LENGUAJE_CONSULTA_VSQL)) {
                logger.error("El lenguaje de consulta debe ser de tipo " + LENGUAJE_CONSULTA_VSQL + ",["
                        + lenguajeConsulta + "]");
                throw new ValidatorException("{errors.altanodoSQI.lenguajeConsulta} " + LENGUAJE_CONSULTA_VSQL);
            }
        } else {
            logger.error("El lenguaje de consulta es obligatorio [" + lenguajeConsulta + "]");
            throw new ValidatorException("{errors.altanodoSQI.lenguajeConsultaObliga}");
        }
        if (lenguajeRespuesta != null && !lenguajeRespuesta.equals("")) {
            if (!lenguajeRespuesta.equalsIgnoreCase(LENGUAJE_RESPUESTA_LOM)
                    && !lenguajeRespuesta.equalsIgnoreCase(LENGUAJE_RESPUESTA_LOMES)) {
                logger.error("El lenguaje de respuesta debe ser de tipo " + LENGUAJE_RESPUESTA_LOM + "o tipo "
                        + LENGUAJE_RESPUESTA_LOMES + "[" + lenguajeRespuesta + "]");
                throw new ValidatorException("{errors.altanodoSQI.lenguajeRespuesta} ");
            }
        } else {
            logger.error("El lenguaje de respuesta es obligatorio [" + lenguajeRespuesta + "]");
            throw new ValidatorException("{errors.altanodoSQI.lenguajeRespuestaObliga}");
        }
        if (identificadorSesion == null || identificadorSesion.equals("")) {
            if (gestorSesion == null || gestorSesion.equals("")) {
                logger.error(
                        "La URL del gestor de sesiones o el identificador de la sesion es obligatorio, identificadorSesion ["
                                + identificadorSesion + "] el gestor de sesiones [" + gestorSesion + "]");
                throw new ValidatorException("{errors.altanodoSQI.identiGestor}");
            }
        }

        if (usuario != null && !usuario.equals("")) {
            if (clave == null || clave.equals("")) {
                logger.error("Si existe usuario," + usuario + ", es obligatoria la clave [" + clave + "]");
                throw new ValidatorException("{errors.altanodoSQI.usuarioClave}");
            }
        }
        if (clave != null && !clave.equals("")) {
            if (usuario == null || usuario.equals("")) {
                logger.error("Si existe clave," + clave + ", es obligatorio el usuario [" + usuario + "]");
                throw new ValidatorException("{errors.altanodoSQI.claveUsuario}");
            }
        }

        //          cargamos el NodoSQIVO con los datos originales que tiene antes de modificarlo
        NodoSQIVO[] nodoCargado = new NodoSQIVO[1];
        NodoSQIVO nodo = new NodoSQIVO();
        nodo.setClave(clave);
        nodo.setDescripcionNodo(descripcionNodo);
        nodo.setGestorSesion(gestorSesion);
        nodo.setId(identificador);
        nodo.setIdentificadorSesion(identificadorSesion);
        nodo.setLenguajeConsulta(lenguajeConsulta);
        nodo.setLenguajeRespuesta(lenguajeRespuesta);
        nodo.setNombreNodo(nombreNodo);
        nodo.setUrlServicio(url);
        nodo.setUsuario(usuario);
        nodoCargado[0] = nodo;
        Long respuesta = this.getSrvGestionSqiService().modificarNodoSQI(nodoCargado[0]);
        form.setIdModificado(respuesta);
        if (logger.isDebugEnabled())
            logger.debug("Lo que ha devuelto es[" + respuesta + "]");
        if (identificador.equals(respuesta)) {
            form.setResultado("OK");
        } else {
            form.setResultado("FALLO");
        }
    } catch (ValidatorException e) {
        throw e;
    } catch (Exception e) {
        logger.error("Se ha producido un error al modificar el nodo: " + e);
        throw new ValidatorException("{errors.modificarnodoSQI}");

    }

}

From source file:edu.harvard.iq.dvn.core.web.admin.OptionsPage.java

public String createStudyDrafts_action() {
    try {//w w  w  .  ja  va2 s.c  o  m
        Map tokenizedLists = determineStudyIds(createStudyDraftIds);
        List ignoredList = new ArrayList();

        for (Iterator it = ((List) tokenizedLists.get("idList")).iterator(); it.hasNext();) {
            Long studyId = (Long) it.next();
            Study study = studyService.getStudy(studyId);
            Long currentVersionNumber = study.getLatestVersion().getVersionNumber();
            StudyVersion editVersion = study.getEditVersion();
            if (currentVersionNumber.equals(editVersion.getVersionNumber())) {
                // working copy already exists
                it.remove();
                ignoredList.add(studyId);
            } else {
                // save new version
                studyService.saveStudyVersion(editVersion,
                        getVDCSessionBean().getLoginBean().getUser().getId());
                studyService.updateStudyVersion(editVersion);
            }
        }

        tokenizedLists.put("ignoredList", ignoredList);
        tokenizedLists.put("ignoredReason", "working verison already exists");

        addMessage("studyMessage", "Create Study Draft request completed.");
        addStudyMessages("studyMessage", tokenizedLists);

    } catch (Exception e) {
        e.printStackTrace();
        addMessage("studyMessage",
                "Create Drafts failed: An unknown error occurred trying to delete the following: \""
                        + deleteStudyIds + "\"");
    }

    return null;
}

From source file:jp.primecloud.auto.service.impl.InstanceServiceImpl.java

/**
 * {@inheritDoc}/*  w w  w. j a v a  2s.co  m*/
 */
@Override
public void updateVmwareInstance(Long instanceNo, String instanceName, String comment, String instanceType,
        String computeResource, String resourcePool, Long keyPairNo, VmwareAddressDto vmwareAddressDto) {
    // ?
    updateInstance(instanceNo, instanceName, comment);

    // ?
    if (instanceNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "instanceNo");
    }
    if (instanceType == null || instanceType.length() == 0) {
        throw new AutoApplicationException("ECOMMON-000003", "instanceType");
    }
    if (computeResource == null || computeResource.length() == 0) {
        throw new AutoApplicationException("ECOMMON-000003", "computeResource");
    }
    if (keyPairNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "keyPairNo");
    }

    // ??
    Instance instance = instanceDao.read(instanceNo);
    if (instance == null) {
        throw new AutoApplicationException("ESERVICE-000403", instanceNo);
    }

    // ??
    Platform platform = platformDao.read(instance.getPlatformNo());
    if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType()) == false) {
        throw new AutoApplicationException("ESERVICE-000408", instance.getInstanceName());
    }

    // ??????
    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);
    VmwareAddress vmwareAddress = vmwareAddressDao.readByInstanceNo(instanceNo);
    if (InstanceStatus.fromStatus(instance.getStatus()) != InstanceStatus.STOPPED) {
        // ??????????????????
        if (!StringUtils.equals(vmwareInstance.getInstanceType(), instanceType)) {
            throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName());
        }
        if (!StringUtils.equals(vmwareInstance.getComputeResource(), computeResource)) {
            throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName());
        }
        if (StringUtils.isEmpty(vmwareInstance.getResourcePool()) ? StringUtils.isNotEmpty(resourcePool)
                : !StringUtils.equals(vmwareInstance.getResourcePool(), resourcePool)) {
            throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName());
        }
        if (!keyPairNo.equals(vmwareInstance.getKeyPairNo())) {
            throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName());
        }
        if (vmwareAddress == null || BooleanUtils.isNotTrue(vmwareAddress.getEnabled())) {
            if (vmwareAddressDto != null) {
                throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName());
            }
        } else {
            if (vmwareAddressDto == null) {
                throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName());
            } else if (!StringUtils.equals(vmwareAddress.getIpAddress(), vmwareAddressDto.getIpAddress())
                    || !StringUtils.equals(vmwareAddress.getSubnetMask(), vmwareAddressDto.getSubnetMask())
                    || !StringUtils.equals(vmwareAddress.getDefaultGateway(),
                            vmwareAddressDto.getDefaultGateway())) {
                throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName());
            }
        }
    }

    // VMware?
    vmwareInstance.setInstanceType(instanceType);
    vmwareInstance.setComputeResource(computeResource);
    vmwareInstance.setResourcePool(resourcePool);
    vmwareInstance.setKeyPairNo(keyPairNo);
    vmwareInstanceDao.update(vmwareInstance);

    Farm farm = farmDao.read(instance.getFarmNo());

    // VmwareAddress?
    if (vmwareAddress == null) {
        if (vmwareAddressDto != null) {
            vmwareAddress = new VmwareAddress();
            vmwareAddress.setPlatformNo(instance.getPlatformNo());
            vmwareAddress.setIpAddress(vmwareAddressDto.getIpAddress());
            vmwareAddress.setSubnetMask(vmwareAddressDto.getSubnetMask());
            vmwareAddress.setDefaultGateway(vmwareAddressDto.getDefaultGateway());
            vmwareAddress.setUserNo(farm.getUserNo());
            vmwareAddress.setInstanceNo(instanceNo);
            vmwareAddress.setEnabled(true);
            vmwareAddress.setAssociated(false);
            vmwareAddressDao.create(vmwareAddress);
        }
    } else {
        if (vmwareAddressDto == null) {
            vmwareAddress.setEnabled(false);
        } else {
            boolean change = false;
            if (!StringUtils.equals(vmwareAddress.getIpAddress(), vmwareAddressDto.getIpAddress())
                    || !StringUtils.equals(vmwareAddress.getSubnetMask(), vmwareAddressDto.getSubnetMask())
                    || !StringUtils.equals(vmwareAddress.getDefaultGateway(),
                            vmwareAddressDto.getDefaultGateway())) {
                change = true;
            }

            vmwareAddress.setIpAddress(vmwareAddressDto.getIpAddress());
            vmwareAddress.setSubnetMask(vmwareAddressDto.getSubnetMask());
            vmwareAddress.setDefaultGateway(vmwareAddressDto.getDefaultGateway());
            vmwareAddress.setEnabled(true);
            if (change) {
                vmwareAddress.setAssociated(false);
            }
        }
        vmwareAddressDao.update(vmwareAddress);
    }

    // 
    eventLogger.log(EventLogLevel.INFO, farm.getFarmNo(), farm.getFarmName(), null, null, instanceNo,
            instanceName, "InstanceUpdate", instanceType, instance.getPlatformNo(), null);
}

From source file:com.cloud.storage.VolumeApiServiceImpl.java

@DB
@Override//  w  w  w  .  ja va 2  s  .  c  o  m
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_MIGRATE, eventDescription = "migrating volume", async = true)
public Volume migrateVolume(MigrateVolumeCmd cmd) {
    Long volumeId = cmd.getVolumeId();
    Long storagePoolId = cmd.getStoragePoolId();

    VolumeVO vol = _volsDao.findById(volumeId);
    if (vol == null) {
        throw new InvalidParameterValueException("Failed to find the volume id: " + volumeId);
    }

    if (vol.getState() != Volume.State.Ready) {
        throw new InvalidParameterValueException("Volume must be in ready state");
    }

    boolean liveMigrateVolume = false;
    Long instanceId = vol.getInstanceId();
    Long srcClusterId = null;
    VMInstanceVO vm = null;
    if (instanceId != null) {
        vm = _vmInstanceDao.findById(instanceId);
    }

    // Check that Vm to which this volume is attached does not have VM Snapshots
    if (vm != null && _vmSnapshotDao.findByVm(vm.getId()).size() > 0) {
        throw new InvalidParameterValueException(
                "Volume cannot be migrated, please remove all VM snapshots for VM to which this volume is attached");
    }

    if (vm != null && vm.getState() == State.Running) {
        // Check if the VM is GPU enabled.
        if (_serviceOfferingDetailsDao.findDetail(vm.getServiceOfferingId(),
                GPU.Keys.pciDevice.toString()) != null) {
            throw new InvalidParameterValueException("Live Migration of GPU enabled VM is not supported");
        }
        // Check if the underlying hypervisor supports storage motion.
        Long hostId = vm.getHostId();
        if (hostId != null) {
            HostVO host = _hostDao.findById(hostId);
            HypervisorCapabilitiesVO capabilities = null;
            if (host != null) {
                capabilities = _hypervisorCapabilitiesDao
                        .findByHypervisorTypeAndVersion(host.getHypervisorType(), host.getHypervisorVersion());
                srcClusterId = host.getClusterId();
            }

            if (capabilities != null) {
                liveMigrateVolume = capabilities.isStorageMotionSupported();
            }
        }

        // If vm is running, and hypervisor doesn't support live migration, then return error
        if (!liveMigrateVolume) {
            throw new InvalidParameterValueException("Volume needs to be detached from VM");
        }
    }

    if (liveMigrateVolume && !cmd.isLiveMigrate()) {
        throw new InvalidParameterValueException(
                "The volume " + vol + "is attached to a vm and for migrating it "
                        + "the parameter livemigrate should be specified");
    }

    StoragePool destPool = (StoragePool) dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
    if (destPool == null) {
        throw new InvalidParameterValueException(
                "Failed to find the destination storage pool: " + storagePoolId);
    }

    if (_volumeMgr.volumeOnSharedStoragePool(vol)) {
        if (destPool.isLocal()) {
            throw new InvalidParameterValueException(
                    "Migration of volume from shared to local storage pool is not supported");
        } else {
            // If the volume is attached to a running vm and the volume is on a shared storage pool, check
            // to make sure that the destination storage pool is in the same cluster as the vm.
            if (liveMigrateVolume && destPool.getClusterId() != null && srcClusterId != null) {
                if (!srcClusterId.equals(destPool.getClusterId())) {
                    throw new InvalidParameterValueException(
                            "Cannot migrate a volume of a virtual machine to a storage pool in a different cluster");
                }
            }
            // In case of VMware, if ROOT volume is being cold-migrated, then ensure destination storage pool is in the same Datacenter as the VM.
            if (vm != null && vm.getHypervisorType().equals(HypervisorType.VMware)) {
                if (!liveMigrateVolume && vol.volumeType.equals(Volume.Type.ROOT)) {
                    Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
                    HostVO host = _hostDao.findById(hostId);
                    if (host != null)
                        srcClusterId = host.getClusterId();
                    if (srcClusterId != null && destPool.getClusterId() != null
                            && !srcClusterId.equals(destPool.getClusterId())) {
                        String srcDcName = _clusterDetailsDao.getVmwareDcName(srcClusterId);
                        String destDcName = _clusterDetailsDao.getVmwareDcName(destPool.getClusterId());
                        if (srcDcName != null && destDcName != null && !srcDcName.equals(destDcName)) {
                            throw new InvalidParameterValueException(
                                    "Cannot migrate ROOT volume of a stopped VM to a storage pool in a different VMware datacenter");
                        }
                    }
                    updateMissingRootDiskController(vm, vol.getChainInfo());
                }
            }
        }
    } else {
        throw new InvalidParameterValueException(
                "Migration of volume from local storage pool is not supported");
    }

    if (vm != null) {
        // serialize VM operation
        AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
        if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
            // avoid re-entrance

            VmWorkJobVO placeHolder = null;
            placeHolder = createPlaceHolderWork(vm.getId());
            try {
                return orchestrateMigrateVolume(vol.getId(), destPool.getId(), liveMigrateVolume);
            } finally {
                _workJobDao.expunge(placeHolder.getId());
            }

        } else {
            Outcome<Volume> outcome = migrateVolumeThroughJobQueue(vm.getId(), vol.getId(), destPool.getId(),
                    liveMigrateVolume);

            try {
                outcome.get();
            } catch (InterruptedException e) {
                throw new RuntimeException("Operation is interrupted", e);
            } catch (java.util.concurrent.ExecutionException e) {
                throw new RuntimeException("Execution excetion", e);
            }

            Object jobResult = _jobMgr.unmarshallResultObject(outcome.getJob());
            if (jobResult != null) {
                if (jobResult instanceof ConcurrentOperationException)
                    throw (ConcurrentOperationException) jobResult;
                else if (jobResult instanceof RuntimeException)
                    throw (RuntimeException) jobResult;
                else if (jobResult instanceof Throwable)
                    throw new RuntimeException("Unexpected exception", (Throwable) jobResult);
            }

            // retrieve the migrated new volume from job result
            if (jobResult != null && jobResult instanceof Long) {
                return _entityMgr.findById(VolumeVO.class, ((Long) jobResult));
            }
            return null;
        }
    }

    return orchestrateMigrateVolume(vol.getId(), destPool.getId(), liveMigrateVolume);
}

From source file:org.apache.fineract.portfolio.loanaccount.domain.Loan.java

public LoanTransaction handlePayDisbursementTransaction(final Long chargeId,
        final LoanTransaction chargesPayment, final List<Long> existingTransactionIds,
        final List<Long> existingReversedTransactionIds) {
    existingTransactionIds.addAll(findExistingTransactionIds());
    existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
    LoanCharge charge = null;/* w w  w .  j a v a2s.  c o  m*/
    for (final LoanCharge loanCharge : this.charges) {
        if (loanCharge.isActive() && chargeId.equals(loanCharge.getId())) {
            charge = loanCharge;
        }
    }
    @SuppressWarnings("null")
    final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(chargesPayment, charge, charge.amount(),
            null);
    chargesPayment.getLoanChargesPaid().add(loanChargePaidBy);
    final Money zero = Money.zero(getCurrency());
    chargesPayment.updateComponents(zero, zero, charge.getAmount(getCurrency()), zero);
    chargesPayment.updateLoan(this);
    this.loanTransactions.add(chargesPayment);
    updateLoanOutstandingBalaces();
    charge.markAsFullyPaid();
    return chargesPayment;
}

From source file:com.gst.portfolio.loanaccount.domain.Loan.java

public boolean hasIdentifyOf(final Long loanId) {
    return loanId.equals(getId());
}

From source file:com.gst.portfolio.loanaccount.domain.Loan.java

public LoanCharge fetchLoanChargesById(Long id) {
    LoanCharge charge = null;//  ww w .j a va  2  s  . co  m
    for (LoanCharge loanCharge : this.charges) {
        if (id.equals(loanCharge.getId())) {
            charge = loanCharge;
            break;
        }
    }
    return charge;
}