Package org.pdfsam.console.exceptions.console

Examples of org.pdfsam.console.exceptions.console.ValidationException


   *        number of total pages
   * @throws ValidationException
   */
  public static void assertValidBounds(Bounds bounds, int pdfNumberOfPages) throws ValidationException {
    if (bounds.getStart() <= 0) {
      throw new ValidationException(ValidationException.ERR_NOT_POSITIVE, new String[] { Integer.toString(bounds.getStart()), bounds.toString() });
    } else if (bounds.getEnd() > pdfNumberOfPages) {
      throw new ValidationException(ValidationException.ERR_CANNOT_MERGE, new String[] { Integer.toString(bounds.getEnd()) });
    } else if (bounds.getStart() > bounds.getEnd()) {
      throw new ValidationException(ValidationException.ERR_START_BIGGER_THAN_END, new String[] { Integer.toString(bounds.getStart()),
          Integer.toString(bounds.getEnd()), bounds.toString() });
    }
  }
View Full Code Here


    for (int i = 0; i < bounds.size(); i++) {
      Bounds victim = (Bounds) bounds.get(i);
      for (int j = i + 1; j < bounds.size(); j++) {
        Bounds current = (Bounds) bounds.get(j);
        if (victim.intersects(current)) {
          throw new ValidationException(ValidationException.ERR_BOUNDS_INTERSECTS, new String[] { victim.toString(),
              current.toString() });
        }
      }
    }
  }
View Full Code Here

            if (rotationParams.length == 2) {
              String pageNumber = rotationParams[0].trim();
              int degrees = Integer.parseInt(rotationParams[1]) % 360;
              // must be a multiple of 90
              if ((degrees % 90) != 0) {
                throw new ValidationException(ValidationException.ERR_DEGREES_NOT_ALLOWED, new String[] { Integer.toString(degrees) });
              }
              // rotate all
              if (ALL_STRING.equals(pageNumber)) {
                if (!retVal.isEmpty()) {
                  LOG.warn("Page rotation for every page found, other rotations removed");
                  retVal.clear();
                }
                retVal.add(new PageRotation(PageRotation.NO_PAGE, degrees, PageRotation.ALL_PAGES));
                break;
              } else if (ODD_STRING.equals(pageNumber)) {
                if (!retVal.isEmpty()) {
                  LOG.warn("Page rotation for odd pages found, other rotations removed");
                  retVal.clear();
                }
                retVal.add(new PageRotation(PageRotation.NO_PAGE, degrees, PageRotation.ODD_PAGES));
                break;
              } else if (EVEN_STRING.equals(pageNumber)) {
                if (!retVal.isEmpty()) {
                  LOG.warn("Page rotation for even pages found, other rotations removed");
                  retVal.clear();
                }
                retVal.add(new PageRotation(PageRotation.NO_PAGE, degrees, PageRotation.EVEN_PAGES));
                break;
              } else {
                if (allowSinglePagesRotation) {
                  retVal.add(new PageRotation(Integer.parseInt(pageNumber), degrees));
                }
              }
            } else {
              throw new ValidationException(ValidationException.ERR_PARAM_ROTATION, new String[] { currentRotation });
            }
          } else {
            throw new ValidationException(ValidationException.ERR_PARAM_ROTATION, new String[] { currentRotation });
          }
        }
      }
    } catch (Exception e) {
      throw new ValidationException(ValidationException.ERR_WRONG_ROTATION, e);
    }
    return (PageRotation[]) retVal.toArray(new PageRotation[retVal.size()]);
  }
View Full Code Here

          retVal.setPageNumber(Integer.parseInt(values[0]));
          if (values.length == 3) {
            retVal.setLogicalPageNumber(Integer.parseInt(values[2]));
          }
        } catch (Exception e) {
          throw new ValidationException(ValidationException.ERR_WRONG_PAGE_LABEL, new String[] { inputString }, e);
        }

        // style
        retVal.setStyle(getPageLabelStyle(values[1]));
      } else {
        throw new ValidationException(ValidationException.ERR_WRONG_PAGE_LABEL, new String[] { inputString });
      }
    }
    return retVal;

  }
View Full Code Here

    if (inputString != null && inputString.length() > 0) {
      if (PageLabel.ARABIC.equals(inputString) || PageLabel.EMPTY.equals(inputString) || PageLabel.LLETTER.equals(inputString)
          || PageLabel.LROMAN.equals(inputString) || PageLabel.ULETTER.equals(inputString) || PageLabel.UROMAN.equals(inputString)) {
        retVal = inputString;
      } else {
        throw new ValidationException(ValidationException.ERR_UNK_LABEL_STYLE, new String[] { inputString });
      }
    } else {
      throw new ValidationException(ValidationException.ERR_UNK_LABEL_STYLE, new String[] { inputString });
    }
    return retVal;
  }
View Full Code Here

   * @throws ValidationException
   *         if not a pdf format
   */
  public static void assertValidPdfExtension(final String inputFileName) throws ValidationException {
    if (!((inputFileName.toLowerCase().endsWith(PDF_EXTENSION)) && (inputFileName.length() > PDF_EXTENSION.length()))) {
      throw new ValidationException(ValidationException.ERR_NOT_PDF, new String[] { inputFileName });
    }
  }
View Full Code Here

   * @throws ValidationException
   *         if not a directory
   */
  public static void assertValidDirectory(File inputDir) throws ValidationException {
    if (!inputDir.isDirectory()) {
      throw new ValidationException(ValidationException.ERR_NOT_DIR, new String[] { inputDir.getAbsolutePath() });
    }
  }
View Full Code Here

   * @param selections
   * @throws ValidationException
   */
  public static void assertValidPageSelectionsArray(String[] selections) throws ValidationException {
    if (!isValidPageSelectionsArray(selections)) {
      throw new ValidationException(ValidationException.ERR_ILLEGAL_U);
    }
  }
View Full Code Here

              if(values.length == 2){
                Integer page = null;
                try{
                  page = Integer.valueOf(values[0]);
              }catch(Exception e){
                throw new ValidationException(ValidationException.ERR_NOT_VALID_LABEL_PREFIX, new String[]{currentPrefix}, e);
              }
              Object obj = labels.get(page);
              if(obj != null){
                ((PageLabel)obj).setPrefix(values[1]);
              }else{
                log.warn("Unable to find label starting at page "+page.intValue()+", prefix will be ignored.");
              }
              }else{
                throw new ValidationException(ValidationException.ERR_NOT_VALID_LABEL_PREFIX, new String[]{currentPrefix});
              }
            }
          }
         
          parsedCommandDTO.setLabels((PageLabel[])labels.values().toArray(new PageLabel[labels.size()]));
View Full Code Here

TOP

Related Classes of org.pdfsam.console.exceptions.console.ValidationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.