コード例 #1
0
 public Object convertSingleResultingObjectToType(Object value, String className) {
   if (value != null) {
     IWTimestamp stamp = new IWTimestamp(value.toString());
     return stamp.getDate();
   }
   return value;
 }
コード例 #2
0
 /**
  * Sets the content (value) of the date input.
  *
  * @param value The content to set.
  */
 public void setContent(String content) {
   if (!"".equals(content)) {
     IWTimestamp stamp = new IWTimestamp(content);
     if (stamp != null) {
       setDate(stamp.getDate());
     }
   }
 }
 public String getDateString(Timestamp stamp, String pattern) {
   IWTimestamp iwts = null;
   String dateStr = "";
   if (stamp != null) {
     iwts = new IWTimestamp(stamp);
     dateStr = iwts.getDateString(pattern);
   }
   return dateStr;
 }
コード例 #4
0
  public Collection<SearchResult> getArticleSearchResults(
      String folder, List<String> categories, IWContext iwc) {
    if (folder == null) {
      return null;
    }
    if (iwc == null) {
      iwc = IWContext.getInstance();
      if (iwc == null) {
        return null;
      }
    }

    IWTimestamp oldest = null;

    if (this.numberOfDaysDisplayed > 0) {
      oldest = IWTimestamp.RightNow();
      oldest.addDays(-this.numberOfDaysDisplayed);
    }

    IWSlideSession session = null;
    try {
      session = (IWSlideSession) IBOLookup.getSessionInstance(iwc, IWSlideSession.class);
    } catch (IBOLookupException e) {
      e.printStackTrace();
      return null;
    }
    String webDavUri = null;
    try {
      webDavUri = session.getWebdavServerURI();
    } catch (RemoteException e) {
      e.printStackTrace();
    }
    if (webDavUri != null) {
      if (folder.startsWith(webDavUri)) {
        folder = folder.substring(webDavUri.length());
      }
      if (folder.startsWith(CoreConstants.SLASH)) {
        folder = folder.substring(1);
      }
    }
    SearchRequest articleSearch = null;
    try {
      articleSearch = getSearchRequest(folder, iwc.getCurrentLocale(), oldest, categories);
    } catch (SearchException e) {
      e.printStackTrace();
      return null;
    }
    ContentSearch searchBusiness = new ContentSearch(iwc.getIWMainApplication());
    searchBusiness.setToUseRootAccessForSearch(true);
    searchBusiness.setToUseDescendingOrder(true);
    Search search = searchBusiness.createSearch(articleSearch);
    return search.getSearchResults();
  }
  public String creditcardAuthorization(
      String nameOnCard,
      String cardnumber,
      String monthExpires,
      String yearExpires,
      String ccVerifyNumber,
      double amount,
      String currency,
      String referenceNumber)
      throws CreditCardAuthorizationException {
    IWTimestamp stamp = IWTimestamp.RightNow();
    this.strName = nameOnCard;
    this.strCCNumber = cardnumber;
    this.strCCExpire = yearExpires + monthExpires;
    this.strCCVerify = ccVerifyNumber;
    setCurrencyAndAmount(currency, amount);
    this.strCurrentDate = getDateString(stamp);
    this.strReferenceNumber = convertStringToNumbers(referenceNumber);

    Hashtable returnedProperties = getFirstResponse();
    if (returnedProperties != null) {
      return propertiesToString(returnedProperties);
    } else {
      return null;
    }
  }
コード例 #6
0
  public LandsmotRegistration register(
      User user, LandsmotEvent event, String email, IWTimestamp date) {
    LandsmotRegistration reg = null;
    if (event != null) {
      try {
        reg = getLandsmotRegistrationHome().findByUserAndEvent(user, event);
      } catch (FinderException e) {
      }
    }

    if (reg == null) {
      try {
        reg = getLandsmotRegistrationHome().create();
        reg.setUser(user);
        if (event != null) {
          reg.setEvent(event);
        }
        reg.setDate(date.getTimestamp());
        reg.store();
      } catch (CreateException e) {
        e.printStackTrace();
      }
    }
    return reg;
  }
コード例 #7
0
  public LandsmotGroupRegistration register(
      String groupName,
      Collection participants,
      LandsmotEvent event,
      String email,
      IWTimestamp date) {
    LandsmotGroupRegistration groupRegistration = null;
    try {
      groupRegistration = getLandsmotGroupRegistrationHome().create();
      groupRegistration.setName(groupName);
      groupRegistration.setEvent(event);
      groupRegistration.setDate(date.getTimestamp());
      groupRegistration.store();

      if (participants != null && !participants.isEmpty()) {
        Iterator iter = participants.iterator();
        while (iter.hasNext()) {
          User participant = (User) iter.next();
          LandsmotRegistration registration = register(participant, null, null, date);
          if (registration != null) {
            registration.setGroupRegistration(groupRegistration);
            registration.store();
          }
        }
      }

    } catch (CreateException e) {
      e.printStackTrace();
    }
    return groupRegistration;
  }
  public String doRefund(
      String cardnumber,
      String monthExpires,
      String yearExpires,
      String ccVerifyNumber,
      double amount,
      String currency,
      Object parentDataPK,
      String captureProperties)
      throws CreditCardAuthorizationException {
    IWTimestamp stamp = IWTimestamp.RightNow();
    this.strCCNumber = cardnumber;
    this.strCCExpire = yearExpires + monthExpires;
    this.strCCVerify = ccVerifyNumber;
    setCurrencyAndAmount(currency, amount);
    this.strCurrentDate = getDateString(stamp);

    try {
      StringBuffer logText = new StringBuffer();
      Hashtable capturePropertiesHash = parseResponse(captureProperties);
      Hashtable properties =
          doRefund(getAmountWithExponents(amount), capturePropertiesHash, parentDataPK);

      String authCode = properties.get(this.PROPERTY_APPROVAL_CODE).toString();
      logText.append("\nRefund successful").append("\nAuthorization Code = " + authCode);
      logText.append("\nAction Code = " + properties.get(this.PROPERTY_ACTION_CODE).toString());
      try {
        String tmpCardNum = CreditCardBusinessBean.encodeCreditCardNumber(cardnumber);
        storeAuthorizationEntry(
            tmpCardNum,
            parentDataPK,
            properties,
            KortathjonustanAuthorisationEntries.AUTHORIZATION_TYPE_REFUND);
        log(logText.toString());

      } catch (Exception e) {
        System.err.println("Unable to save entry to database");
        e.printStackTrace();
        if (authCode != null) {
          return authCode;
        } else {
          throw new CreditCardAuthorizationException(e);
        }
      }

      return authCode;
    } catch (CreditCardAuthorizationException e) {
      StringBuffer logText = new StringBuffer();
      logText.append("Authorization FAILED");
      logText.append("\nError           = " + e.getErrorMessage());
      logText.append("\nNumber        = " + e.getErrorNumber());
      logText.append("\nDisplay error = " + e.getDisplayError());
      log(logText.toString());
      throw e;
    } catch (NullPointerException n) {
      throw new CreditCardAuthorizationException(n);
    }
  }
