Package railo.runtime.exp

Examples of railo.runtime.exp.ApplicationException


   
    doc.setPages(pages);
   
    // scale
    if(scale<1)
      throw new ApplicationException("value of attribute scale ["+scale+"] should be at least 1");
   
    // destination
    if(destination==null)
      destination=ResourceUtil.toResourceNotExisting(pageContext, "thumbnails");
   
View Full Code Here


 
 
  private void doActionAddWatermark() throws PageException, IOException, DocumentException {
    required("pdf", "addWatermark", "source", source);
    if(copyFrom==null && image==null)
      throw new ApplicationException("at least one of the following attributes must be defined " +
          "[copyFrom,image]");
   
    if(destination!=null && destination.exists() && !overwrite)
      throw new ApplicationException("destination file ["+destination+"] already exists");
   
   
    // image
    Image img=null;
    if(image!=null) {
      railo.runtime.img.Image ri = railo.runtime.img.Image.createImage(pageContext,image,false,false,true,null);
      img=Image.getInstance(ri.getBufferedImage(),null,false);
    }
    // copy From
    else {
      byte[] barr;
      try{
        Resource res = Caster.toResource(pageContext, copyFrom, true);
        barr=IOUtil.toBytes(res);
      }
      catch(ExpressionException ee) {
        barr=Caster.toBinary(copyFrom);
      }
      img=Image.getInstance(PDFUtil.toImage(barr, 1).getBufferedImage(),null,false);
     
    }
   
    // position
    float x=UNDEFINED,y=UNDEFINED;
    if(!StringUtil.isEmpty(position)) {
      int index=position.indexOf(',');
      if(index==-1)
        throw new ApplicationException("attribute [position] has an invalid value ["+position+"]," +
            "value should follow one of the following pattern [40,50], [40,] or [,50]");
      String strX = position.substring(0,index).trim();
      String strY = position.substring(index+1).trim();
      if(!StringUtil.isEmpty(strX))x = Caster.toIntValue(strX);
      if(!StringUtil.isEmpty(strY))y = Caster.toIntValue(strY);
View Full Code Here

 
  private void doActionRemoveWatermark() throws PageException, IOException, DocumentException {
    required("pdf", "removeWatermark", "source", source);
   
    if(destination!=null && destination.exists() && !overwrite)
      throw new ApplicationException("destination file ["+destination+"] already exists");
   
    railo.runtime.img.Image ri = new railo.runtime.img.Image(1,1,BufferedImage.TYPE_INT_RGB,Color.BLACK);
    Image img = Image.getInstance(ri.getBufferedImage(),null,false);
    img.setAbsolutePosition(1,1);
   
View Full Code Here

    doc.setPages(pages);
   
   
    if(destination==null && StringUtil.isEmpty(name)){
      if(doc.getResource()==null)
        throw new ApplicationException("source is not based on a resource, destination attribute is required");
      destination=doc.getResource();
    }
    else if(destination!=null && destination.exists() && !overwrite)
      throw new ApplicationException("destination file ["+destination+"] already exists");
   
    boolean destIsSource = destination!=null && doc.getResource()!=null && destination.equals(doc.getResource());
   
    // output
    OutputStream os=null;
View Full Code Here

 
 
  private void doActionMerge() throws ApplicationException, PageException, IOException, DocumentException {
   
    if(source==null && params==null && directory==null)
      throw new ApplicationException("at least one of the following constellation must be defined" +
          " attribute source, attribute directory or cfpdfparam child tags");
    if(destination==null && StringUtil.isEmpty(name,true))
      throw new ApplicationException("at least one of the following attributes must be defined " +
          "[destination,name]");
    if(destination!=null && !overwrite)
      throw new ApplicationException("destination file ["+destination+"] already exists");
   
    ArrayList docs = new ArrayList();
    PDFDocument doc;
    boolean isListing=false;
   
    // source
    if(source!=null) {
      if(Decision.isArray(source)) {
        Array arr = Caster.toArray(source);
        int len = arr.size();
        for(int i=1;i<=len;i++) {
          docs.add(doc=toPDFDocument(arr.getE(i),password,null));
          doc.setPages(pages);
        }
      }
      else if(source instanceof String) {
        String[] sources = ListUtil.toStringArrayTrim(ListUtil.listToArrayRemoveEmpty((String)source, ','));
        for(int i=0;i<sources.length;i++) {
          docs.add(doc=toPDFDocument(sources[i],password,null));
          doc.setPages(pages);
        }
      }
      else docs.add(toPDFDocument(source,password,null));
     
    }
    boolean destIsSource = false;
   
    // params
    if(directory!=null && !directory.isDirectory()) {
      if(!directory.exists())
        throw new ApplicationException("defined attribute directory does not exist");
      throw new ApplicationException("defined attribute directory is not a directory");
    }
    if(params!=null) {
      Iterator it = params.iterator();
      PDFParamBean param;
      while(it.hasNext()) {
        param=(PDFParamBean) it.next();
        docs.add(doc=toPDFDocument(param.getSource(), param.getPassword(),directory));
        doc.setPages(param.getPages());
      }
    }
    else if(directory!=null) {
      isListing=true;
      Resource[] children = ResourceUtil.listResources(directory, filter);
     
      if(ascending) {
        for(int i=children.length-1;i>=0;i--) {
          if(destination!=null && children[i].equals(destination))  destIsSource=true;
          docs.add(doc=toPDFDocument(children[i],password,null));
          doc.setPages(pages);
        }
      }
      else {
        for(int i=0;i<children.length;i++) {
          if(destination!=null && children[i].equals(destination))  destIsSource=true;
          docs.add(doc=toPDFDocument(children[i],password,null));
          doc.setPages(pages);
        }
      }
     
    }
   
    int doclen=docs.size();
    if(doclen==0)
      throw new ApplicationException("you have to define at leat 1 pdf file");
   
    // output
    OutputStream os=null;
    if(!StringUtil.isEmpty(name) || destIsSource){
      os=new ByteArrayOutputStream();
View Full Code Here

 
  private void doActionProtect() throws PageException, IOException, DocumentException {
    required("pdf", "protect", "source", source);
   
    if(StringUtil.isEmpty(newUserPassword) && StringUtil.isEmpty(newOwnerPassword))
      throw new ApplicationException("at least one of the following attributes must be defined [newUserPassword,newOwnerPassword]");
       
   
    PDFDocument doc = toPDFDocument(source,password,null);
   
    if(destination==null){
      destination=doc.getResource();
      if(destination==null)
        throw new ApplicationException("source is not based on a resource, destination file is required");
    }
    else if(destination.exists() && !overwrite)
      throw new ApplicationException("destination file ["+destination+"] already exists");
   
    boolean destIsSource = doc.getResource()!=null && destination.equals(doc.getResource());
   
    // output
    OutputStream os=null;
View Full Code Here

    PdfReader pr = doc.getPdfReader();
    OutputStream os=null;
    try {
      if(destination==null){
        if(doc.getResource()==null)
          throw new ApplicationException("source is not based on a resource, destination file is required");
        destination=doc.getResource();
      }
      else if(destination.exists() && !overwrite)
        throw new ApplicationException("destination file ["+destination+"] already exists");
     
      PdfStamper stamp = new PdfStamper(pr, os=destination.getOutputStream());
      HashMap moreInfo = new HashMap();
           
      //Key[] keys = info.keys();
View Full Code Here

        else if(validate.equals("uuid"))    input.setValidate(VALIDATE_UUID);
        else if(validate.equals("guid"))    input.setValidate(VALIDATE_GUID);
        else if(validate.equals("maxlength"))  input.setValidate(VALIDATE_MAXLENGTH);
        else if(validate.equals("noblanks"))  input.setValidate(VALIDATE_NOBLANKS);
       
        else throw new ApplicationException("attribute validate has an invalid value ["+validate+"]",
                "valid values for attribute validate are [creditcard, date, eurodate, float, integer, regular, social_security_number, telephone, time, zipcode]");
       
    }
View Full Code Here

     * @throws ApplicationException
     */
    public void setDaynames(String listDaynames) throws ApplicationException {
      String[] arr = ListUtil.listToStringArray(listDaynames, ',');
      if(arr.length==7)
        throw new ApplicationException("value of attribute [daynames] must contain a string list with 7 values, now there are "+arr.length+" values");
      this.daynames=arr;
    }
View Full Code Here

     * @param daynames The daynames to set.
     * @throws ApplicationException
     */
    public void setFirstdayofweek(double firstDayOfWeek) throws ApplicationException {
      if(firstDayOfWeek<0 || firstDayOfWeek>6)
        throw new ApplicationException("value of attribute [firstDayOfWeek] must conatin a numeric value between 0-6");
      this.firstDayOfWeek=firstDayOfWeek;
    }
View Full Code Here

TOP

Related Classes of railo.runtime.exp.ApplicationException

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.