Esempio n. 1
0
  public static boolean call(PageContext pc, Object obj, boolean addNewLine, boolean doErrorStream)
      throws PageException {
    String string;
    if (Decision.isSimpleValue(obj)) string = Caster.toString(obj);
    else {
      try {
        string = Serialize.call(pc, obj);
      } catch (Throwable t) {
        string = obj.toString();
      }
    }
    PrintStream stream = System.out;
    // string+=":"+Thread.currentThread().getId();
    if (doErrorStream) stream = System.err;
    if (string != null) {
      if (StringUtil.indexOfIgnoreCase(string, "<print-stack-trace>") != -1) {
        String st = ExceptionUtil.getStacktrace(new Exception("Stack trace"), false);
        string = StringUtil.replace(string, "<print-stack-trace>", "\n" + st + "\n", true).trim();
      }
      if (StringUtil.indexOfIgnoreCase(string, "<hash-code>") != -1) {
        String st = obj.hashCode() + "";
        string = StringUtil.replace(string, "<hash-code>", st, true).trim();
      }
    }
    if (addNewLine) stream.println(string);
    else stream.print(string);

    return true;
  }
Esempio n. 2
0
  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);

    PDFDocument doc = toPDFDocument(source, password, null);
    doc.setPages(pages);
    PdfReader reader = doc.getPdfReader();

    boolean destIsSource =
        destination != null && doc.getResource() != null && destination.equals(doc.getResource());
    java.util.List bookmarks = SimpleBookmark.getBookmark(reader);
    ArrayList master = new ArrayList();
    if (bookmarks != null) master.addAll(bookmarks);

    // output
    OutputStream os = null;
    if (!StringUtil.isEmpty(name) || destIsSource) {
      os = new ByteArrayOutputStream();
    } else if (destination != null) {
      os = destination.getOutputStream();
    }

    try {
      int len = reader.getNumberOfPages();
      PdfStamper stamp = new PdfStamper(reader, os);

      Set _pages = doc.getPages();
      for (int i = 1; i <= len; i++) {
        if (_pages != null && !_pages.contains(Integer.valueOf(i))) continue;
        PdfContentByte cb = foreground ? stamp.getOverContent(i) : stamp.getUnderContent(i);
        PdfGState gs1 = new PdfGState();
        gs1.setFillOpacity(0);
        cb.setGState(gs1);
        cb.addImage(img);
      }
      if (bookmarks != null) stamp.setOutlines(master);
      stamp.close();
    } finally {
      IOUtil.closeEL(os);
      if (os instanceof ByteArrayOutputStream) {
        if (destination != null)
          IOUtil.copy(
              new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray()),
              destination,
              true); // MUST overwrite
        if (!StringUtil.isEmpty(name)) {
          pageContext.setVariable(
              name, new PDFDocument(((ByteArrayOutputStream) os).toByteArray(), password));
        }
      }
    }
  }
Esempio n. 3
0
 private void set(SQLException sqle, String detail) {
   String sqleMessage = sqle != null ? sqle.getMessage() : "";
   if (detail != null) {
     if (!StringUtil.isEmpty(sqleMessage)) setDetail(detail + "\n" + sqleMessage);
     else setDetail(detail);
   } else {
     if (!StringUtil.isEmpty(sqleMessage)) setDetail(sqleMessage);
   }
 }
Esempio n. 4
0
  /**
   * @param title
   * @param key
   * @param content
   * @param custom1
   * @param custom2
   * @param custom3
   * @param custom4
   * @return Document
   */
  public static Document getDocument(
      String title,
      String key,
      String content,
      String urlpath,
      String custom1,
      String custom2,
      String custom3,
      String custom4) {

    // make a new, empty document
    Document doc = new Document();
    doc.add(FieldUtil.UnIndexed("size", Caster.toString(content.length())));

    doc.add(FieldUtil.Text("key", key));
    FieldUtil.setMimeType(doc, "text/plain");
    FieldUtil.setRaw(doc, content);
    FieldUtil.setContent(doc, content);
    FieldUtil.setSummary(doc, StringUtil.max(content, SUMMERY_SIZE), false);

    FieldUtil.setTitle(doc, title);
    FieldUtil.setURL(doc, urlpath);
    FieldUtil.setCustom(doc, custom1, 1);
    FieldUtil.setCustom(doc, custom2, 2);
    FieldUtil.setCustom(doc, custom3, 3);
    FieldUtil.setCustom(doc, custom4, 4);
    return doc;
  }
