예제 #1
0
  public boolean userAdminHasPositiveBalance(Integer balanceItem, String loggedUser) {
    boolean hasPositiveBalance = false;
    String ndgMode = null;

    if (properties.containsKey("NDG_MODE")) {
      ndgMode = properties.getProperty("NDG_MODE");
    }

    char userAdminHasFullPermission = 'N';
    try {
      userAdminHasFullPermission =
          findNdgUserByName(findNdgUserByName(loggedUser).getUserAdmin()).getHasFullPermissions();
    } catch (MSMApplicationException e) {
      e.printStackTrace();
    }

    if (!("hosted".equals(ndgMode))
        || (userAdminHasFullPermission == 'Y')
        || (userAdminHasFullPermission == 'y')) {
      hasPositiveBalance = true;
    } else {
      NdgUser onlineUser = null;
      try {
        onlineUser = findNdgUserByName(loggedUser);
      } catch (MSMApplicationException e) {
        e.printStackTrace();
      }

      Query query = manager.createNamedQuery("userbalance.findByUserAdmin");
      query.setParameter("useradmin", onlineUser.getUserAdmin());

      try {
        UserBalance userBalance = (UserBalance) query.getSingleResult();
        if (balanceItem.intValue() == UserVO.USER_LIMIT.intValue()) {
          hasPositiveBalance = (userBalance.getUsers() > 0);
        } else if (balanceItem.intValue() == UserVO.IMEI_LIMIT.intValue()) {
          hasPositiveBalance = (userBalance.getImeis() > 0);
        } else if (balanceItem.intValue() == UserVO.ALERT_LIMIT.intValue()) {
          hasPositiveBalance = (userBalance.getSendAlerts() > 0);
        } else if (balanceItem.intValue() == UserVO.RESULT_LIMIT.intValue()) {
          hasPositiveBalance = (userBalance.getResults() > 0);
        } else if (balanceItem.intValue() == UserVO.SURVEY_LIMIT.intValue()) {
          hasPositiveBalance = (userBalance.getSurveys() > 0);
        }
      } catch (Exception e) {
        hasPositiveBalance = false;
      }
    }
    return hasPositiveBalance;
  }
