Examples of FileSystem


Examples of com.knowgate.dfs.FileSystem

          throw new MessagingException (sqle.getMessage(), sqle);
        }
        try {
          File oDir = new File (sFolderDir);
          if (!oDir.exists()) {
            FileSystem oFS = new FileSystem();
            oFS.mkdirs(sFolderUrl);
          }
        } catch (IOException ioe) {
          iOpenMode = 0;
          oConn = null;
          if (DebugFile.trace) DebugFile.decIdent();
View Full Code Here

Examples of com.knowgate.dfs.FileSystem

    if (DebugFile.trace) {
      DebugFile.writeln("Begin MyIncidencesTab.render()");
      DebugFile.incIdent();
    }

    FileSystem oFS = new FileSystem(FileSystem.OS_PUREJAVA);

    String sOutput;
    String sDomainId = req.getProperty("domain");
    String sWorkAreaId = req.getProperty("workarea");
    String sUserId = req.getProperty("user");
    String sZone = req.getProperty("zone");
    String sLang = req.getProperty("language");
    String sTemplatePath = req.getProperty("template");
    String sStorage = req.getProperty("storage");
    String sFileDir = "file://" + sStorage + "domains" + File.separator + sDomainId + File.separator + "workareas" + File.separator + sWorkAreaId + File.separator + "cache" + File.separator + sUserId;
    String sCachedFile = "myincidencestab_" + req.getWindowState().toString() + ".xhtm";

    if (DebugFile.trace) {
      DebugFile.writeln ("user=" + sUserId);
      DebugFile.writeln ("template=" + sTemplatePath);
      DebugFile.writeln ("cache dir=" + sFileDir);
      DebugFile.writeln ("modified=" + req.getAttribute("modified"));
      DebugFile.writeln ("encoding=" + sEncoding);
    }

    Date oDtModified = (Date) req.getAttribute("modified");

    if (null!=oDtModified) {
      try {

        File oCached = new File(sFileDir.substring(7)+File.separator+sCachedFile);

        if (!oCached.exists()) {
          oFS.mkdirs(sFileDir);
        }
        else if (oCached.lastModified()>oDtModified.getTime()) {
          sOutput = new String(oFS.readfile(sFileDir+File.separator+sCachedFile, sEncoding==null ? "ISO8859_1" : sEncoding));

          if (DebugFile.trace) {
            DebugFile.writeln("cache hit " + sFileDir+File.separator+sCachedFile);
            DebugFile.decIdent();
            DebugFile.writeln("End MyIncidencesTab.render()");
          }

          return sOutput;
        }
      }
      catch (Exception xcpt) {
        DebugFile.writeln(xcpt.getClass().getName() + " " + xcpt.getMessage());
      }
    }

    String sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type=\"text/xsl\"?>";

    int iBugs = 0;

    if (req.getWindowState().equals(WindowState.MINIMIZED)) {
      sXML += "<bugs/>";
    }
    else {

      DBBind oDBB = (DBBind) getPortletContext().getAttribute("GlobalDBBind");

      DBSubset oBugs = new DBSubset (DB.k_bugs, DB.gu_bug + "," + DB.tl_bug,
                                     "(" + DB.tx_status + " IS NULL OR " + DB.tx_status + " IN ('EN ESPERA', 'ASIGNADO', 'VERIFICADO')) AND (" + DB.nm_assigned + "=? OR " + DB.tx_rep_mail + " IN (SELECT " + DB.tx_main_email + " FROM " + DB.k_users + " WHERE " + DB.gu_user + "=?)) ORDER BY " + DB.od_priority + " DESC", 10);

      JDCConnection oCon = null;

      try  {
        oCon = oDBB.getConnection("MyIncidencesTab");

        iBugs = oBugs.load (oCon, new Object[]{sUserId,sUserId});

        oCon.close("MyIncidencesTab");
        oCon = null;

        sXML += "<bugs>\n"+oBugs.toXML("","bug")+"</bugs>";
      }
      catch (SQLException e) {
        sXML += "<bugs/>";

        try {
          if (null != oCon)
            if (!oCon.isClosed())
              oCon.close("MyIncidencesTab");
        } catch (SQLException ignore) { }
      }
    }

    try {
       if (DebugFile.trace) DebugFile.writeln("new ByteArrayInputStream(" + String.valueOf(sXML.length()) + ")");

       if (sEncoding==null)
         oInStream = new ByteArrayInputStream(sXML.getBytes());
       else
         oInStream = new ByteArrayInputStream(sXML.getBytes(sEncoding));

       oOutStream = new ByteArrayOutputStream(4000);

       Properties oProps = new Properties();

       Enumeration oKeys = req.getPropertyNames();
       while (oKeys.hasMoreElements()) {
         String sKey = (String) oKeys.nextElement();
         oProps.setProperty(sKey, req.getProperty(sKey));
       } // wend

       if (req.getWindowState().equals(WindowState.MINIMIZED))
         oProps.setProperty("windowstate", "MINIMIZED");
       else
         oProps.setProperty("windowstate", "NORMAL");

       StylesheetCache.transform (sTemplatePath, oInStream, oOutStream, oProps);

       if (sEncoding==null)
         sOutput = oOutStream.toString();
       else
         sOutput = oOutStream.toString("UTF-8");

       oOutStream.close();

       oInStream.close();
       oInStream = null;

       oFS.writefilestr (sFileDir+File.separator+sCachedFile, sOutput, sEncoding==null ? "ISO8859_1" : sEncoding);
     }
     catch (TransformerConfigurationException tce) {
       if (DebugFile.trace) {
         DebugFile.writeln("TransformerConfigurationException " + tce.getMessageAndLocation());
         try {
View Full Code Here

Examples of com.knowgate.dfs.FileSystem

      DebugFile.incIdent();
    }

    final int iMaxRecent = 10;

    FileSystem oFS = new FileSystem(FileSystem.OS_PUREJAVA);

    String sOutput;
    String sDomainId = req.getProperty("domain");
    String sWorkAreaId = req.getProperty("workarea");
    String sUserId = req.getProperty("user");
    String sZone = req.getProperty("zone");
    String sLang = req.getProperty("language");
    String sTemplatePath = req.getProperty("template");
    String sStorage = req.getProperty("storage");
    String sFileDir = "file://" + sStorage + "domains" + File.separator + sDomainId + File.separator + "workareas" + File.separator + sWorkAreaId + File.separator + "cache" + File.separator + sUserId;
    String sCachedFile = "recentpoststab_" + req.getWindowState().toString() + ".xhtm";

    // New for v4.0
    String sOrderBy = req.getProperty("orderby");
    if (null==sOrderBy) sOrderBy = DB.dt_published;
    if (sOrderBy.length()==0) sOrderBy = DB.dt_published;

    if (DebugFile.trace) {
      DebugFile.writeln ("user=" + sUserId);
      DebugFile.writeln ("template=" + sTemplatePath);
      DebugFile.writeln ("cache dir=" + sFileDir);
      DebugFile.writeln ("modified=" + req.getAttribute("modified"));
      DebugFile.writeln ("encoding=" + sEncoding);
    }

    Date oDtModified = (Date) req.getAttribute("modified");

    if (null!=oDtModified) {
      try {

        File oCached = new File(sFileDir.substring(7)+File.separator+sCachedFile);

        if (!oCached.exists()) {
          oFS.mkdirs(sFileDir);
        }
        else if (oCached.lastModified()>oDtModified.getTime()) {
          sOutput = new String(oFS.readfile(sFileDir+File.separator+sCachedFile, sEncoding==null ? "ISO8859_1" : sEncoding));

          if (DebugFile.trace) {
            DebugFile.writeln("cache hit " + sFileDir+File.separator+sCachedFile);
            DebugFile.decIdent();
            DebugFile.writeln("End RecentPosts.render()");
          }

          return sOutput;
        }
      }
      catch (Exception xcpt) {
        DebugFile.writeln(xcpt.getClass().getName() + " " + xcpt.getMessage());
      }
    }

    String sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type=\"text/xsl\"?>";

    int iPosts = 0;

    if (req.getWindowState().equals(WindowState.MINIMIZED)) {
      sXML += "<posts/>";
    }
    else {

      DBBind oDBB = (DBBind) getPortletContext().getAttribute("GlobalDBBind");

      JDCConnection oCon = null;

      try  {
        oCon = oDBB.getConnection("RecentPostsTab");

        DBSubset oPosts = Forums.getTopLevelMessages(oCon,iMaxRecent,sWorkAreaId,Boolean.TRUE, sOrderBy);
        iPosts = oPosts.getRowCount();

        oCon.close("RecentPostsTab");
        oCon = null;

        Date dtPub;
        int iDtPubColPos = oPosts.getColumnPosition(DB.dt_published);
        for (int p=0; p<iPosts; p++) {
          dtPub = oPosts.getDate(iDtPubColPos,p);
          oPosts.setElementAt(Gadgets.leftPad(String.valueOf(dtPub.getMonth()+1),'0',2)+"-"+Gadgets.leftPad(String.valueOf(dtPub.getDate()),'0',2)+" "+Gadgets.leftPad(String.valueOf(dtPub.getHours()),'0',2)+":"+Gadgets.leftPad(String.valueOf(dtPub.getMinutes()),'0',2), 5,p);
        }

        sXML += "<posts>\n"+oPosts.toXML("","newsmsg")+"</posts>";
      }
      catch (SQLException e) {
        sXML += "<posts/>";

        try {
          if (null != oCon)
            if (!oCon.isClosed())
              oCon.close("RecentPostsTab");
        } catch (SQLException ignore) { }
      }
    }

    try {
       if (DebugFile.trace) DebugFile.writeln("new ByteArrayInputStream(" + String.valueOf(sXML.length()) + ")");

       if (sEncoding==null)
         oInStream = new ByteArrayInputStream(sXML.getBytes());
       else
         oInStream = new ByteArrayInputStream(sXML.getBytes(sEncoding));

       oOutStream = new ByteArrayOutputStream(4000);

       Properties oProps = new Properties();

       Enumeration oKeys = req.getPropertyNames();
       while (oKeys.hasMoreElements()) {
         String sKey = (String) oKeys.nextElement();
         oProps.setProperty(sKey, req.getProperty(sKey));
       } // wend

       if (req.getWindowState().equals(WindowState.MINIMIZED))
         oProps.setProperty("windowstate", "MINIMIZED");
       else
         oProps.setProperty("windowstate", "NORMAL");
      
       StylesheetCache.transform (sTemplatePath, oInStream, oOutStream, oProps);

       if (sEncoding==null)
         sOutput = oOutStream.toString();
       else
         sOutput = oOutStream.toString("UTF-8");

       oOutStream.close();

       oInStream.close();
       oInStream = null;

       oFS.writefilestr (sFileDir+File.separator+sCachedFile, sOutput, sEncoding==null ? "ISO8859_1" : sEncoding);
     }
     catch (TransformerConfigurationException tce) {
       if (DebugFile.trace) {
         DebugFile.writeln("TransformerConfigurationException " + tce.getMessageAndLocation());
         try {
View Full Code Here

Examples of com.knowgate.dfs.FileSystem

   * @param oConn Database Connection
   * @throws SQLException
   */
  public boolean delete(JDCConnection oConn) throws SQLException {
    boolean bRetVal;
    FileSystem oFS = new FileSystem();

    if (DebugFile.trace) {
      DebugFile.writeln("Begin ProductLocation.delete(" + getString(DB.gu_location) + ")" );
      DebugFile.incIdent();
    }

    try {
      if (getInt(DB.id_cont_type)==ProductLocation.CONTAINER_FILE || getInt(DB.id_cont_type)==ProductLocation.CONTAINER_FTP) {

        oFS.delete(getURL());
      } // fi(CONTAINER_*)
    }
    catch (IOException ioe) {
      if (ioe.getMessage().indexOf("No such file or directory")<0)
        throw new SQLException(ioe.getMessage());
View Full Code Here

Examples of com.knowgate.dfs.FileSystem

      DebugFile.writeln(")");
    } // fi (trace)
    // ***************************************************
    // Load file with properties about the mail to be sent
    FileSystem oFS = new FileSystem();
    FileInputStream oInStrm = new FileInputStream(oPropsFile);
    Properties oProps = new Properties();
    oProps.load(oInStrm);
   
    System.out.println("Running job "+oProps.getProperty("job"));

    // *************************************************************************
    // Recipients list must be an ASCII encoded file with one recipient per line
   
    String sRecipientsFile = oProps.getProperty("recipients");

    if (null==sRecipientsFile) {
      if (DebugFile.trace) DebugFile.decIdent();
      throw new NullPointerException("Recipients file path is required");
    } else {
      if (DebugFile.trace) DebugFile.writeln("recipients="+sRecipientsFile);
    }

    String sRecipientsList = oFS.readfilestr(sRecipientsFile, "ASCII");
    if (sRecipientsList.length()==0) {
      if (DebugFile.trace) DebugFile.decIdent();
      throw new NullPointerException("Recipients file is empty");
    }

    // ***********************************
    // Load Black List into a sorted array

    String[] aBlackList = null;
    String sBlackListFile = oProps.getProperty("blacklist");
    if (null!=sRecipientsFile) {
      if (sRecipientsFile.trim().length()>0) {
        String sBlackList = oFS.readfilestr(sBlackListFile, "ASCII");
        if (sBlackList.length()>0) {
          aBlackList = Gadgets.split(sBlackList, "\n");
          final int nBlackList = aBlackList.length;
          for (int b=0; b<nBlackList; b++) {
            aBlackList[b] = aBlackList[b].toLowerCase();
          } // next
          Arrays.sort(aBlackList, String.CASE_INSENSITIVE_ORDER);
        }
      } // fi
    } // fi
   
    String aRecipients[] = Gadgets.split(sRecipientsList, "\n");

      System.out.println("total recipients count is "+String.valueOf(aRecipients.length));
    if (DebugFile.trace) DebugFile.writeln("total recipients count is "+String.valueOf(aRecipients.length));

    AdHocMailing oAdHoc = new AdHocMailing();
    if (oProps.getProperty("allow")!=null) oAdHoc.setAllowPattern(oProps.getProperty("allow"));
    if (oProps.getProperty("deny")!=null) oAdHoc.setDenyPattern(oProps.getProperty("deny"));
    oAdHoc.addBlackList (aBlackList );
    oAdHoc.addRecipients(aRecipients);
    aRecipients = oAdHoc.getRecipients();

    System.out.println("unique and allowed recipients count is"+String.valueOf(aRecipients.length));
    if (DebugFile.trace) DebugFile.writeln("unique and allowed recipients count is"+String.valueOf(aRecipients.length));
   
    // ******************
    // Get Mail enconding
   
    String sEncoding = oProps.getProperty("encoding","UTF-8");
   
    // ******************************************************
    // Get base directory where mail source files are located
   
    String sUserDir = oProps.getProperty("userdir",System.getProperty("user.dir"));
   
    // ********************
    // Get mail source HTML
   
    String sTextHtml = null;
    String sHtmlFilePath = oProps.getProperty("texthtml","");
    if (sHtmlFilePath.length()>0) {
      if (!sHtmlFilePath.startsWith(sUserDir)) sHtmlFilePath = sUserDir+sHtmlFilePath;
        sTextHtml = oFS.readfilestr(sHtmlFilePath, sEncoding);
    }

    // **************************
    // Get mail source plain text

    String sTextPlain = null;
    String sTextFilePath = oProps.getProperty("textplain","");
    if (sTextFilePath.length()>0) {
      if (!sTextFilePath.startsWith(sUserDir)) sTextFilePath = sUserDir+sTextFilePath;
    sTextPlain = oFS.readfilestr(sTextFilePath, sEncoding);
    }
       
    // Get mail subject
    String sSubject = oProps.getProperty("subject", "");

View Full Code Here

Examples of com.knowgate.dfs.FileSystem

      DebugFile.incIdent();
    }

    final int iMaxRecent = 10;

    FileSystem oFS = new FileSystem(FileSystem.OS_PUREJAVA);

    String sOutput;
    String sDomainId = req.getProperty("domain");
    String sWorkAreaId = req.getProperty("workarea");
    String sUserId = req.getProperty("user");
    String sNewsGrp = req.getProperty("newsgrp");
    String sZone = req.getProperty("zone");
    String sLang = req.getProperty("language");
    String sTemplatePath = req.getProperty("template");
    String sStorage = req.getProperty("storage");
    String sFileDir = "file://" + sStorage + "domains" + File.separator + sDomainId + File.separator + "workareas" + File.separator + sWorkAreaId + File.separator + "cache" + File.separator + sUserId;
    String sCachedFile = "recentpoststab_" + req.getWindowState().toString() + ".xhtm";

    // New for v4.0
    String sOrderBy = req.getProperty("orderby");
    if (null==sOrderBy) sOrderBy = DB.dt_published;
    if (sOrderBy.length()==0) sOrderBy = DB.dt_published;

    if (DebugFile.trace) {
      DebugFile.writeln ("template=" + sTemplatePath);
      DebugFile.writeln ("cache dir=" + sFileDir);
      DebugFile.writeln ("modified=" + req.getAttribute("modified"));
      DebugFile.writeln ("encoding=" + sEncoding);
    }

    Date oDtModified = (Date) req.getAttribute("modified");

    if (null!=oDtModified) {
      try {

        File oCached = new File(sFileDir.substring(7)+File.separator+sCachedFile);

        if (!oCached.exists()) {
          oFS.mkdirs(sFileDir);
        }
        else if (oCached.lastModified()>oDtModified.getTime()) {
          sOutput = new String(oFS.readfile(sFileDir+File.separator+sCachedFile, sEncoding==null ? "ISO8859_1" : sEncoding));

          if (DebugFile.trace) {
            DebugFile.writeln("cache hit " + sFileDir+File.separator+sCachedFile);
            DebugFile.decIdent();
            DebugFile.writeln("End RecentPosts.render()");
          }

          return sOutput;
        }
      }
      catch (Exception xcpt) {
        DebugFile.writeln(xcpt.getClass().getName() + " " + xcpt.getMessage());
      }
    }

    String sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type=\"text/xsl\"?>";

    int iPosts = 0;

    if (req.getWindowState().equals(WindowState.MINIMIZED)) {
      sXML += "<posts/>";
    }
    else {

      DBBind oDBB = (DBBind) getPortletContext().getAttribute("GlobalDBBind");

      JDCConnection oCon = null;

      try  {
        oCon = oDBB.getConnection("PostsForGroup");

        NewsGroup oGrp = new NewsGroup(sNewsGrp);
        DBSubset  oPosts = oGrp.getTopLevelMessages(oCon, iMaxRecent, sOrderBy);
        iPosts = oPosts.getRowCount();

        oCon.close("PostsForGroup");
        oCon = null;

        Date dtPub;
        int iDtPubColPos = oPosts.getColumnPosition(DB.dt_published);
        for (int p=0; p<iPosts; p++) {
          dtPub = oPosts.getDate(iDtPubColPos,p);
          oPosts.setElementAt(Gadgets.leftPad(String.valueOf(dtPub.getMonth()+1),'0',2)+"-"+Gadgets.leftPad(String.valueOf(dtPub.getDate()),'0',2)+" "+Gadgets.leftPad(String.valueOf(dtPub.getHours()),'0',2)+":"+Gadgets.leftPad(String.valueOf(dtPub.getMinutes()),'0',2), 5,p);
        }

        sXML += "<posts>\n"+oPosts.toXML("","newsmsg")+"</posts>";
      }
      catch (SQLException e) {
        sXML += "<posts/>";

        try {
          if (null != oCon)
            if (!oCon.isClosed())
              oCon.close("PostsForGroup");
        } catch (SQLException ignore) { }
      }
    }

    try {
       if (DebugFile.trace) DebugFile.writeln("new ByteArrayInputStream(" + String.valueOf(sXML.length()) + ")");

       if (sEncoding==null)
         oInStream = new ByteArrayInputStream(sXML.getBytes());
       else
         oInStream = new ByteArrayInputStream(sXML.getBytes(sEncoding));

       oOutStream = new ByteArrayOutputStream(4000);

       Properties oProps = new Properties();

       Enumeration oKeys = req.getPropertyNames();
       while (oKeys.hasMoreElements()) {
         String sKey = (String) oKeys.nextElement();
         oProps.setProperty(sKey, req.getProperty(sKey));
       } // wend

       if (req.getWindowState().equals(WindowState.MINIMIZED))
         oProps.setProperty("windowstate", "MINIMIZED");
       else
         oProps.setProperty("windowstate", "NORMAL");

       StylesheetCache.transform (sTemplatePath, oInStream, oOutStream, oProps);

       if (sEncoding==null)
         sOutput = oOutStream.toString();
       else
         sOutput = oOutStream.toString("UTF-8");

       oOutStream.close();

       oInStream.close();
       oInStream = null;

       oFS.writefilestr (sFileDir+File.separator+sCachedFile, sOutput, sEncoding==null ? "ISO8859_1" : sEncoding);
     }
     catch (TransformerConfigurationException tce) {
       if (DebugFile.trace) {
         DebugFile.writeln("TransformerConfigurationException " + tce.getMessageAndLocation());
         try {
View Full Code Here

Examples of com.knowgate.dfs.FileSystem

      DebugFile.incIdent();
    }

    if (null==oFS) {
      if (DebugFile.trace) DebugFile.writeln("new com.knowgate.dfs.FileSystem()");
      oFS = new FileSystem();
    }

    // Crea la ruta base quitando el file:// de por delante
    sBasePath = sSourcePath.substring(sSourcePath.indexOf("://")+3);
View Full Code Here

Examples of com.knowgate.dfs.FileSystem

        if (id_disposition.equals("reference")) {
          if (DebugFile.trace) DebugFile.writeln("content disposition is reference");
          sFilePath = oRSet.getString(4);

          FileSystem oFS = new FileSystem();
          byte[] byData = oFS.readfilebin(sFilePath);
          String sContentType = oRSet.getString(7);
          if (DebugFile.trace) DebugFile.writeln("new ByteArrayDataSource("+sFilePath+", "+sContentType+")");
          ByteArrayDataSource baDataSrc = new ByteArrayDataSource(byData, sContentType);

          oMimeBody = new MimeBodyPart();
View Full Code Here

Examples of com.knowgate.dfs.FileSystem

    if (DebugFile.trace) {
      DebugFile.writeln("Begin CalendarTab.render()");
      DebugFile.incIdent();
    }

    FileSystem oFS = new FileSystem(FileSystem.OS_PUREJAVA);

    String sOutput;
    String sDomainId = req.getProperty("domain");
    String sWorkAreaId = req.getProperty("workarea");
    String sUserId = req.getProperty("user");
    String sTemplatePath = req.getProperty("template");
    String sStorage = req.getProperty("storage");
    String sZone = req.getProperty("zone");
    String sMaxRows = req.getProperty("maxrows");
    if (null==sMaxRows) sMaxRows = "10";
    String sFileDir = "file://" + sStorage + "domains" + File.separator + sDomainId + File.separator + "workareas" + File.separator + sWorkAreaId + File.separator + "cache" + File.separator + sUserId;
    String sCachedFile = "calendartab_" + sZone + "_" + req.getWindowState().toString() + ".xhtm";

    if (DebugFile.trace) {
      DebugFile.writeln ("user=" + sUserId);
      DebugFile.writeln ("template=" + sTemplatePath);
      DebugFile.writeln ("cache dir=" + sFileDir);
      DebugFile.writeln ("modified=" + req.getAttribute("modified"));
      DebugFile.writeln ("encoding=" + sEncoding);
    }

    Date oDtModified = (Date) req.getAttribute("modified");

    if (null!=oDtModified) {
      try {
      if (DebugFile.trace) DebugFile.writeln ("new File("+sFileDir.substring(7)+File.separator+sCachedFile+")");
       
        File oCached = new File(sFileDir.substring(7)+File.separator+sCachedFile);

        if (!oCached.exists()) {
          oFS.mkdirs(sFileDir);
        }
        else if (oCached.lastModified()>oDtModified.getTime()) {
          sOutput = new String(FileSystem.readfile(sFileDir+File.separator+sCachedFile, sEncoding==null ? "ISO8859_1" : sEncoding));

          if (DebugFile.trace) {
            DebugFile.writeln("cache hit " + sFileDir+File.separator+sCachedFile);
            DebugFile.decIdent();
            DebugFile.writeln("End CalendarTab.render()");
          }

          return sOutput;
        }
      }
      catch (Exception xcpt) {
        DebugFile.writeln(xcpt.getClass().getName() + " " + xcpt.getMessage());
      }
    }

    String sXML;

    int iToDo = 0, iMeetings = 0;

    if (req.getWindowState().equals(WindowState.MINIMIZED)) {
      if (DebugFile.trace) DebugFile.writeln ("WindowState.MINIMIZED");
      sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type=\"text/xsl\"?><calendar><todo/><today/></calendar>";
    }
    else {
      if (DebugFile.trace) DebugFile.writeln ("WindowState.NORMAL");

      String sTodayXML, sToDoXML;

      Date dt00 = new Date();
      Date dt23 = new Date();

      dt00.setHours(0);
      dt00.setMinutes(0);
      dt00.setSeconds(0);

      dt23.setHours(23);
      dt23.setMinutes(59);
      dt23.setSeconds(59);

      DBBind oDBB = (DBBind) getPortletContext().getAttribute("GlobalDBBind");

      DBSubset oToDo = new DBSubset (DB.k_to_do, DB.gu_to_do + "," + DB.od_priority + "," + DB.tl_to_do,
                                     DB.gu_user + "=? AND (" + DB.tx_status + "='PENDING' OR " + DB.tx_status + " IS NULL) ORDER BY 2 DESC", 10);

      DBSubset oMeetings = new DBSubset (DB.k_meetings + " m," + DB.k_x_meeting_fellow + " f",
                                         "m." + DB.gu_meeting + ",m." + DB.gu_fellow + ",m." + DB.tp_meeting + ",m." + DB.tx_meeting + ", m." + DB.dt_start + ",m." + DB.dt_end,
                                         "m." + DB.gu_meeting + "=f." + DB.gu_meeting + " AND f." + DB.gu_fellow + "=? AND m." + DB.dt_start + " BETWEEN ? AND ? ORDER BY m." + DB.dt_start, 10);

      JDCConnection oCon = null;

      try  {
        oCon = oDBB.getConnection("CalendarTab_today");

        oToDo.setMaxRows(Integer.parseInt(sMaxRows));
        iToDo = oToDo.load (oCon, new Object[]{sUserId});

        for (int a=0; a<iToDo; a++) {
          if (oToDo.getStringNull(2, a,"").length()>40)
            oToDo.setElementAt(oToDo.getString(2, a).substring(0, 40) +"...", 2,a);
        }

        sToDoXML = oToDo.toXML("", "activity");

        iMeetings = oMeetings.load(oCon, new Object[]{sUserId, new Timestamp(dt00.getTime()), new Timestamp(dt23.getTime())});

        for (int m=0; m<iMeetings; m++) {

          if (oMeetings.isNull(3,m)) oMeetings.setElementAt("untitled", 3,m);

          Date oFrom = oMeetings.getDate(4,m);
          oMeetings.setElementAt(String.valueOf(oFrom.getHours())+":"+Gadgets.leftPad(String.valueOf(oFrom.getMinutes()),'0',2), 4, m);

          Date oTo = oMeetings.getDate(5,m);
          oMeetings.setElementAt(String.valueOf(oTo.getHours())+":"+Gadgets.leftPad(String.valueOf(oTo.getMinutes()),'0',2), 5, m);
        }

        oCon.close("CalendarTab_today");
        oCon = null;

        sTodayXML = oMeetings.toXML("","meeting");
      }
      catch (SQLException e) {
        sToDoXML = "<todo></todo>";
        sTodayXML = "<today></today>";

        try {
          if (null != oCon)
            if (!oCon.isClosed())
              oCon.close("CalendarTab_today");
        } catch (SQLException ignore) { }
      }

      sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/xsl\"?>\n<calendar>\n";
      if (iToDo>0)
        sXML += "<todo>\n"+sToDoXML+"</todo>\n";
      else
        sXML += "<todo/>\n";

      if (iMeetings>0)
        sXML += "<today>\n"+sTodayXML+"</today>\n</calendar>";
      else
        sXML += "<today/>\n</calendar>";
     }

     try {
       if (DebugFile.trace) DebugFile.writeln("new ByteArrayInputStream(" + String.valueOf(sXML.length()) + ")");

       if (sEncoding==null)
         oInStream = new ByteArrayInputStream(sXML.getBytes());
       else
         oInStream = new ByteArrayInputStream(sXML.getBytes(sEncoding));

       oOutStream = new ByteArrayOutputStream(4000);

       Properties oProps = new Properties();

       Enumeration oKeys = req.getPropertyNames();
       while (oKeys.hasMoreElements()) {
         String sKey = (String) oKeys.nextElement();
         if (null!=req.getProperty(sKey)) {
           if (DebugFile.trace) DebugFile.writeln("setProperty("+sKey+","+req.getProperty(sKey)+")");
           oProps.setProperty(sKey, req.getProperty(sKey));
         }
       } // wend

     if (req.getWindowState()==null)
         oProps.setProperty("windowstate", "NORMAL");
       else if (req.getWindowState().equals(WindowState.MINIMIZED))
         oProps.setProperty("windowstate", "MINIMIZED");
       else
         oProps.setProperty("windowstate", "NORMAL");

       StylesheetCache.transform (sTemplatePath, oInStream, oOutStream, oProps);

       if (sEncoding==null)
         sOutput = oOutStream.toString();
       else
         sOutput = oOutStream.toString("UTF-8");

       oOutStream.close();

       oInStream.close();
       oInStream = null;

       oFS.writefilestr (sFileDir+File.separator+sCachedFile, sOutput, sEncoding==null ? "ISO8859_1" : sEncoding);
     }
     catch (TransformerConfigurationException tce) {
       if (DebugFile.trace) {
         DebugFile.writeln("TransformerConfigurationException " + tce.getMessageAndLocation());
         try {
View Full Code Here

Examples of com.knowgate.dfs.FileSystem

    String sOutput;
    ByteArrayInputStream oInStream;
    ByteArrayOutputStream oOutStream;

    FileSystem oFS = new FileSystem(FileSystem.OS_PUREJAVA);

  // ****************************************************************************
  // These are the properties passed to this portlet from desktop.jsp page

    String sDomainId   = req.getProperty("domain");
    String sWorkAreaId = req.getProperty("workarea");
    String sUserId     = req.getProperty("user");
    String sZone       = req.getProperty("zone");
    String sLang       = req.getProperty("language");
    String sStorage    = req.getProperty("storage");
    String sTemplatePath  = req.getProperty("template");
    String sCacheFilesDir = sStorage+"domains"+File.separator+
                          sDomainId+File.separator+"workareas"+File.separator+
                          sWorkAreaId+File.separator+"cache"+File.separator+sUserId;
    String sCachedFile = getClass().getName() + "." + req.getWindowState().toString() + ".xhtm";

    // No more properties
  // ****************************************************************************

  // ****************************************************************************
  // Portlets are cached for reducing database accesses and improving performance

    Date oDtModified = (Date) req.getAttribute("modified");
 
    if (null!=oDtModified) {
      try {

        File oCached = new File(sCacheFilesDir+File.separator+sCachedFile);

        if (!oCached.exists())
          oFS.mkdirs(sCacheFilesDir);
        else if (oCached.lastModified()>oDtModified.getTime())
          return oFS.readfilestr("file://"+sCacheFilesDir+File.separator+sCachedFile,
                                 sEncoding==null ? "ISO8859_1" : sEncoding);
      } catch (Exception xcpt) {
        System.err.println(xcpt.getClass().getName() + " " + xcpt.getMessage());
      }
    } // fi (oDtModified)

  // ****************************************************************************

    String sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type=\"text/xsl\"?>";
 
    if (req.getWindowState().equals(WindowState.MINIMIZED)) {
     
      // If portlet state is minimized then there is no need to do any database access
     
      sXML += "<FullName/>";
    }
    else {

      // Get database connection from desktop.jsp page

      DBBind oDBB = (DBBind) getPortletContext().getAttribute("GlobalDBBind");

      JDCConnection oCon = null;

      try  {
        oCon = oDBB.getConnection("HelloWorld");

      String sFullName = DBCommand.queryStr(oCon, "SELECT "+DB.nm_user+",' ',"+DB.tx_surname1+" FROM "+DB.k_users+" WHERE '"+DB.gu_user+"='"+sUserId+"'");

        oCon.close("HelloWorld");
        oCon = null;

        sXML += "<FullName>"+sFullName+"</FullName>";
      }
      catch (SQLException e) {
        sXML += "<FullName/>";

        try {
          if (null != oCon)
            if (!oCon.isClosed())
              oCon.close("HelloWorld");
        } catch (SQLException ignore) { }
      }
    } // fi (WindowState)

    try {

     // ******************************************
     // Set input parameters for XSL StyleSheet
    
       Properties oProps = new Properties();
       Enumeration oKeys = req.getPropertyNames();
       while (oKeys.hasMoreElements()) {
         String sKey = (String) oKeys.nextElement();
         oProps.setProperty(sKey, req.getProperty(sKey));
       } // wend

       oProps.setProperty("windowstate",
                          req.getWindowState().equals(WindowState.MINIMIZED) ?
                          "MINIMIZED" : "NORMAL");

     // ******************************************

     // ******************************************
     // Perform XSLT Transformation for generating
     // portlet XHTML code fragment.

       if (sEncoding==null)
         oInStream = new ByteArrayInputStream(sXML.getBytes());
       else
         oInStream = new ByteArrayInputStream(sXML.getBytes(sEncoding));

       oOutStream = new ByteArrayOutputStream(4000);

       StylesheetCache.transform (sTemplatePath, oInStream, oOutStream, oProps);

       if (sEncoding==null)
         sOutput = oOutStream.toString();
       else
         sOutput = oOutStream.toString("UTF-8");

       oOutStream.close();

       oInStream.close();
       oInStream = null;

     // **************************************
     // Cache generated XHTML code into a file

       oFS.writefilestr ("file://"+sCacheFilesDir+File.separator+sCachedFile, sOutput,
                         sEncoding==null ? "ISO8859_1" : sEncoding);
     }
     catch (Exception xcpt) {
       throw new PortletException(xcpt.getClass().getName() + " " + xcpt.getMessage(), xcpt);
     }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.