Package railo.runtime.exp

Examples of railo.runtime.exp.ApplicationException


 
  public void setAction(String strAction) throws ApplicationException  {
    strAction=strAction.toLowerCase();
        if(strAction.equals("create"))action=ACTION_CREATE;
        else if(strAction.equals("update")) action=ACTION_UPDATE;
        else throw new ApplicationException("invalid action definition ["+strAction+"] for tag application, valid values are [create,update]");
   
  }
View Full Code Here


     */
    public void setLoginstorage(String loginstorage) throws ApplicationException {
        loginstorage=loginstorage.toLowerCase();
        if(loginstorage.equals("session"))this.loginstorage=Scope.SCOPE_SESSION;
        else if(loginstorage.equals("cookie"))this.loginstorage=Scope.SCOPE_COOKIE;
        else throw new ApplicationException("invalid loginStorage definition ["+loginstorage+"] for tag application, valid values are [session,cookie]");
    }
View Full Code Here

    return setAtEL(propertyName,arrCurrentRow.get(pc.getId(),1),value);
  }
 
  @Override
  public boolean wasNull() {
    throw new PageRuntimeException(new ApplicationException("method [wasNull] is not supported"));
  }
View Full Code Here

  }
  public static Object _invoke(String name, Object[] args) throws PageException {
    Key key = Caster.toKey(name);
    Component c=component.get();
    PageContext p=pagecontext.get();
    if(c==null) throw new ApplicationException("missing component");
    if(p==null) throw new ApplicationException("missing pagecontext");
   
    for(int i=0;i<args.length;i++) {
      args[i]=AxisCaster.toRailoType(p,args[i]);
    }
   
View Full Code Here

   
    Query query;
   
    try {
      if(!dc.getDatasource().isStorage())
        throw new ApplicationException("storage usage for this datasource is disabled, you can enable this in the railo administrator.");
      query = executor.select(pc.getConfig(),pc.getCFID(),pc.getApplicationContext().getName(), dc, type,log, true);
    }
    catch (SQLException se) {
      throw Caster.toPageException(se);
    }
View Full Code Here

  private static Cache getCache(Config config, String cacheName) throws PageException {
    try {
      CacheConnection cc = Util.getCacheConnection(config,cacheName);
      if(!cc.isStorage())
        throw new ApplicationException("storage usage for this cache is disabled, you can enable this in the railo administrator.");
      return cc.getInstance(config);
    } catch (IOException e) {
      throw Caster.toPageException(e);
    }
  }
View Full Code Here

      else if(method.equals("delete")) this.method=METHOD_DELETE;
      else if(method.equals("put")) this.method=METHOD_PUT;
      else if(method.equals("trace")) this.method=METHOD_TRACE;
      else if(method.equals("options")) this.method=METHOD_OPTIONS;
      else if(method.equals("patch")) this.method=METHOD_PATCH;
      else throw new ApplicationException("invalid method type ["+(method.toUpperCase())+"], valid types are POST,GET,HEAD,DELETE,PUT,TRACE,OPTIONS,PATCH");
  }
View Full Code Here

    if(StringUtil.isEmpty(strCompression,true)) return;
    Boolean b = Caster.toBoolean(strCompression,null);
   
    if(b!=null) compression=b.booleanValue();
    else if(strCompression.trim().equalsIgnoreCase("none")) compression=false;
      else throw new ApplicationException("invalid value for attribute compression ["+strCompression+"], valid values are: true,false or none");
   
  }