コード例 #9
0
 public PresentationObject getHandlerObject(String name, String value, IWContext iwc) {
   this.setName(name);
   if (value != null) {
     SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
     try {
       Date date = formatter.parse(value);
       java.sql.Date sqlDate = new java.sql.Date(date.getTime());
       setDate(sqlDate);
       return this;
     } catch (ParseException ex) {
       logError("[DateInput] The value " + value + " could not be parsed");
       // go further to the default setting
     }
   }
   IWTimestamp to = IWTimestamp.RightNow();
   this.setYearRange(SYSTEM_LAUNCH_YEAR, to.getYear());
   this.setDate(to.getDate());
   return this;
 }
コード例 #10
0
  public SearchRequest getSearchRequest(
      String scope, Locale locale, IWTimestamp oldest, List<String> categoryList)
      throws SearchException {
    SearchRequest s = new SearchRequest();
    s.addSelection(IWSlideConstants.PROPERTY_DISPLAY_NAME);
    s.addSelection(IWSlideConstants.PROPERTY_CREATION_DATE);
    s.addSelection(IWSlideConstants.PROPERTY_CATEGORY);
    s.addScope(new SearchScope(scope));
    SearchExpression expression = null;

    String localeString = CoreConstants.EMPTY;
    SearchExpression namePatternExpression =
        s.compare(
            CompareOperator.LIKE,
            IWSlideConstants.PROPERTY_DISPLAY_NAME,
            "%" + localeString + ".article");
    expression = namePatternExpression;

    SearchExpression creationDateExpression = null;
    if (oldest != null) {
      creationDateExpression =
          s.compare(CompareOperator.GTE, IWSlideConstants.PROPERTY_CREATION_DATE, oldest.getDate());
      expression = s.and(expression, creationDateExpression);
    }

    List<CompareExpression> categoryExpressions = new ArrayList<CompareExpression>();
    if (categoryList != null) {
      for (Iterator<String> iter = categoryList.iterator(); iter.hasNext(); ) {
        String categoryName = iter.next();
        categoryExpressions.add(
            s.compare(
                CompareOperator.LIKE,
                IWSlideConstants.PROPERTY_CATEGORY,
                "%," + categoryName + ",%"));
      }
      Iterator<CompareExpression> expr = categoryExpressions.iterator();
      if (expr.hasNext()) {
        SearchExpression categoryExpression = expr.next();
        while (expr.hasNext()) {
          categoryExpression = s.or(categoryExpression, expr.next());
        }
        expression = s.and(expression, categoryExpression);
      }
    }

    s.setWhereExpression(expression);
    return s;
  }
コード例 #11
0
  public void endIdegaWebApplication() {
    // IWMainApplication application = IWMainApplication.getIWMainApplication(getServletContext());
    // IWMainApplication application = iwma;
    this.iwma
        .getSettings()
        .setProperty("last_shutdown", com.idega.util.IWTimestamp.RightNow().toString());

    IWStyleManager iwStyleManager = IWStyleManager.getInstance();
    log.fine("Saving style sheet");
    iwStyleManager.writeStyleSheet();
    this.iwma.unloadInstanceAndClass();
    // some bundle starters have initialized threads that are using the database
    // therefore stop first and then end database pool
    endDatabasePool();
    log.fine("Completed");
    Introspector.flushCaches();
  }
  /**
   * @param cardnumber
   * @param parentDataPK
   * @param properties
   * @throws IDOLookupException
   * @throws CreateException
   */
  private void storeAuthorizationEntry(
      String encodedCardnumber, Object parentDataPK, Hashtable properties, String authorizationType)
      throws IDOLookupException, CreateException {
    KortathjonustanAuthorisationEntriesHome authHome =
        (KortathjonustanAuthorisationEntriesHome)
            IDOLookup.getHome(KortathjonustanAuthorisationEntries.class);
    auth = authHome.create();

    if (properties.containsKey(this.PROPERTY_AMOUNT))
      auth.setAmount(
          Double.parseDouble(
              properties.get(this.PROPERTY_AMOUNT).toString())); // Double.parseDouble(strAmount));
    if (properties.containsKey(this.PROPERTY_APPROVAL_CODE))
      auth.setAuthorizationCode(
          properties.get(this.PROPERTY_APPROVAL_CODE).toString()); // authCode);
    if (properties.containsKey(this.PROPERTY_CARD_BRAND_NAME))
      auth.setBrandName(properties.get(this.PROPERTY_CARD_BRAND_NAME).toString());
    if (properties.containsKey(this.PROPERTY_CC_EXPIRE))
      auth.setCardExpires(
          properties.get(this.PROPERTY_CC_EXPIRE).toString()); // monthExpires+yearExpires);
    if (properties.containsKey(this.PROPERTY_CURRENCY_CODE))
      auth.setCurrency(
          getCurrencyAbbreviation(
              properties.get(this.PROPERTY_CURRENCY_CODE).toString())); // currency);
    if (properties.containsKey(this.PROPERTY_ERROR_CODE))
      auth.setErrorNumber(properties.get(this.PROPERTY_ERROR_CODE).toString());
    if (properties.containsKey(this.PROPERTY_ERROR_TEXT))
      auth.setErrorText(properties.get(this.PROPERTY_ERROR_TEXT).toString());
    if (properties.containsKey(this.PROPERTY_TOTAL_RESPONSE))
      auth.setServerResponse(properties.get(this.PROPERTY_TOTAL_RESPONSE).toString());

    auth.setTransactionType(authorizationType);
    auth.setCardNumber(encodedCardnumber);
    auth.setDate(IWTimestamp.RightNow().getDate());

    if (parentDataPK != null) {
      try {
        auth.setParentID(((Integer) parentDataPK).intValue());
      } catch (Exception e) {
        System.out.println("KortathjonustanCCCleint : could not set parentID : " + parentDataPK);
      }
    }
    auth.store();
  }