Esempio n. 5
0
  public static void sendDispositionHeader(
      String name, String filename, String headerCharset, OutputStream out) throws IOException {
    out.write(CONTENT_DISPOSITION_BYTES);
    out.write(QUOTE_BYTES);
    if (StringUtil.isAscci(name)) out.write(EncodingUtil.getAsciiBytes(name));
    else out.write(name.getBytes(headerCharset));
    out.write(QUOTE_BYTES);

    if (filename != null) {
      out.write(FILE_NAME_BYTES);
      out.write(QUOTE_BYTES);
      if (StringUtil.isAscci(filename)) out.write(EncodingUtil.getAsciiBytes(filename));
      else out.write(filename.getBytes(headerCharset));
      out.write(QUOTE_BYTES);
    }
  }
  public ByteArrayHttpEntity(byte[] barr, String contentType) {
    super(barr);
    contentLength = barr == null ? 0 : barr.length;

    if (StringUtil.isEmpty(contentType, true)) {
      Header h = getContentType();
      if (h != null) strContentType = h.getValue();
    } else this.strContentType = contentType;
  }
  private boolean isValid(Config config, String serverPassword) {
    if (StringUtil.isEmpty(serverPassword, true)) {
      try {
        PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();
        serverPassword = pc.getServerPassword();
      } catch (Throwable t) {
      }
    }
    config = ThreadLocalPageContext.getConfig(config);

    if (config == null || StringUtil.isEmpty(serverPassword, true)) return false;
    try {
      config.getConfigServer(serverPassword);
      return true;
    } catch (PageException e) {
      return false;
    }
  }
Esempio n. 8
0
  private void doActionSetInfo() throws PageException, IOException, DocumentException {
    required("pdf", "setInfo", "info", info);
    required("pdf", "getInfo", "source", source);

    PDFDocument doc = toPDFDocument(source, password, null);
    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();
      for (int i = 0; i < keys.length; i++) {
        moreInfo.put(
            StringUtil.ucFirst(keys[i].getLowerString()), Caster.toString(info.get(keys[i])));
      }
      // author
      Object value = info.get("author", null);
      if (value != null) moreInfo.put("Author", Caster.toString(value));
      // keywords
      value = info.get("keywords", null);
      if (value != null) moreInfo.put("Keywords", Caster.toString(value));
      // title
      value = info.get("title", null);
      if (value != null) moreInfo.put("Title", Caster.toString(value));
      // subject
      value = info.get("subject", null);
      if (value != null) moreInfo.put("Subject", Caster.toString(value));
      // creator
      value = info.get("creator", null);
      if (value != null) moreInfo.put("Creator", Caster.toString(value));
      // trapped
      value = info.get("Trapped", null);
      if (value != null) moreInfo.put("Trapped", Caster.toString(value));
      // Created
      value = info.get("Created", null);
      if (value != null) moreInfo.put("Created", Caster.toString(value));
      // Language
      value = info.get("Language", null);
      if (value != null) moreInfo.put("Language", Caster.toString(value));

      stamp.setMoreInfo(moreInfo);
      stamp.close();

    } finally {
      IOUtil.closeEL(os);
      pr.close();
    }
  }
