this.getLogger().trace("EXIT!"); //NOI18N
}
- /**
- * Calculates total amount of all choosen products
- *
- * @param request Request instance
- * @param session Session instance
- * @return Total amount of all choosen products
- * @deprecated Old lost
- */
- @Deprecated
- private int calculateTotalAmount (final ServletRequest request, final HttpSession session) throws ServletException {
- // Trace message
- this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
-
- // Is product and session set?
- if (null == request) {
- // Not set
- throw new NullPointerException("request is null"); //NOI18N
- } else if (null == session) {
- // Not set
- throw new NullPointerException("session is null"); //NOI18N
- }
-
- // Init/declare total price and iterator
- int totalAmount = 0;
- Iterator<Product> iterator = this.getAvailableProductsIterator();
-
- // "Walk" over all products
- while (iterator.hasNext()) {
- // Get next product
- Product product = iterator.next();
-
- // Is this choosen?
- if (this.isProductChoosen(product, request, session)) {
- // Then add ordered amount
- this.getLogger().debug(MessageFormat.format("Counting {0} ...", product.getItemId())); //NOI18N
-
- // Getting amount
- String amount = this.getAmountFromSession(product, session);
-
- // Add it up
- this.getLogger().debug(MessageFormat.format("amount={0}", amount)); //NOI18N
- totalAmount += Integer.valueOf(amount);
- }
- this.getLogger().debug(MessageFormat.format("product={0},totalAmount={1}", product.getItemId(), totalAmount)); //NOI18N
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("totalAmount={0} - EXIT!", totalAmount)); //NOI18N
-
- // Return total price
- return totalAmount;
- }
-
@Override
public void doBootstrap () {
throw new UnsupportedOperationException("Not supported yet."); //NOI18N
throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}
- /**
- * Some "getter" for amount from session
- *
- * @param product Product instance
- * @param session Session instance
- * @return Amount as string
- * @deprecated Old lost code
- */
- @Deprecated
- private String getAmountFromSession (final Product product, final HttpSession session) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
-
- // Is product and session set?
- if (null == product) {
- // Not set
- throw new NullPointerException("product is null"); //NOI18N
- } else if (null == session) {
- // Not set
- throw new NullPointerException("session is null"); //NOI18N
- }
-
- // Get attribute
- Object object = this.getValueFromSession(product, session, HTTP_PARAM_AMOUNT);
-
- // Is the object null?
- if (null == object) {
- // Trace message
- this.getLogger().trace("Returning 0 - EXIT!"); //NOI18N
-
- // Not found
- return "0"; //NOI18N
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("object={0} - EXIT!", object)); //NOI18N
-
- // Cast to string and return it
- return (String) object;
- }
-
- @Override
- public String getCheckedHtmlFromProduct (final Product product, final ServletRequest request, final HttpSession session) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
-
- // Is product and session set?
- if (null == product) {
- // Not set
- throw new NullPointerException("product is null"); //NOI18N
- } else if (null == request) {
- // Not set
- throw new NullPointerException("request is null"); //NOI18N
- } else if (null == session) {
- // Not set
- throw new NullPointerException("session is null"); //NOI18N
- }
-
- // First let's check if the product is choosen
- if (this.isProductChoosen(product, request, session)) {
- // Trace message
- this.getLogger().trace("Returning checked=\"checked\" - EXIT!"); //NOI18N
-
- // Is choosen
- return "checked=\"checked\""; //NOI18N
- } else {
- // Trace message
- this.getLogger().trace("Returning empty string - EXIT!"); //NOI18N
-
- // Not choosen
- return ""; //NOI18N
- }
- }
-
- @Override
- public String getDisabledHtmlFromSession (final ServletRequest request, final HttpSession session) throws ServletException {
- // Trace message
- this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
-
- // Is product and session set?
- if (null == request) {
- // Not set
- throw new NullPointerException("request is null"); //NOI18N
- } else if (null == session) {
- // Not set
- throw new NullPointerException("session is null"); //NOI18N
- }
-
- // Get "enabled" from request scope
- Boolean enabled = Boolean.parseBoolean((String) request.getAttribute("enabled")); //NOI18N
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("enabled={0}", enabled)); //NOI18N
-
- // Is something selected?
- if ((enabled) || (this.calculateTotalAmount(request, session) > 0)) {
- // Trace message
- this.getLogger().trace("Returning empty string - EXIT!"); //NOI18N
-
- // Something has been choosen
- return ""; //NOI18N
- } else {
- // Trace message
- this.getLogger().trace("Returning disabled=\"disabled\" - EXIT!"); //NOI18N
-
- // Nothing choosen yet
- return "disabled=\"disabled\""; //NOI18N
- }
- }
-
@Override
public String getPrintableProduktAvailability (final Product product) {
// Trace message