예제 #2
0
  public String processListCommand() {
    String result = new String();
    StringBuffer stb = new StringBuffer();

    stb.append("<surveys>\n");

    try {
      ArrayList<SurveyVO> listOfSurveys =
          (ArrayList<SurveyVO>) mb.listSurveysByImeiDB(imei, TransactionLogVO.STATUS_AVAILABLE);

      for (Iterator iterator = listOfSurveys.iterator(); iterator.hasNext(); ) {
        SurveyVO surveyVO = (SurveyVO) iterator.next();
        String linha =
            "<survey id=\""
                + surveyVO.getIdSurvey()
                + "\""
                + " title=\""
                + surveyVO.getTitle()
                + "\"/>";
        stb.append(linha + "\n");
      }

      stb.append("</surveys>");

      result = stb.toString();
    } catch (MSMApplicationException e) {
      e.printStackTrace();
    } catch (MSMSystemException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return result;
  }
 public void saveSettingsFromEditorToServer(String userName, String settingsContent) {
   try {
     userManager.saveSettingsFromEditorToServer(userName, settingsContent);
   } catch (MSMApplicationException e) {
     e.printStackTrace();
   }
 }
예제 #4
0
  public String processDownloadCommand() {
    StringBuffer result = new StringBuffer();

    try {
      for (Iterator iterator =
              mb.listSurveysByImeiDB(imei, TransactionLogVO.STATUS_AVAILABLE).iterator();
          iterator.hasNext(); ) {
        NdgUser userlogged = mb.getUserByImei(imei);

        if (userlogged != null) {
          SurveyVO surveyVO = (SurveyVO) iterator.next();

          StringBuffer currentResult = new StringBuffer(surveyVO.getSurvey());

          // we need to remove last '\n'
          if (currentResult.charAt(currentResult.toString().length() - 1) == '\n') {
            currentResult.deleteCharAt(currentResult.toString().length() - 1);
          }

          result.append(currentResult);
        } else {
          new UserNotFoundException();
        }
      }
    } catch (MSMApplicationException e) {
      e.printStackTrace();
    } catch (MSMSystemException e) {
      e.printStackTrace();
    }

    return new String(result);
  }
 public void detachImeiFromSurvey(String surveyID, String imeiNumber)
     throws MSMApplicationException {
   try {
     surveyHandler.detachImeiFromSurvey(surveyID, imeiNumber);
   } catch (MSMApplicationException e) {
     e.printStackTrace();
   }
 }
예제 #6
0
  public void updateUserAdminBalance(Integer balanceItem, String loggedUser) {
    String ndgMode = null;
    if (properties.containsKey("NDG_MODE")) {
      ndgMode = properties.getProperty("NDG_MODE");
    }

    char userAdminHasFullPermission = 'N';
    try {
      userAdminHasFullPermission =
          findNdgUserByName(findNdgUserByName(loggedUser).getUserAdmin()).getHasFullPermissions();
    } catch (MSMApplicationException e) {
      e.printStackTrace();
    }

    try {
      if ("hosted".equals(ndgMode)) {
        if (!((userAdminHasFullPermission == 'y') || (userAdminHasFullPermission == 'Y'))) {
          NdgUser onlineUser = findNdgUserByName(loggedUser);

          Query query = manager.createNamedQuery("userbalance.findByUserAdmin");
          query.setParameter("useradmin", onlineUser.getUserAdmin());

          UserBalance userBalance = (UserBalance) query.getSingleResult();
          if (balanceItem.intValue() == UserVO.USER_LIMIT.intValue()) {
            userBalance.setUsers(userBalance.getUsers() - 1);
          } else if (balanceItem.intValue() == UserVO.IMEI_LIMIT.intValue()) {
            userBalance.setImeis(userBalance.getImeis() - 1);
          } else if (balanceItem.intValue() == UserVO.ALERT_LIMIT.intValue()) {
            userBalance.setSendAlerts(userBalance.getSendAlerts() - 1);
          } else if (balanceItem.intValue() == UserVO.RESULT_LIMIT.intValue()) {
            userBalance.setResults(userBalance.getResults() - 1);
          } else if (balanceItem.intValue() == UserVO.SURVEY_LIMIT.intValue()) {
            userBalance.setSurveys(userBalance.getSurveys() - 1);
          }

          manager.persist(userBalance);
        }
      }
    } catch (MSMApplicationException e) {
      e.printStackTrace();
    }
  }
  public String loadSettingsFromServerToEditor(String userName) {
    String settingsContent = "";

    try {
      settingsContent = userManager.loadSettingsFromServerToEditor(userName);
    } catch (MSMApplicationException e) {
      e.printStackTrace();
    }

    return settingsContent;
  }
  public ArrayList<String> loadSurveysFromServerToEditor(String userName) {
    ArrayList<String> surveyList = new ArrayList<String>();

    try {
      surveyList = surveyHandler.loadSurveysFromServerToEditor(userName);
    } catch (MSMApplicationException e) {
      e.printStackTrace();
    }

    return surveyList;
  }
예제 #9
0
  private void updateStatusSendingSurvey(String status) {
    try {
      mb.updateStatusSendingSurvey(imei, status);

      log.debug("Processing Ack Command to Imei " + imei);
      log.debug("############################################################");
    } catch (MSMApplicationException e) {
      e.printStackTrace();
    } catch (MSMSystemException e) {
      e.printStackTrace();
    }
  }
 public void sendDynamicJad(String msisdn, String imei) throws MSMApplicationException {
   String urlToJad = null;
   try {
     urlToJad = deviceManager.createDynamicJad(msisdn);
     ArrayList<ImeiVO> listoOfDevices = new ArrayList<ImeiVO>();
     ImeiVO imeiVo = new ImeiVO();
     imeiVo.setImei(imei);
     imeiVo.setMsisdn(msisdn);
     listoOfDevices.add(imeiVo);
     if (SmsHandlerFactory.getInstance().hasSmsSupport()) {
       sendLinkSMS(urlToJad, listoOfDevices);
     }
   } catch (MSMApplicationException e) {
     e.printStackTrace();
   }
 }
예제 #11
0
  public String loadSettingsFromServerToEditor(String userName) throws MSMApplicationException {
    String settingsContent = "";

    NdgUser user = null;

    try {
      try {
        user = findNdgUserByName(userName);
      } catch (MSMApplicationException e) {
        e.printStackTrace();
      }
    } catch (NoResultException e) {
      // empty
    }

    if (user != null) {
      settingsContent = user.getEditorSettings();
    }

    return settingsContent;
  }