Esempio n. 9
0
  /**
   * Constructor of the class
   *
   * @param sqle
   */
  @Override
  public CatchBlock getCatchBlock(Config config) {
    String strSQL = sql == null ? "" : sql.toString();
    if (StringUtil.isEmpty(strSQL)) strSQL = Caster.toString(getAdditional().get("SQL", ""), "");

    String datasourceName = datasource == null ? "" : datasource.getName();
    if (StringUtil.isEmpty(datasourceName))
      datasourceName = Caster.toString(getAdditional().get("DataSource", ""), "");

    CatchBlock sct = super.getCatchBlock(config);
    sct.setEL("NativeErrorCode", new Double(errorcode));
    sct.setEL("DataSource", datasourceName);
    sct.setEL("SQLState", sqlstate);
    sct.setEL("Sql", strSQL);
    sct.setEL("queryError", strSQL);
    sct.setEL("where", "");
    return sct;
  }
Esempio n. 10
0
  private void doActionDeletePages() throws PageException, IOException, DocumentException {
    required("pdf", "deletePage", "pages", pages, true);
    required("pdf", "deletePage", "source", source);

    PDFDocument doc = toPDFDocument(source, password, null);
    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;
    if (!StringUtil.isEmpty(name) || destIsSource) {
      os = new ByteArrayOutputStream();
    } else if (destination != null) {
      os = destination.getOutputStream();
    }

    try {
      PDFUtil.concat(new PDFDocument[] {doc}, os, true, true, true, version);
    } finally {
      // if(document!=null)document.close();
      IOUtil.closeEL(os);
      if (os instanceof ByteArrayOutputStream) {
        if (destination != null)
          IOUtil.copy(
              new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray()),
              destination,
              true); // MUST overwrite
        if (!StringUtil.isEmpty(name)) {
          pageContext.setVariable(
              name, new PDFDocument(((ByteArrayOutputStream) os).toByteArray(), password));
        }
      }
    }
  }
Esempio n. 11
0
 @Override
 public String getParent() {
   if (StringUtil.isEmpty(parent)) return null;
   return provider
       .getScheme()
       .concat("://")
       .concat(zip.getCompressFile().getPath())
       .concat("!")
       .concat(parent);
 }
Esempio n. 12
0
  public Component getEntityByCFCName(String cfcName, boolean unique) throws PageException {
    String name = cfcName;
    int pointIndex = cfcName.lastIndexOf('.');
    if (pointIndex != -1) {
      name = cfcName.substring(pointIndex + 1);
    } else cfcName = null;

    ComponentPro cfc;
    String[] names = null;
    // search array (array exist when cfcs is in generation)

    if (arr != null) {
      names = new String[arr.size()];
      int index = 0;
      Iterator<ComponentPro> it2 = arr.iterator();
      while (it2.hasNext()) {
        cfc = it2.next();
        names[index++] = cfc.getName();
        if (isEntity(cfc, cfcName, name)) // if(cfc.equalTo(name))
        return unique ? (Component) cfc.duplicate(false) : cfc;
      }
    } else {
      // search cfcs
      Iterator<Entry<String, CFCInfo>> it = cfcs.entrySet().iterator();
      Entry<String, CFCInfo> entry;
      while (it.hasNext()) {
        entry = it.next();
        cfc = entry.getValue().getCFC();
        if (isEntity(cfc, cfcName, name)) // if(cfc.instanceOf(name))
        return unique ? (Component) cfc.duplicate(false) : cfc;

        // if(name.equalsIgnoreCase(HibernateCaster.getEntityName(cfc)))
        //	return cfc;
      }
      names = cfcs.keySet().toArray(new String[cfcs.size()]);
    }

    // search by entityname //TODO is this ok?
    CFCInfo info = cfcs.get(name.toLowerCase());
    if (info != null) {
      cfc = info.getCFC();
      return unique ? (Component) cfc.duplicate(false) : cfc;
    }

    throw new ORMException(
        this,
        "entity ["
            + name
            + "] "
            + (StringUtil.isEmpty(cfcName) ? "" : "with cfc name [" + cfcName + "] ")
            + "does not exist, existing  entities are ["
            + railo.runtime.type.List.arrayToList(names, ", ")
            + "]");
  }