コード例 #13
0
  public void addScriptElements(IWContext iwc) {
    if (this.isShowDay) {
      if (this.showYear) {
        this.theYear.setOnChange(
            "iwPopulateDaysWithYear(this,this.form."
                + this.theMonth.getName()
                + ",this.form."
                + this.theDay.getName()
                + ",'"
                + this.dayString
                + "');iwSetValueOfHiddenDateWithAllInputs(this.form."
                + this.theYear.getName()
                + ",this.form."
                + this.theMonth.getName()
                + ",this.form."
                + this.theDay.getName()
                + ",this.form."
                + this.theWholeDate.getName()
                + ");");
        this.theMonth.setOnChange(
            "iwPopulateDaysWithYear(this.form."
                + this.theYear.getName()
                + ",this,this.form."
                + this.theDay.getName()
                + ",'"
                + this.dayString
                + "');iwSetValueOfHiddenDateWithAllInputs(this.form."
                + this.theYear.getName()
                + ",this.form."
                + this.theMonth.getName()
                + ",this.form."
                + this.theDay.getName()
                + ",this.form."
                + this.theWholeDate.getName()
                + ");");
        this.theDay.setOnChange(
            "iwSetValueOfHiddenDateWithAllInputs(this.form."
                + this.theYear.getName()
                + ",this.form."
                + this.theMonth.getName()
                + ",this.form."
                + this.theDay.getName()
                + ",this.form."
                + this.theWholeDate.getName()
                + ");");
      } else {
        this.theMonth.setOnChange(
            "iwPopulateDaysWithMonth('"
                + this.selectedYear
                + "',this,this.form."
                + this.theDay.getName()
                + ",'"
                + this.dayString
                + "');iwSetValueOfHiddenDateWithDay('"
                + this.selectedYear
                + "',this.form."
                + this.theMonth.getName()
                + ",this.form."
                + this.theDay.getName()
                + ",this.form."
                + this.theWholeDate.getName()
                + ");");
        this.theDay.setOnChange(
            "iwSetValueOfHiddenDateWithDay('"
                + this.selectedYear
                + "',this.form."
                + this.theMonth.getName()
                + ",this.form."
                + this.theDay.getName()
                + ",this.form."
                + this.theWholeDate.getName()
                + ");");
      }
    } else {
      if (this.showYear) {
        this.theYear.setOnChange(
            "iwSetValueOfHiddenDateWithYear(this.form."
                + this.theYear.getName()
                + ",this.form."
                + this.theMonth.getName()
                + ",this.form."
                + this.theWholeDate.getName()
                + ");");
        this.theMonth.setOnChange(
            "iwSetValueOfHiddenDateWithYear(this.form."
                + this.theYear.getName()
                + ",this.form."
                + this.theMonth.getName()
                + ",this.form."
                + this.theWholeDate.getName()
                + ");");
      } else {
        this.theMonth.setOnChange(
            "iwSetValueOfHiddenDateWithMonth('"
                + this.selectedYear
                + "',this.form."
                + this.theMonth.getName()
                + ",'01',this.form."
                + this.theWholeDate.getName()
                + ");");
      }
    }
    if (this.isSetAsNotEmpty) {
      if (this.showYear) {
        this.theYear.setAsNotEmpty(this.notEmptyErrorMessage, "YY");
      }
      this.theMonth.setAsNotEmpty(this.notEmptyErrorMessage, "00");
      if (this.isShowDay) {
        this.theDay.setAsNotEmpty(this.notEmptyErrorMessage, "00");
      }
    }
    if (this.earliestDate != null) {
      if (getParentForm() != null) {
        Form form = getParentForm();
        form.setOnSubmit("return checkSubmit(this)");
        Script script = form.getAssociatedFormScript();
        if (script == null) {
          script = new Script();
        }

        if (script.getFunction("checkSubmit") == null) {
          script.addFunction("checkSubmit", "function checkSubmit(inputs){\n\n}");
        }

        IWTimestamp earlyDate = new IWTimestamp(this.earliestDate.getTime());
        earlyDate.setTime(0, 0, 0, 0);
        script.addToBeginningOfFunction(
            "checkSubmit",
            "if (checkEarliestDate (findObj('"
                + getName()
                + "'),"
                + earlyDate.getDate().getTime()
                + ", '"
                + this.earliestDateErrorMessage
                + "') == false ){\nreturn false;\n}\n");

        StringBuffer buffer = new StringBuffer();
        buffer.append("function checkEarliestDate(input, date, warnMsg) {").append("\n\t");
        buffer.append("var returnBoolean = true;").append("\n\t");
        buffer.append("var dateString = input.value;").append("\n\t");
        buffer.append("if (dateString.length > 0) {").append("\n\t\t");
        buffer.append("var oldDate = new Date(date);").append("\n\t\t");
        buffer.append("var month = dateString.substring(5,7) - 1;").append("\n\t\t");
        buffer
            .append(
                "var newDate = new Date(dateString.substring(0,4),month,dateString.substring(8,10));")
            .append("\n\t\t");
        buffer.append("var difference = oldDate - newDate;").append("\n\t\t");
        buffer.append("if (difference > 0)").append("\n\t\t\t");
        buffer.append("returnBoolean = false;").append("\n\t");
        buffer.append("}").append("\n\n\t");
        buffer.append("if (!returnBoolean)").append("\n\t\t");
        buffer.append("alert(warnMsg);").append("\n\t");
        buffer.append("return returnBoolean;").append("\n}");
        script.addFunction("checkEarliestDate", buffer.toString());

        form.setAssociatedFormScript(script);
      }
    }
    if (this.latestDate != null) {
      if (getParentForm() != null) {
        Form form = getParentForm();
        form.setOnSubmit("return checkSubmit(this)");
        Script script = form.getAssociatedFormScript();
        if (script == null) {
          script = new Script();
        }

        if (script.getFunction("checkSubmit") == null) {
          script.addFunction("checkSubmit", "function checkSubmit(inputs){\n\n}");
        }
        script.addToFunction(
            "checkSubmit",
            "if (checkLatestDate (findObj('"
                + getName()
                + "'),"
                + this.latestDate.getTime()
                + ", '"
                + this.latestDateErrorMessage
                + "') == false ){\nreturn false;\n}\n");

        StringBuffer buffer = new StringBuffer();
        buffer.append("function checkLatestDate(input, date, warnMsg) {").append("\n\t");
        buffer.append("var returnBoolean = true;").append("\n\t");
        buffer.append("var dateString = input.value;").append("\n\t");
        buffer.append("if (dateString.length > 0) {").append("\n\t\t");
        buffer.append("var oldDate = new Date(date);").append("\n\t\t");
        buffer.append("var month = dateString.substring(5,7) - 1;").append("\n\t\t");
        buffer
            .append(
                "var newDate = new Date(dateString.substring(0,4),month,dateString.substring(8,10));")
            .append("\n\t\t");
        buffer.append("var difference = newDate - oldDate;").append("\n\t\t");
        buffer.append("if (difference > 0)").append("\n\t\t\t");
        buffer.append("returnBoolean = false;").append("\n\t");
        buffer.append("}").append("\n\n\t");
        buffer.append("if (!returnBoolean)").append("\n\t\t");
        buffer.append("alert(warnMsg);").append("\n\t");
        buffer.append("return returnBoolean;").append("\n}");
        script.addFunction("checkLatestDate", buffer.toString());

        form.setAssociatedFormScript(script);
      }
    }
  }