View Full Code Here

            //listQS.add(new BasicNameValuePair(translateEncoding(param.getName(), http.charset),translateEncoding(param.getValueAsString(), http.charset)));
          }
        // Form
          else if(type.equals("formfield") || type.equals("form")) {
            hasForm=true;
            if(this.method==METHOD_GET) throw new ApplicationException("httpparam type formfield can't only be used, when method of the tag http equal post");
            if(post!=null){
              if(doMultiPart)  {
                parts.add(
                  new FormBodyPart(
                    param.getName(),
                    new StringBody(
                        param.getValueAsString(),
                        CharsetUtil.toCharset(charset)
                    )
                  )
                );
              }
              else {
                postParam.add(new BasicNameValuePair(param.getName(),param.getValueAsString()));
              }
            }
            //else if(multi!=null)multi.addParameter(param.getName(),param.getValueAsString());
          }
        // CGI
          else if(type.equals("cgi")) {
            if(param.getEncoded())
              req.addHeader(
                  urlenc(param.getName(),charset),
                  urlenc(param.getValueAsString(),charset));
                    else
                        req.addHeader(param.getName(),param.getValueAsString());
          }
            // Header
                else if(type.startsWith("head")) {
                  if(param.getName().equalsIgnoreCase("content-type")) hasContentType=true;
                 
                  if(param.getName().equalsIgnoreCase("Content-Length")) {}
                  else if(param.getName().equalsIgnoreCase("Accept-Encoding")) {
                    acceptEncoding.append(headerValue(param.getValueAsString()));
                    acceptEncoding.append(", ");
                  }
                  else req.addHeader(param.getName(),headerValue(param.getValueAsString()));
                }
        // Cookie
          else if(type.equals("cookie")) {
            HTTPEngine4Impl.addCookie(client,host,param.getName(),param.getValueAsString(),"/",charset);
          }
        // File
          else if(type.equals("file")) {
            hasForm=true;
            if(this.method==METHOD_GET) throw new ApplicationException("httpparam type file can't only be used, when method of the tag http equal post");
            String strCT = getContentType(param);
            ContentType ct = HTTPUtil.toContentType(strCT,null);
             
            String mt="text/xml";
            if(ct!=null && !StringUtil.isEmpty(ct.getMimeType(),true)) mt=ct.getMimeType();
           
            String cs=charset;
            if(ct!=null && !StringUtil.isEmpty(ct.getCharset(),true)) cs=ct.getCharset();
           
           
            if(doMultiPart) {
              try {
                Resource res = param.getFile();
                parts.add(new FormBodyPart(
                    param.getName(),
                    new ResourceBody(res, mt, res.getName(), cs)
                ));
                //parts.add(new ResourcePart(param.getName(),new ResourcePartSource(param.getFile()),getContentType(param),_charset));
              }
              catch (FileNotFoundException e) {
                throw new ApplicationException("can't upload file, path is invalid",e.getMessage());
              }
            }
          }
        // XML
          else if(type.equals("xml")) {
            ContentType ct = HTTPUtil.toContentType(param.getMimeType(),null);
             
            String mt="text/xml";
            if(ct!=null && !StringUtil.isEmpty(ct.getMimeType(),true)) mt=ct.getMimeType();
           
            String cs=charset;
            if(ct!=null && !StringUtil.isEmpty(ct.getCharset(),true)) cs=ct.getCharset();
           
            hasBody=true;
            hasContentType=true;
            req.addHeader("Content-type", mt+"; charset="+cs);
              if(eem==null)throw new ApplicationException("type xml is only supported for type post and put");
              HTTPEngine4Impl.setBody(eem, param.getValueAsString(),mt,cs);
          }
        // Body
          else if(type.equals("body")) {
            ContentType ct = HTTPUtil.toContentType(param.getMimeType(),null);
             
            String mt=null;
            if(ct!=null && !StringUtil.isEmpty(ct.getMimeType(),true)) mt=ct.getMimeType();
           
            String cs=charset;
            if(ct!=null && !StringUtil.isEmpty(ct.getCharset(),true)) cs=ct.getCharset();
           
           
            hasBody=true;
            if(eem==null)throw new ApplicationException("type body is only supported for type post and put");
            HTTPEngine4Impl.setBody(eem, param.getValue(),mt,cs);
           
          }
                else {
                    throw new ApplicationException("invalid type ["+type+"]");
                }
           
        }
       
        // post params
        if(postParam!=null && postParam.size()>0)
          post.setEntity(new org.apache.http.client.entity.UrlEncodedFormEntity(postParam,charset));
       
        if(compression){
          acceptEncoding.append("gzip");
        }
        else {
          acceptEncoding.append("deflate;q=0");
          req.setHeader("TE", "deflate;q=0");
        }
      req.setHeader("Accept-Encoding",acceptEncoding.toString());
       
       
       
        // multipart
        if(doMultiPart && eem!=null) {
          hasContentType=true;
          boolean doIt=true;
          if(!this.multiPart && parts.size()==1){
            ContentBody body = parts.get(0).getBody();
            if(body instanceof StringBody){
              StringBody sb=(StringBody)body;
              try {
                org.apache.http.entity.ContentType ct=org.apache.http.entity.ContentType.create(sb.getMimeType(),sb.getCharset());
                String str = IOUtil.toString(sb.getReader());
                StringEntity entity = new StringEntity(str,ct);
                eem.setEntity(entity);
               
              } catch (IOException e) {
                throw Caster.toPageException(e);
              }
              doIt=false;
            }
          }
          if(doIt) {
            MultipartEntity mpe = new MultipartEntity(HttpMultipartMode.STRICT);
            Iterator<FormBodyPart> it = parts.iterator();
            while(it.hasNext()) {
              FormBodyPart part = it.next();
              mpe.addPart(part.getName(),part.getBody());
            }
            eem.setEntity(mpe);
          }
            //eem.setRequestEntity(new MultipartRequestEntityFlex(parts.toArray(new Part[parts.size()]), eem.getParams(),http.multiPartType));
        }
       
       
       
        if(hasBody && hasForm)
          throw new ApplicationException("mixing httpparam  type file/formfield and body/XML is not allowed");
     
        if(!hasContentType) {
          if(isBinary) {
            if(hasBody) req.addHeader("Content-type", "application/octet-stream");
            else req.addHeader("Content-type", "application/x-www-form-urlencoded; charset="+charset);
          }
          else {
            if(hasBody)
              req.addHeader("Content-type", "text/html; charset="+charset );
          }
        }
       
       
        // set User Agent
          if(!hasHeaderIgnoreCase(req,"User-Agent"))
            req.setHeader("User-Agent",this.useragent);
       
      // set timeout
        if(this.timeout>0L)HTTPEngine4Impl.setTimeout(params, (int)this.timeout);
       
      // set Username and Password
        if(this.username!=null) {
          if(this.password==null)this.password="";
          if(AUTH_TYPE_NTLM==this.authType) {
            if(StringUtil.isEmpty(this.workStation,true))
                      throw new ApplicationException("attribute workstation is required when authentication type is [NTLM]");
            if(StringUtil.isEmpty(this.domain,true))
                      throw new ApplicationException("attribute domain is required when authentication type is [NTLM]");
             
            HTTPEngine4Impl.setNTCredentials(client, this.username, this.password, this.workStation,this.domain);
          }
          else httpContext=HTTPEngine4Impl.setCredentials(client, httpHost, this.username, this.password,preauth);
        }
View Full Code Here

      multiPartType=multiPartType.trim().toLowerCase();
     
      if("form-data".equals(multiPartType))   this.multiPartType=MULTIPART_FORM_DATA;
      //else if("related".equals(multiPartType))     this.multiPartType=MultipartRequestEntityFlex.MULTIPART_RELATED;
      else
      throw new ApplicationException("invalid value for attribute multiPartType ["+multiPartType+"]",
          "attribute must have one of the following values [form-data]");
     
    }
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.