Esempio n. 13
0
 /**
  * @param order the order to set
  * @throws ApplicationException
  */
 public void setOrder(String strOrder) throws ApplicationException {
   strOrder = StringUtil.toLowerCase(strOrder.trim());
   if ("name".equals(strOrder)) order = ORDER_NAME;
   else if ("time".equals(strOrder)) order = ORDER_TIME;
   else
     throw new ApplicationException(
         "invalid order definition ["
             + strOrder
             + "], valid order definitions are "
             + "[name,time]");
 }
Esempio n. 14
0
 /**
  * @param resolution the resolution to set
  * @throws ApplicationException
  */
 public void setResolution(String strResolution) throws ApplicationException {
   strResolution = StringUtil.toLowerCase(strResolution.trim());
   if ("low".equals(strResolution)) resolution = RESOLUTION_LOW;
   else if ("high".equals(strResolution)) resolution = RESOLUTION_HIGH;
   else
     throw new ApplicationException(
         "invalid resolution definition ["
             + strResolution
             + "], valid resolution definitions are "
             + "[low,high]");
 }
Esempio n. 15
0
  /**
   * returns if a value of the list contains given value, case sensitive
   *
   * @param list list to search in
   * @param value value to serach
   * @param delimeter delimeter of the list
   * @return position in list or 0
   */
  public static int listContains(String list, String value, String delimeter) {
    if (StringUtil.isEmpty(value)) return -1;

    Array arr = listToArray(list, delimeter);
    int len = arr.size();

    for (int i = 1; i <= len; i++) {
      if (arr.get(1, "").toString().indexOf(value) != -1) return i;
    }
    return -1;
  }
Esempio n. 16
0
  private static boolean validExtension(String[] extensions, String file) {

    String ext = ResourceUtil.getExtension(file, "");
    ext = railo.runtime.type.util.ListUtil.first(ext, "/", true);

    if (StringUtil.isEmpty(ext)) return true;
    for (int i = 0; i < extensions.length; i++) {
      if (ext.equalsIgnoreCase(extensions[i])) return true;
    }
    return false;
  }
Esempio n. 17
0
 /**
  * @param saveOption the saveOption to set
  * @throws ApplicationException
  */
 public void setSaveoption(String strSaveOption) throws ApplicationException {
   strSaveOption = StringUtil.toLowerCase(strSaveOption.trim());
   if ("full".equals(strSaveOption)) saveOption = SAVE_OPTION_FULL;
   else if ("incremental".equals(strSaveOption)) saveOption = SAVE_OPTION_INCREMENTAL;
   else if ("linear".equals(strSaveOption)) saveOption = SAVE_OPTION_LINEAR;
   else
     throw new ApplicationException(
         "invalid saveOption definition ["
             + strSaveOption
             + "], valid saveOption definitions are "
             + "[full,linear,incremental]");
 }
Esempio n. 18
0
  private PageContextImpl createPageContext(
      CFMLFactory factory,
      ComponentAccess app,
      String applicationName,
      String cfid,
      Collection.Key methodName)
      throws PageException {
    Resource root = factory.getConfig().getRootDirectory();
    String path = app.getPageSource().getFullRealpath();

    // Request
    HttpServletRequestDummy req =
        new HttpServletRequestDummy(root, "localhost", path, "", null, null, null, null, null);
    if (!StringUtil.isEmpty(cfid))
      req.setCookies(new Cookie[] {new Cookie("cfid", cfid), new Cookie("cftoken", "0")});

    // Response
    OutputStream os = DevNullOutputStream.DEV_NULL_OUTPUT_STREAM;
    try {
      Resource out =
          factory
              .getConfig()
              .getConfigDir()
              .getRealResource("output/" + methodName.getString() + ".out");
      out.getParentResource().mkdirs();
      os = out.getOutputStream(false);
    } catch (IOException e) {
      e.printStackTrace();
      // TODO was passiert hier
    }
    HttpServletResponseDummy rsp = new HttpServletResponseDummy(os);

    // PageContext
    PageContextImpl pc =
        (PageContextImpl)
            factory.getRailoPageContext(factory.getServlet(), req, rsp, null, false, -1, false);
    // ApplicationContext
    ClassicApplicationContext ap =
        new ClassicApplicationContext(
            factory.getConfig(),
            applicationName,
            false,
            app == null ? null : ResourceUtil.getResource(pc, app.getPageSource(), null));
    initApplicationContext(pc, app);
    ap.setName(applicationName);
    ap.setSetSessionManagement(true);
    // if(!ap.hasName())ap.setName("Controler")
    // Base
    pc.setBase(app.getPageSource());

    return pc;
  }