コード例 #14
0
  public void startIdegaWebApplication() {
    long start = System.currentTimeMillis();

    try {
      addToClassPath();
    } catch (Exception e) {
      log.log(Level.WARNING, "Error adding libs to classpath", e);
    }

    // reset singletons
    IWMainApplication.shutdownApplicationServices();
    // enable singletons
    SingletonRepository.start();

    this.setDatabaseProperties();
    registerSystemBeans();
    this.startDatabasePool();

    // set application variables first before setting any properties (ICApplicationBinding table
    // might be created first)
    setApplicationVariables();
    if (!this.iwma.getSettings().getBoolean("use_debug_mode", false)) {
      this.iwma.regData();
    }
    // now set some properties
    this.iwma
        .getSettings()
        .setProperty("last_startup", com.idega.util.IWTimestamp.RightNow().toString());

    // cleaning, maintaining, updating
    if (!this.iwma.isInDatabaseLessMode()) {
      log.fine("Cleaning and updating database...");
      updateStartDataInDatabase();
      log.fine("...cleaning and updating database done");
    }
    startTemporaryBundleStarters();

    startComponentRegistry();

    boolean fileSystemStarted = false;
    if (!this.iwma.isInDatabaseLessMode()) {
      this.iwma.startAccessController();

      fileSystemStarted = this.iwma.startFileSystem(false);
    }

    try {
      log.fine("Loading the ViewManager...");
      this.iwma.loadViewManager();
      log.fine("...loading ViewManager done");
    } catch (Exception e) {
      log.log(Level.SEVERE, "Error loading the ViewManager", e);
    }

    if (!this.iwma.isInDatabaseLessMode()) {
      this.iwma.loadBundles();

      if (!fileSystemStarted) {
        this.iwma.startFileSystem(
            true); // added by Eiki to ensure that ic_file is created before ib_page
      }
    }

    executeServices(this.iwma);
    // create ibdomain
    long end = System.currentTimeMillis();
    long time = (end - start) / 1000;

    // test if all classes are available
    testReferencedClasses();
    log.info("Completed in " + time + " seconds");
  }
  /**
   * Terminates all all high school placements not included in the import (except Nacka Gymnasium
   * placements).
   */
  protected boolean terminateOldPlacements() {
    println("NackaHighSchoolPlacementHandler: Starting termination of old placements...");
    boolean success = true;
    School schoolA = null;
    School schoolB = null;
    School schoolC = null;
    try {
      schoolA =
          schoolHome.findBySchoolName(NackaProgmaPlacementImportFileHandlerBean.SCHOOL_NAME_A);
    } catch (FinderException e) {
      println(
          "NackaHighSchoolPlacementHandler: School '"
              + NackaProgmaPlacementImportFileHandlerBean.SCHOOL_NAME_A
              + "' not found.");
      return false;
    }
    try {
      schoolB =
          schoolHome.findBySchoolName(NackaProgmaPlacementImportFileHandlerBean.SCHOOL_NAME_B);
    } catch (FinderException e) {
      println(
          "NackaHighSchoolPlacementHandler: School '"
              + NackaProgmaPlacementImportFileHandlerBean.SCHOOL_NAME_B
              + "' not found.");
      return false;
    }
    try {
      schoolC =
          schoolHome.findBySchoolName(NackaProgmaPlacementImportFileHandlerBean.SCHOOL_NAME_C);
    } catch (FinderException e) {
      println(
          "NackaHighSchoolPlacementHandler: School '"
              + NackaProgmaPlacementImportFileHandlerBean.SCHOOL_NAME_C
              + "' not found.");
      return false;
    }
    int schoolIdA = ((Integer) schoolA.getPrimaryKey()).intValue();
    int schoolIdB = ((Integer) schoolB.getPrimaryKey()).intValue();
    int schoolIdC = ((Integer) schoolC.getPrimaryKey()).intValue();
    String[] schoolIds =
        new String[] {
          String.valueOf(schoolIdA), String.valueOf(schoolIdB), String.valueOf(schoolIdC)
        };

    SchoolCategory highSchoolCategory = null;
    try {
      highSchoolCategory = schoolBusiness.getCategoryHighSchool();
    } catch (RemoteException e) {
      println("NackaHighSchoolPlacementHandler: High school category not found.");
      return false;
    }

    Collection placements = null;
    try {
      placements =
          schoolClassMemberHome.findActiveByCategorySeasonAndSchools(
              highSchoolCategory, season, schoolIds, true);
    } catch (FinderException e) {
      println("NackaHighSchoolPlacementHandler: Error finding placements.");
      return false;
    }

    Commune defaultCommune = null;
    try {
      defaultCommune =
          ((CommuneBusiness) getServiceInstance(CommuneBusiness.class)).getDefaultCommune();
    } catch (IBOLookupException e1) {
      e1.printStackTrace();
      println("NackaHighSchoolPlacementHandler: Unable to get default commune.");

      return false;
    } catch (RemoteException e1) {
      e1.printStackTrace();

      println("NackaHighSchoolPlacementHandler: Unable to get default commune.");
      return false;
    }

    Iterator iter = placements.iterator();
    IWTimestamp now = IWTimestamp.RightNow();
    now.setAsDate();
    while (iter.hasNext()) {
      SchoolClassMember member = (SchoolClassMember) iter.next();
      IWTimestamp placementDate = null;
      try {
        PlacementImportDate p = placementImportDateHome.findByPrimaryKey(member.getPrimaryKey());
        placementDate = new IWTimestamp(p.getImportDate());
        placementDate.setAsDate();
      } catch (FinderException e) {
      }
      School memberSchool = member.getSchoolClass().getSchool();
      if ((placementDate == null || placementDate.isEarlierThan(now))
          && (memberSchool.getManagementTypeId().equals(SchoolManagementTypeBMPBean.TYPE_COMMUNE))
          && (memberSchool.getCommune().equals(defaultCommune))) {
        member.setRemovedDate(lastDayInPreviousMonth);
        member.store();
        println("Terminating placement with id: " + member.getPrimaryKey());
      }
    }

    println("NackaHighSchoolPlacementHandler: Termination of old placements finished.");
    return success;
  }
  /** Stores one placement. */
  protected boolean storeUserInfo(int row) throws RemoteException {

    User user = null;
    SchoolType schoolType = null;
    School school = null;

    String providerName = getUserProperty(COLUMN_PROVIDER_NAME);
    if (providerName == null) {
      errorLog.put(new Integer(row), "The name of the high school is empty.");
      return false;
    }

    String schoolClassName = getUserProperty(COLUMN_SCHOOL_CLASS);
    if (schoolClassName == null) {
      errorLog.put(new Integer(row), "The class name is empty.");
      return false;
    }

    String schoolYearName = getUserProperty(COLUMN_SCHOOL_YEAR);
    if (schoolYearName == null) {
      errorLog.put(new Integer(row), "The school year is empty.");
    }

    String studyPathCode = getUserProperty(COLUMN_STUDY_PATH);
    if (studyPathCode == null) {
      studyPathCode = "";
    }

    String personalId = getUserProperty(COLUMN_PERSONAL_ID);
    if (personalId == null) {
      errorLog.put(new Integer(row), "The personal id is empty.");
      return false;
    }

    String studentName = getUserProperty(COLUMN_STUDENT_NAME);
    if (studentName == null) {
      studentName = "";
    }
    String studentFirstName = "";
    String studentLastName = "";
    if (studentName.length() > 0) {
      int cutPos = studentName.indexOf(',');
      if (cutPos != -1) {
        studentFirstName = studentName.substring(cutPos + 1).trim();
        studentLastName = studentName.substring(0, cutPos).trim();
      }
    }

    String homeCommuneCode = getUserProperty(COLUMN_HOME_COMMUNE);
    if (homeCommuneCode == null) {
      homeCommuneCode = "";
    }

    String address = getUserProperty(COLUMN_ADDRESS);
    if (address == null) {
      address = "";
    }

    String coAddress = getUserProperty(COLUMN_CO_ADDRESS);
    if (coAddress == null) {
      coAddress = "";
    }

    String zipCode = getUserProperty(COLUMN_ZIP_CODE);
    if (zipCode == null) {
      zipCode = "";
    }

    String zipArea = getUserProperty(COLUMN_ZIP_AREA);
    if (zipArea == null) {
      zipArea = "";
    }

    String highSchoolType = getUserProperty(COLUMN_HIGH_SCHOOL_TYPE);
    if (highSchoolType == null) {
      errorLog.put(new Integer(row), "The high school type is empty.");
      return false;
    }

    // user
    boolean isNewUser = false;
    try {
      user = communeUserBusiness.getUserHome().findByPersonalID(personalId);
    } catch (FinderException e) {
      println("User not found for PIN : " + personalId + " CREATING");

      try {
        user =
            communeUserBusiness.createSpecialCitizenByPersonalIDIfDoesNotExist(
                studentFirstName,
                "",
                studentLastName,
                personalId,
                getGenderFromPin(personalId),
                getBirthDateFromPin(personalId));
        isNewUser = true;
      } catch (Exception e2) {
        e2.printStackTrace();
        return false;
      }
    }

    if (isNewUser) {
      try {
        Commune homeCommune = communeHome.findByCommuneCode(homeCommuneCode);
        Integer communeId = (Integer) homeCommune.getPrimaryKey();
        communeUserBusiness.updateCitizenAddress(
            ((Integer) user.getPrimaryKey()).intValue(), address, zipCode, zipArea, communeId);
      } catch (FinderException e) {
        errorLog.put(new Integer(row), "Commune not found: " + homeCommuneCode);
        return false;
      }
      user.store();
    }

    // school type
    String typeKey = null;
    String schoolYearPrefix = "G";
    if (highSchoolType.equals("GY")) {
      typeKey = LOC_KEY_HIGH_SCHOOL;
    } else {
      typeKey = LOC_KEY_SPECIAL_HIGH_SCHOOL;
      schoolYearPrefix += "S";
    }

    try {
      schoolType = schoolTypeHome.findByTypeKey(typeKey);
    } catch (FinderException e) {
      errorLog.put(
          new Integer(row),
          "School type: " + highSchoolType + " not found in database (key = " + typeKey + ").");
      return false;
    }

    // school
    try {
      school = schoolHome.findBySchoolName(providerName);
    } catch (FinderException e) {
      errorLog.put(new Integer(row), "Cannot find school with name '" + providerName + "'");
      return false;
    }

    // school type
    boolean hasSchoolType = false;
    try {
      Iterator schoolTypeIter =
          schoolBusiness.getSchoolRelatedSchoolTypes(school).values().iterator();
      while (schoolTypeIter.hasNext()) {
        SchoolType st = (SchoolType) schoolTypeIter.next();
        if (st.getPrimaryKey().equals(schoolType.getPrimaryKey())) {
          hasSchoolType = true;
          break;
        }
      }
    } catch (Exception e) {
    }

    if (!hasSchoolType) {
      errorLog.put(
          new Integer(row),
          "School type '" + highSchoolType + "' not found in high school: " + providerName);
      return false;
    }

    // school year
    SchoolYear schoolYear = null;
    schoolYearName = schoolYearPrefix + schoolYearName;
    try {
      schoolYear = schoolYearHome.findByYearName(schoolYearName);
    } catch (FinderException e) {
      errorLog.put(new Integer(row), "School year: " + schoolYearName + " not found in database.");
    }
    boolean schoolYearFoundInSchool = false;
    Map m = schoolBusiness.getSchoolRelatedSchoolYears(school);
    try {
      schoolYearFoundInSchool = m.containsKey(schoolYear.getPrimaryKey());
    } catch (Exception e) {
    }

    if (!schoolYearFoundInSchool) {
      errorLog.put(
          new Integer(row),
          "School year: '" + schoolYearName + "' not found in school: '" + providerName + "'.");
      return false;
    }

    // study path
    SchoolStudyPath studyPath = null;
    try {
      studyPath = studyPathHome.findByCode(studyPathCode);
    } catch (Exception e) {
      errorLog.put(new Integer(row), "Cannot find study path: " + studyPathCode);
      return false;
    }

    // school Class
    SchoolClass schoolClass = null;
    try {
      int schoolId = ((Integer) school.getPrimaryKey()).intValue();
      int seasonId = ((Integer) season.getPrimaryKey()).intValue();
      Collection c = schoolClassHome.findBySchoolAndSeason(schoolId, seasonId);
      Iterator iter = c.iterator();
      while (iter.hasNext()) {
        SchoolClass sc = (SchoolClass) iter.next();
        if (sc.getName().equals(schoolClassName)) {
          schoolClass = sc;
          break;
        }
      }
      if (schoolClass == null) {
        throw new FinderException();
      }
    } catch (Exception e) {
      println(
          "School Class not found, creating '"
              + schoolClassName
              + "' for high school '"
              + providerName
              + "'.");
      int schoolId = ((Integer) school.getPrimaryKey()).intValue();
      int schoolTypeId = ((Integer) schoolType.getPrimaryKey()).intValue();
      int seasonId = ((Integer) season.getPrimaryKey()).intValue();
      try {
        schoolClass = schoolClassHome.create();
        schoolClass.setSchoolClassName(schoolClassName);
        schoolClass.setSchoolId(schoolId);
        schoolClass.setSchoolTypeId(schoolTypeId);
        schoolClass.setSchoolSeasonId(seasonId);
        schoolClass.setValid(true);
        schoolClass.store();
        schoolClass.addSchoolYear(schoolYear);
      } catch (Exception e2) {
      }

      if (schoolClass == null) {
        errorLog.put(new Integer(row), "Could not create school Class: " + schoolClassName);
        return false;
      }
    }

    // school Class member
    int schoolClassId = ((Integer) schoolClass.getPrimaryKey()).intValue();
    SchoolClassMember member = null;
    Timestamp registerDate = firstDayInCurrentMonth;

    try {
      Collection placements = schoolClassMemberHome.findByStudent(user);
      if (placements != null) {
        Iterator placementsIter = placements.iterator();
        while (placementsIter.hasNext()) {
          SchoolClassMember placement = (SchoolClassMember) placementsIter.next();
          SchoolType st = placement.getSchoolClass().getSchoolType();
          String stKey = "";

          if (st != null) {
            stKey = st.getLocalizationKey();
          }

          if (stKey.equals(LOC_KEY_HIGH_SCHOOL) || stKey.equals(LOC_KEY_SPECIAL_HIGH_SCHOOL)) {
            if (placement.getRemovedDate() == null) {
              int scId = placement.getSchoolClassId();
              int studyPathId = placement.getStudyPathId();
              int newStudyPathId = ((Integer) studyPath.getPrimaryKey()).intValue();
              int schoolYearId = placement.getSchoolYearId();
              int newSchoolYearId = ((Integer) schoolYear.getPrimaryKey()).intValue();
              if ((scId == schoolClassId)
                  && (studyPathId == newStudyPathId)
                  && (schoolYearId == newSchoolYearId)) {
                member = placement;
              } else {
                IWTimestamp t1 = new IWTimestamp(placement.getRegisterDate());
                t1.setAsDate();
                IWTimestamp t2 = new IWTimestamp(firstDayInCurrentMonth);
                t2.setAsDate();
                if (t1.equals(t2)) {
                  try {
                    PlacementImportDate p = null;
                    try {
                      p = placementImportDateHome.findByPrimaryKey(placement.getPrimaryKey());
                    } catch (FinderException e) {
                    }
                    if (p != null) {
                      p.remove();
                    }
                    placement.remove();
                  } catch (RemoveException e) {
                    log(e);
                  }
                } else {
                  placement.setRemovedDate(lastDayInPreviousMonth);
                  placement.store();
                }
                registerDate = firstDayInCurrentMonth;
              }
            }
          }
        }
      }
    } catch (FinderException f) {
    }

    if (member == null) {
      try {
        member = schoolClassMemberHome.create();
      } catch (CreateException e) {
        errorLog.put(
            new Integer(row),
            "School Class member could not be created for personal id: " + personalId);
        return false;
      }
      member.setSchoolClassId(((Integer) schoolClass.getPrimaryKey()).intValue());
      member.setClassMemberId(((Integer) user.getPrimaryKey()).intValue());
      member.setRegisterDate(registerDate);
      member.setRegistrationCreatedDate(IWTimestamp.getTimestampRightNow());
      member.setSchoolYear(((Integer) schoolYear.getPrimaryKey()).intValue());
      member.setSchoolTypeId(((Integer) schoolType.getPrimaryKey()).intValue());
      member.setStudyPathId(((Integer) studyPath.getPrimaryKey()).intValue());
      member.store();
    }

    PlacementImportDate p = null;
    try {
      p = placementImportDateHome.findByPrimaryKey(member.getPrimaryKey());
    } catch (FinderException e) {
    }
    if (p == null) {
      try {
        p = placementImportDateHome.create();
        p.setSchoolClassMemberId(((Integer) member.getPrimaryKey()).intValue());
      } catch (CreateException e) {
        errorLog.put(
            new Integer(row),
            "Could not create import date from school class member: " + member.getPrimaryKey());
        return false;
      }
    }
    p.setImportDate(today);
    p.store();

    return true;
  }
  /** @see com.idega.block.importer.business.ImportFileHandler#handleRecords() */
  @Override
  public boolean handleRecords() {
    failedRecords = new ArrayList();
    errorLog = new TreeMap();
    report = new Report(file.getFile().getName()); // Create a report file.
    // It will be located in
    // the Report dir

    IWTimestamp t = IWTimestamp.RightNow();
    t.setAsDate();
    today = t.getDate();
    t.setDay(1);
    firstDayInCurrentMonth = t.getTimestamp();
    t.addDays(-1);
    lastDayInPreviousMonth = t.getTimestamp();

    transaction = this.getSessionContext().getUserTransaction();

    Timer clock = new Timer();
    clock.start();

    try {
      // initialize business beans and data homes
      communeUserBusiness =
          (CommuneUserBusiness) this.getServiceInstance(CommuneUserBusiness.class);
      schoolBusiness = (SchoolBusiness) this.getServiceInstance(SchoolBusiness.class);

      schoolHome = schoolBusiness.getSchoolHome();
      schoolTypeHome = schoolBusiness.getSchoolTypeHome();
      schoolYearHome = schoolBusiness.getSchoolYearHome();
      schoolClassHome = (SchoolClassHome) this.getIDOHome(SchoolClass.class);
      schoolClassMemberHome = (SchoolClassMemberHome) this.getIDOHome(SchoolClassMember.class);
      communeHome = (CommuneHome) this.getIDOHome(Commune.class);
      studyPathHome = (SchoolStudyPathHome) this.getIDOHome(SchoolStudyPath.class);
      placementImportDateHome =
          (PlacementImportDateHome) this.getIDOHome(PlacementImportDate.class);

      try {
        season =
            schoolBusiness.getCurrentSchoolSeason(schoolBusiness.getCategoryElementarySchool());
      } catch (FinderException e) {
        e.printStackTrace();
        println("NackaHighSchoolPlacementHandler: School season is not defined.");
        return false;
      }

      transaction.begin();

      // iterate through the records and process them
      String item;
      int count = 0;
      boolean failed = false;

      while (!(item = (String) file.getNextRecord()).trim().equals("")) {
        count++;

        if (!processRecord(item, count)) {
          failedRecords.add(item);
          failed = true;
          // break;
        }

        if ((count % 100) == 0) {
          System.out.println(
              "NackaHighSchoolHandler processing RECORD ["
                  + count
                  + "] time: "
                  + IWTimestamp.getTimestampRightNow().toString());
        }

        item = null;
      }

      if (!failed) {
        if (!terminateOldPlacements()) {
          failed = true;
        }
      }

      printFailedRecords();

      clock.stop();
      println("Number of records handled: " + (count - 1));
      println(
          "Time to handle records: "
              + clock.getTime()
              + " ms  OR "
              + ((int) (clock.getTime() / 1000))
              + " s");

      // success commit changes
      if (!failed) {
        transaction.commit();
      } else {
        transaction.rollback();
      }

      report.store(false);

      return !failed;

    } catch (Exception e) {
      e.printStackTrace();
      try {
        transaction.rollback();
      } catch (SystemException e2) {
        e2.printStackTrace();
      }

      report.store(false);

      return false;
    }
  }
  public String doSale(
      String nameOnCard,
      String cardnumber,
      String monthExpires,
      String yearExpires,
      String ccVerifyNumber,
      double amount,
      String currency,
      String referenceNumber)
      throws CreditCardAuthorizationException {
    try {
      IWTimestamp stamp = IWTimestamp.RightNow();
      this.strName = nameOnCard;
      this.strCCNumber = cardnumber;
      this.strCCExpire = yearExpires + monthExpires;
      this.strCCVerify = ccVerifyNumber;
      setCurrencyAndAmount(currency, amount);
      this.strCurrentDate = getDateString(stamp);
      this.strReferenceNumber = convertStringToNumbers(referenceNumber);

      StringBuffer logText = new StringBuffer();
      // System.out.println("referenceNumber => " + strReferenceNumber);

      Hashtable returnedProperties = getFirstResponse();
      String authCode = null;
      if (returnedProperties != null) {
        logText.append("Authorization successful");
        Hashtable returnedCaptureProperties = finishTransaction(returnedProperties);
        if (returnedCaptureProperties != null
            && returnedCaptureProperties.get(this.PROPERTY_APPROVAL_CODE).toString() != null) {
          // System.out.println("Approval Code =
          // "+returnedCaptureProperties.get(PROPERTY_APPROVAL_CODE).toString());
          authCode =
              returnedCaptureProperties
                  .get(this.PROPERTY_APPROVAL_CODE)
                  .toString(); // returnedCaptureProperties;

          logText.append("\nCapture successful").append("\nAuthorization Code = " + authCode);
          logText.append(
              "\nAction Code = "
                  + returnedCaptureProperties.get(this.PROPERTY_ACTION_CODE).toString());

          try {
            String tmpCardNum = CreditCardBusinessBean.encodeCreditCardNumber(cardnumber);
            this.storeAuthorizationEntry(
                tmpCardNum,
                null,
                returnedCaptureProperties,
                KortathjonustanAuthorisationEntries.AUTHORIZATION_TYPE_SALE);

            log(logText.toString());

          } catch (Exception e) {
            System.err.println("Unable to save entry to database");
            throw new CreditCardAuthorizationException(e);
          }
        }
      }

      return authCode;
    } catch (CreditCardAuthorizationException e) {
      StringBuffer logText = new StringBuffer();
      logText.append("Authorization FAILED");
      logText.append("\nError           = " + e.getErrorMessage());
      logText.append("\nNumber        = " + e.getErrorNumber());
      logText.append("\nDisplay error = " + e.getDisplayError());
      log(logText.toString());
      throw e;
    }
  }
 private String getDateString(IWTimestamp stamp) {
   return stamp.getDateString("yyMMddHHmmss");
 }
  /*
   * public static void main(String[] args) throws Exception { String host =
   * "test.kortathjonustan.is"; int port = 8443; String SITE = "22"; String USER =
   * "idega"; String PASSWORD = "******"; String ACCEPTOR_TERM_ID = "90000022";
   * String ACCEPTOR_IDENTIFICATION = "8180001";
   *
   * String strCCNumber = "5413033024823099"; String strCCExpire = "0504";
   * String strCCVerify = "150"; String strReferenceNumber =
   * Integer.toString((int) (Math.random() * 43200)); String keystore =
   * "/Applications/idega/webs/nat/idegaweb/bundles/com.idega.block.creditcard.bundle/resources/demoFolder/testkeys.jks";
   * String keystorePass = "******";
   *
   * KortathjonustanCreditCardClient client = new
   * KortathjonustanCreditCardClient(IWContext.getInstance(), host, port,
   * keystore, keystorePass, SITE, USER, PASSWORD, ACCEPTOR_TERM_ID,
   * ACCEPTOR_IDENTIFICATION); try { String tmp = client.doSale("Gr�mur Steri",
   * strCCNumber, strCCExpire.substring(2, 4), strCCExpire.substring(0, 2),
   * strCCVerify, 1, "ISK", strReferenceNumber );
   *
   * //CreditCardBusiness cBus = (CreditCardBusiness)
   * IBOLookup.getServiceInstance(IWContext.getInstance(),
   * CreditCardBusiness.class); //KortathjonustanAuthorisationEntries entry =
   * (KortathjonustanAuthorisationEntries) cBus.getAuthorizationEntry(supp,
   * tmp);
   *
   *
   * //String tmp2 = client.doRefund(strCCNumber, strCCExpire.substring(2, 4),
   * strCCExpire.substring(0, 2), strCCVerify, 1, "ISK",
   * entry.getResponseString()); System.out.println("AuthorizationNumber =
   * "+tmp); //System.out.println("RefundAuthNumber = "+tmp2); } catch
   * (CreditCardAuthorizationException e) { System.out.println(" ---- Exception
   * ----"); System.out.println("DisplayText = "+e.getDisplayError());
   * System.out.println("ErrorText = "+e.getErrorMessage());
   * System.out.println("ErrorNum = "+e.getErrorNumber()); System.out.println("
   * -----------------------"); e.printStackTrace(System.err); }
   *  }
   *
   */
  private Hashtable doRefund(int iAmountToRefund, Hashtable captureProperties, Object parentDataPK)
      throws CreditCardAuthorizationException {
    // TODO tjekka ef amountToRefund er sama og upphaflega refundi� ...
    // System.out.println(" ------ REFUND ------");
    Hashtable refundProperties = new Hashtable();
    try {

      int iAmount = 0;
      try {
        iAmount = Integer.parseInt(captureProperties.get(this.PROPERTY_AMOUNT).toString());
        if (iAmountToRefund > iAmount) {
          CreditCardAuthorizationException e =
              new CreditCardAuthorizationException(
                  "Amount to refund can not be higher that the original amount");
          e.setDisplayError("Amount to refund can not be higher that the original amount");
          throw e;
        }
      } catch (NumberFormatException e1) {
        throw new CreditCardAuthorizationException("Amount must be a number");
      }

      StringBuffer strPostData = new StringBuffer();
      // "DEFAULT" PROPERTIES
      appendProperty(strPostData, this.PROPERTY_USER, this.USER);
      appendProperty(strPostData, this.PROPERTY_PASSWORD, this.PASSWORD);
      appendProperty(strPostData, this.PROPERTY_SITE, this.SITE);
      appendProperty(
          strPostData, this.PROPERTY_CURRENT_DATE, getDateString(IWTimestamp.RightNow()));
      // TODO IMPLEMENT
      // appendProperty(strPostData, PROPERTY_MERCHANT_LANGUAGE)
      // appendProperty(strPostData, PROPERTY_CLIENT_LANGUAGE)
      appendProperty(strPostData, this.PROPERTY_AMOUNT_ECHO, this.strAmount);

      appendProperty(strPostData, this.PROPERTY_AMOUNT, Integer.toString(iAmountToRefund));
      if (iAmount > iAmountToRefund) {
        appendProperty(
            strPostData,
            this.PROPERTY_AMOUNT_ECHO,
            captureProperties.get(this.PROPERTY_AMOUNT).toString());
      }
      appendProperty(
          strPostData,
          this.PROPERTY_CURRENCY_EXPONENT,
          captureProperties.get(this.PROPERTY_CURRENCY_EXPONENT).toString());
      appendProperty(
          strPostData,
          this.PROPERTY_REFERENCE_ID,
          captureProperties.get(this.PROPERTY_REFERENCE_ID).toString());
      appendProperty(
          strPostData,
          this.PROPERTY_ACCEPTOR_TERM_ID,
          captureProperties.get(this.PROPERTY_ACCEPTOR_TERM_ID).toString());
      appendProperty(
          strPostData,
          this.PROPERTY_ACCEPTOR_IDENT,
          captureProperties.get(this.PROPERTY_ACCEPTOR_IDENT).toString());
      appendProperty(
          strPostData,
          this.PROPERTY_CURRENCY_CODE,
          captureProperties.get(this.PROPERTY_CURRENCY_CODE).toString());
      appendProperty(
          strPostData,
          this.PROPERTY_ORIGINAL_DATA_ELEMENT,
          captureProperties.get(this.PROPERTY_ORIGINAL_DATA_ELEMENT).toString());
      appendProperty(
          strPostData,
          this.PROPERTY_CURRENT_DATE_ECHO,
          captureProperties.get(this.PROPERTY_CURRENT_DATE).toString());
      appendProperty(
          strPostData,
          this.PROPERTY_ACTION_CODE_ECHO,
          captureProperties.get(this.PROPERTY_ACTION_CODE).toString());
      appendProperty(
          strPostData,
          this.PROPERTY_APPROVAL_CODE_ECHO,
          captureProperties.get(this.PROPERTY_APPROVAL_CODE).toString());

      String strResponse = null;

      SSLClient client = getSSLClient();
      // System.out.println("Request [" + strPostData.toString() + "]");
      try {
        strResponse = client.sendRequest(REQUEST_TYPE_REVERSAL, strPostData.toString());
      } catch (Exception e) {
        CreditCardAuthorizationException cce = new CreditCardAuthorizationException();
        cce.setDisplayError("Cannot connect to Central Payment Server");
        cce.setErrorMessage("SendRequest failed");
        cce.setErrorNumber("-");
        cce.setParentException(e);
        throw cce;
      }
      //      System.out.println("Response [" + strResponse + "]");
      if (strResponse == null) {
        CreditCardAuthorizationException cce = new CreditCardAuthorizationException();
        cce.setDisplayError("Cannot connect to Central Payment Server");
        cce.setErrorMessage("SendRequest returned null");
        cce.setErrorNumber("-");
        throw cce;
      } else if (!strResponse.startsWith(this.PROPERTY_ACTION_CODE)) {
        CreditCardAuthorizationException cce = new CreditCardAuthorizationException();
        cce.setDisplayError("Cannot connect to Central Payment Server");
        cce.setErrorMessage(
            "Invalid response from host, should start with d39 [" + strResponse + "]");
        cce.setErrorNumber("-");
        throw cce;
      } else {
        refundProperties = parseResponse(strResponse);
        if (CODE_AUTHORIZATOIN_APPROVED.equals(refundProperties.get(this.PROPERTY_ACTION_CODE))) {
          return refundProperties;
        } else {
          CreditCardAuthorizationException cce = new CreditCardAuthorizationException();
          cce.setDisplayError(refundProperties.get(this.PROPERTY_ACTION_CODE_TEXT).toString());
          cce.setErrorMessage(refundProperties.get(this.PROPERTY_ERROR_TEXT).toString());
          cce.setErrorNumber(refundProperties.get(this.PROPERTY_ACTION_CODE).toString());
          throw cce;
        }
      }

    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }

    return refundProperties;
  }