Esempio n. 19
0
  /**
   * returns if a value of the list contains given value, case sensitive, ignore empty positions
   *
   * @param list list to search in
   * @param value value to serach
   * @param delimeter delimeter of the list
   * @return position in list or 0
   */
  public static int listContainsIgnoreEmpty(String list, String value, String delimeter) {
    if (StringUtil.isEmpty(value)) return -1;
    Array arr = listToArrayRemoveEmpty(list, delimeter);
    int count = 0;
    int len = arr.size();

    for (int i = 1; i <= len; i++) {
      String item = arr.get(i, "").toString();
      if (item.indexOf(value) != -1) return count;
      count++;
    }
    return -1;
  }
Esempio n. 20
0
  public Query execute(PageContext pc, SQL sql, String prettySQL, int maxrows)
      throws PageException {
    if (StringUtil.isEmpty(prettySQL)) prettySQL = SQLPrettyfier.prettyfie(sql.getSQLString());

    ZqlParser parser = new ZqlParser(new ByteArrayInputStream(prettySQL.getBytes()));
    Vector statements;
    try {
      statements = parser.readStatements();
    } catch (Throwable t) {
      throw Caster.toPageException(t);
    }
    return execute(statements, pc, sql, maxrows);
  }
Esempio n. 21
0
 public static String getType(Property prop) {
   String type = prop.getType();
   if (StringUtil.isEmpty(type)
       || "any".equalsIgnoreCase(type)
       || "object".equalsIgnoreCase(type)) {
     String fieldType = Caster.toString(prop.getMeta().get(FIELD_TYPE, null), null);
     if ("one-to-many".equalsIgnoreCase(fieldType) || "many-to-many".equalsIgnoreCase(fieldType)) {
       return "array";
     }
     return "any";
   }
   return type;
 }
Esempio n. 22
0
  protected void _init(PageContext pc, Map<String, String> arguments) {
    this.pc = pc;

    // header
    HttpServletRequest req = pc.getHttpServletRequest();

    header = new StringBuffer();
    createHeader(header, "context-path", req.getContextPath());
    createHeader(header, "remote-user", req.getRemoteUser());
    createHeader(header, "remote-addr", req.getRemoteAddr());
    createHeader(header, "remote-host", req.getRemoteHost());
    createHeader(
        header,
        "script-name",
        StringUtil.emptyIfNull(req.getContextPath())
            + StringUtil.emptyIfNull(req.getServletPath()));
    createHeader(header, "server-name", req.getServerName());
    createHeader(header, "protocol", req.getProtocol());
    createHeader(header, "server-port", Caster.toString(req.getServerPort()));
    createHeader(
        header,
        "path-info",
        StringUtil.replace(
            StringUtil.emptyIfNull(req.getRequestURI()),
            StringUtil.emptyIfNull(req.getServletPath()),
            "",
            true));
    // createHeader(header,"path-translated",pc.getBasePageSource().getDisplayPath());
    createHeader(header, "query-string", req.getQueryString());
    createHeader(header, "unit", unitShortToString(unit));
    createHeader(header, "min-time-nano", min + "");

    content = new StringBuffer();

    // directory
    String strDirectory = arguments.get("directory");
    if (dir == null) {
      if (StringUtil.isEmpty(strDirectory)) {
        dir = getTemp(pc);
      } else {
        try {
          dir = ResourceUtil.toResourceNotExisting(pc, strDirectory, false);
          if (!dir.exists()) {
            dir.createDirectory(true);
          } else if (dir.isFile()) {
            err(
                pc,
                "can not create directory [" + dir + "], there is already a file with same name.");
          }
        } catch (Throwable t) {
          err(pc, t);
          dir = getTemp(pc);
        }
      }
    }
    file = dir.getRealResource((pc.getId()) + "-" + CreateUUID.call(pc) + ".exl");
    file.createNewFile();
    start = System.currentTimeMillis();
  }
Esempio n. 23
0
 private void loadNamingStrategy(ORMConfiguration ormConf) throws PageException {
   String strNamingStrategy = ormConf.namingStrategy();
   if (StringUtil.isEmpty(strNamingStrategy, true)) {
     namingStrategy = DefaultNamingStrategy.INSTANCE;
   } else {
     strNamingStrategy = strNamingStrategy.trim();
     if ("default".equalsIgnoreCase(strNamingStrategy))
       namingStrategy = DefaultNamingStrategy.INSTANCE;
     else if ("smart".equalsIgnoreCase(strNamingStrategy))
       namingStrategy = SmartNamingStrategy.INSTANCE;
     else namingStrategy = new CFCNamingStrategy(strNamingStrategy);
   }
 }
Esempio n. 24
0
  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;
    if (destIsSource) {
      os = new ByteArrayOutputStream();
    } else {
      os = destination.getOutputStream();
    }

    try {
      PDFUtil.encrypt(doc, os, newUserPassword, newOwnerPassword, permissions, encrypt);
    } finally {
      IOUtil.closeEL(os);
      if (os instanceof ByteArrayOutputStream) {
        IOUtil.copy(
            new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray()),
            destination,
            true); // MUST overwrite
      }
    }
  }
Esempio n. 25
0
  private static void addEventListeners(
      PageContext pc, Configuration config, ORMConfiguration ormConfig, Map<String, CFCInfo> cfcs)
      throws PageException {
    if (!ormConfig.eventHandling()) return;
    String eventHandler = ormConfig.eventHandler();
    AllEventListener listener = null;
    if (!StringUtil.isEmpty(eventHandler, true)) {
      // try {
      Component c = pc.loadComponent(eventHandler.trim());

      listener = new AllEventListener(c);
      // config.setInterceptor(listener);
      // }catch (PageException e) {e.printStackTrace();}
    }
    config.setInterceptor(new InterceptorImpl(listener));
    EventListeners listeners = config.getEventListeners();

    // post delete
    List<EventListener> list = merge(listener, cfcs, EventListener.POST_DELETE);
    listeners.setPostDeleteEventListeners(list.toArray(new PostDeleteEventListener[list.size()]));

    // post insert
    list = merge(listener, cfcs, EventListener.POST_INSERT);
    listeners.setPostInsertEventListeners(list.toArray(new PostInsertEventListener[list.size()]));

    // post update
    list = merge(listener, cfcs, EventListener.POST_UPDATE);
    listeners.setPostUpdateEventListeners(list.toArray(new PostUpdateEventListener[list.size()]));

    // post load
    list = merge(listener, cfcs, EventListener.POST_LOAD);
    listeners.setPostLoadEventListeners(list.toArray(new PostLoadEventListener[list.size()]));

    // pre delete
    list = merge(listener, cfcs, EventListener.PRE_DELETE);
    listeners.setPreDeleteEventListeners(list.toArray(new PreDeleteEventListener[list.size()]));

    // pre insert
    // list=merge(listener,cfcs,EventListener.PRE_INSERT);
    // listeners.setPreInsertEventListeners(list.toArray(new PreInsertEventListener[list.size()]));

    // pre load
    list = merge(listener, cfcs, EventListener.PRE_LOAD);
    listeners.setPreLoadEventListeners(list.toArray(new PreLoadEventListener[list.size()]));

    // pre update
    // list=merge(listener,cfcs,EventListener.PRE_UPDATE);
    // listeners.setPreUpdateEventListeners(list.toArray(new PreUpdateEventListener[list.size()]));
  }