コード例 #21
0
  private void addMenuElementsToDropdowns() {
    IWTimestamp stamp = IWTimestamp.RightNow();
    int currentYear = stamp.getYear();

    if (this.showYear) {
      this.setYearRange(currentYear, currentYear + 5);
    }

    if (this.showNullValue) {
      this.theMonth.addMenuElement("00");
    }
    this.theMonth.addMenuElement("01");
    this.theMonth.addMenuElement("02");
    this.theMonth.addMenuElement("03");
    this.theMonth.addMenuElement("04");
    this.theMonth.addMenuElement("05");
    this.theMonth.addMenuElement("06");
    this.theMonth.addMenuElement("07");
    this.theMonth.addMenuElement("08");
    this.theMonth.addMenuElement("09");
    this.theMonth.addMenuElement("10");
    this.theMonth.addMenuElement("11");
    this.theMonth.addMenuElement("12");

    if (this.showNullValue) {
      this.theDay.addMenuElement("00", "D");
    }
    this.theDay.addMenuElement("01", "1");
    this.theDay.addMenuElement("02", "2");
    this.theDay.addMenuElement("03", "3");
    this.theDay.addMenuElement("04", "4");
    this.theDay.addMenuElement("05", "5");
    this.theDay.addMenuElement("06", "6");
    this.theDay.addMenuElement("07", "7");
    this.theDay.addMenuElement("08", "8");
    this.theDay.addMenuElement("09", "9");
    this.theDay.addMenuElement("10", "10");
    this.theDay.addMenuElement("11", "11");
    this.theDay.addMenuElement("12", "12");
    this.theDay.addMenuElement("13", "13");
    this.theDay.addMenuElement("14", "14");
    this.theDay.addMenuElement("15", "15");
    this.theDay.addMenuElement("16", "16");
    this.theDay.addMenuElement("17", "17");
    this.theDay.addMenuElement("18", "18");
    this.theDay.addMenuElement("19", "19");
    this.theDay.addMenuElement("20", "20");
    this.theDay.addMenuElement("21", "21");
    this.theDay.addMenuElement("22", "22");
    this.theDay.addMenuElement("23", "23");
    this.theDay.addMenuElement("24", "24");
    this.theDay.addMenuElement("25", "25");
    this.theDay.addMenuElement("26", "26");
    this.theDay.addMenuElement("27", "27");
    this.theDay.addMenuElement("28", "28");
    this.theDay.addMenuElement("29", "29");
    this.theDay.addMenuElement("30", "30");
    this.theDay.addMenuElement("31", "31");

    if (this.showYear && this.showNullValue) {
      this.theYear.addMenuElement("YY");
    }
  }