Esempio n. 26
0
 /**
  * @param format the format to set
  * @throws ApplicationException
  */
 public void setFormat(String strFormat) throws ApplicationException {
   strFormat = StringUtil.toLowerCase(strFormat.trim());
   if ("jpg".equals(strFormat)) format = FORMAT_JPG;
   else if ("jpeg".equals(strFormat)) format = FORMAT_JPG;
   else if ("jpe".equals(strFormat)) format = FORMAT_JPG;
   else if ("tiff".equals(strFormat)) format = FORMAT_TIFF;
   else if ("tif".equals(strFormat)) format = FORMAT_TIFF;
   else if ("png".equals(strFormat)) format = FORMAT_PNG;
   else
     throw new ApplicationException(
         "invalid format definition ["
             + strFormat
             + "], valid format definitions are "
             + "[jpg,tiff,png]");
 }
Esempio n. 27
0
  private boolean isEntity(ComponentPro cfc, String cfcName, String name) {
    if (!StringUtil.isEmpty(cfcName)) {
      if (cfc.equalTo(cfcName)) return true;

      if (cfcName.indexOf('.') != -1) {
        String path = cfcName.replace('.', '/') + ".cfc";
        Resource[] locations = ormConf.getCfcLocations();
        for (int i = 0; i < locations.length; i++) {
          if (locations[i].getRealResource(path).equals(cfc.getPageSource().getFile())) return true;
        }
        return false;
      }
    }

    if (cfc.equalTo(name)) return true;
    return name.equalsIgnoreCase(HibernateCaster.getEntityName(cfc));
  }
Esempio n. 28
0
  private static String checkTableValidate(DatabaseMetaData md, String dbName, String tableName) {

    ResultSet tables = null;
    try {
      tables = md.getTables(dbName, null, null, null);
      String name;
      while (tables.next()) {
        name = tables.getString("TABLE_NAME");
        if (name.equalsIgnoreCase(tableName)
            && StringUtil.indexOfIgnoreCase(tables.getString("TABLE_TYPE"), "SYSTEM") == -1)
          return name;
      }
    } catch (Throwable t) {
    } finally {
      DBUtil.closeEL(tables);
    }
    return null;
  }
Esempio n. 29
0
  public static StringList toWordList(String list) {
    if (list.length() == 0) return new StringList();
    int len = list.length();
    int last = 0;
    char c, l = 0;
    StringList rtn = new StringList();

    for (int i = 0; i < len; i++) {
      if (StringUtil.isWhiteSpace(c = list.charAt(i))) {
        rtn.add(list.substring(last, i), l);
        l = c;
        last = i + 1;
      }
    }
    if (last <= len) rtn.add(list.substring(last), l);
    rtn.reset();
    return rtn;
  }
Esempio n. 30
0
  /**
   * Constructor of the class
   *
   * @param provider
   * @param zip
   * @param path
   * @param caseSensitive
   */
  CompressResource(
      CompressResourceProvider provider, Compress zip, String path, boolean caseSensitive) {
    if (StringUtil.isEmpty(path)) path = "/";
    this.provider = provider;
    this.zip = zip;
    this.path = path;

    if ("/".equals(path)) {
      this.parent = null;
      this.name = "";
    } else {
      String[] pn = ResourceUtil.translatePathName(path);
      this.parent = pn[0];
      this.name = pn[1];
    }

    this.caseSensitive = caseSensitive;
  }