<commit_before>package org.jasig.portal.channels;

import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;

import java.io.*;
import java.util.*;
import org.jasig.portal.*;
import org.jasig.portal.channels.bookmarks.*;
import com.objectspace.xml.*;

/**
 * This is a channel for storing user-defined bookmarks.
 * 
 * @author <NAME>
 */
public class CBookmarks extends GenericPortalBean implements org.jasig.portal.IChannel                         
{ 
  // This should come from a database
  private File xmlFile = new File (getPortalBaseDir () + "source\\org\\jasig\\portal\\channels\\bookmarks\\bookmarks.xml");
  private String xmlFilePackage = "org.jasig.portal.channels.bookmarks";
  
  public String getName () {return "My Bookmarks";}
  public void initParams (Hashtable params) {};
  public boolean isMinimizable () {return true;}
  public boolean isDetachable () {return true;}
  public boolean isRemovable () {return true;}
  public boolean isEditable () {return true;}
  public boolean hasHelp () {return false;}  
  
  public int getDefaultDetachWidth () {return 450;}
  public int getDefaultDetachHeight () {return 400;}
  
  public void render (HttpServletRequest req, HttpServletResponse res, JspWriter out)
  {    
    try 
    {
      // Open xml file -- this should eventually be retrieved from a database
      IXml xml = Xml.openDocument (xmlFilePackage, xmlFile);
      IBookmarks bm = (IBookmarks) xml.getRoot ();
      
      // Get Bookmarks
      IBookmark[] bookmarks = bm.getBookmarks ();
      
      out.println ("<table width=100%>");
        
      for (int i = 0; i < bookmarks.length; i++)
      {
        out.println ("  <tr bgcolor=#eeeeee>");
        out.println ("    <td><font face=Arial><a href=\"" + bookmarks[i].getAttribute ("url") + "\">" + bookmarks[i].getAttribute ("name") + "</a></font></td>");
        out.println ("    <td><font face=Arial>" + bookmarks[i].getAttribute ("comments") + "</font></td>");
        out.println ("  </tr>");
      }
      
      out.println ("</table>");
      
    }
    catch (Exception e)
    {
      e.printStackTrace ();
    }
  }
  
  public void edit (HttpServletRequest req, HttpServletResponse res, JspWriter out)
  {    
    try
    {
      String sAction = req.getParameter("action");
      
      if (sAction == null)
        doListBookmarks (req, res, out);
      else if (sAction.equals("edit"))
        doEditBookmark (req, res, out);
      else if (sAction.equals ("delete"))
        doDeleteBookmark (req, res, out);
      else if (sAction.equals ("add"))
        doAddBookmark (req, res, out);
      else if (sAction.equals ("save"))
        doSaveBookmark (req, res, out);
      else if (sAction.equals ("done"))
        doFinishedEditing (req, res, out);
    }
    catch (Exception e)
    {
      e.printStackTrace ();
    }
  }
    
  protected void doListBookmarks (HttpServletRequest req, HttpServletResponse res, JspWriter out)
  {
    try
    {
      // Open xml file -- this should eventually be retrieved from a database
      IXml xml = Xml.openDocument (xmlFilePackage, xmlFile);
      IBookmarks bm = (IBookmarks) xml.getRoot ();
        
      // Get Bookmarks
      IBookmark[] bookmarks = bm.getBookmarks ();
        
      out.println ("<table>");
      out.println ("  <tr>");
      out.println ("    <th>Name</th>");
      out.println ("    <th>URL</th>");
      out.println ("    <th>Comments</th>");
      out.println ("  </tr>");
        
      for (int i = 0; i < bookmarks.length; i++)
      {
        out.println ("  <tr bgcolor=#eeeeee>");
        out.println ("    <td>" + bookmarks[i].getAttribute ("name") + "</td>");
        out.println ("    <td>" + bookmarks[i].getAttribute ("url") + "</td>");
        out.println ("    <td>" + bookmarks[i].getAttribute ("comments") + "</td>");
        out.println ("    <td>[<a href=\"dispatch.jsp?method=edit&action=edit&bookmark=" + i + "\">edit</a>][<a href=\"dispatch.jsp?method=edit&action=delete&bookmark=" + i + "\">delete</a>]</td>");
        out.println ("  </tr>");
      }
      out.println ("</table>");
      out.println ("<table border=0><tr>");
      out.println ("<td><br><input type=button name=add value=\"Add Bookmark\" onClick=\"location=\'dispatch.jsp?method=edit&action=add\'\"></td>");
      out.println ("<td><br><input type=button name=finished value=\"Finished\" onClick=\"location=\'dispatch.jsp?method=edit&action=done\'\"></td>");
      out.println ("</tr></table>");
    }
    catch (Exception e)
    {
      e.printStackTrace ();
    }
  }
  
  protected void doEditBookmark (HttpServletRequest req, HttpServletResponse res, JspWriter out)
  {
    try<commit_msg>Added <form> tags around  buttons so that they appear in Netscape<commit_after>package org.jasig.portal.channels;

import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;

import java.io.*;
import java.util.*;
import org.jasig.portal.*;
import org.jasig.portal.channels.bookmarks.*;
import com.objectspace.xml.*;

/**
 * This is a channel for storing user-defined bookmarks.
 * 
 * @author <NAME>
 */
public class CBookmarks extends GenericPortalBean implements org.jasig.portal.IChannel                         
{ 
  // This should come from a database
  private File xmlFile = new File (getPortalBaseDir () + "source\\org\\jasig\\portal\\channels\\bookmarks\\bookmarks.xml");
  private String xmlFilePackage = "org.jasig.portal.channels.bookmarks";
  
  public String getName () {return "My Bookmarks";}
  public void initParams (Hashtable params) {};
  public boolean isMinimizable () {return true;}
  public boolean isDetachable () {return true;}
  public boolean isRemovable () {return true;}
  public boolean isEditable () {return true;}
  public boolean hasHelp () {return false;}  
  
  public int getDefaultDetachWidth () {return 450;}
  public int getDefaultDetachHeight () {return 400;}
  
  public void render (HttpServletRequest req, HttpServletResponse res, JspWriter out)
  {    
    try 
    {
      // Open xml file -- this should eventually be retrieved from a database
      IXml xml = Xml.openDocument (xmlFilePackage, xmlFile);
      IBookmarks bm = (IBookmarks) xml.getRoot ();
      
      // Get Bookmarks
      IBookmark[] bookmarks = bm.getBookmarks ();
      
      out.println ("<table width=100%>");
        
      for (int i = 0; i < bookmarks.length; i++)
      {
        out.println ("  <tr bgcolor=#eeeeee>");
        out.println ("    <td><font face=Arial><a href=\"" + bookmarks[i].getAttribute ("url") + "\">" + bookmarks[i].getAttribute ("name") + "</a></font></td>");
        out.println ("    <td><font face=Arial>" + bookmarks[i].getAttribute ("comments") + "</font></td>");
        out.println ("  </tr>");
      }
      
      out.println ("</table>");
      
    }
    catch (Exception e)
    {
      e.printStackTrace ();
    }
  }
  
  public void edit (HttpServletRequest req, HttpServletResponse res, JspWriter out)
  {    
    try
    {
      String sAction = req.getParameter("action");
      
      if (sAction == null)
        doListBookmarks (req, res, out);
      else if (sAction.equals("edit"))
        doEditBookmark (req, res, out);
      else if (sAction.equals ("delete"))
        doDeleteBookmark (req, res, out);
      else if (sAction.equals ("add"))
        doAddBookmark (req, res, out);
      else if (sAction.equals ("save"))
        doSaveBookmark (req, res, out);
      else if (sAction.equals ("done"))
        doFinishedEditing (req, res, out);
    }
    catch (Exception e)
    {
      e.printStackTrace ();
    }
  }
    
  protected void doListBookmarks (HttpServletRequest req, HttpServletResponse res, JspWriter out)
  {
    try
    {
      // Open xml file -- this should eventually be retrieved from a database
      IXml xml = Xml.openDocument (xmlFilePackage, xmlFile);
      IBookmarks bm = (IBookmarks) xml.getRoot ();
        
      // Get Bookmarks
      IBookmark[] bookmarks = bm.getBookmarks ();
        
      out.println ("<table>");
      out.println ("  <tr>");
      out.println ("    <th>Name</th>");
      out.println ("    <th>URL</th>");
      out.println ("    <th>Comments</th>");
      out.println ("  </tr>");
        
      for (int i = 0; i < bookmarks.length; i++)
      {
        out.println ("  <tr bgcolor=#eeeeee>");
        out.println ("    <td>" + bookmarks[i].getAttribute ("name") + "</td>");
        out.println ("    <td>" + bookmarks[i].getAttribute ("url") + "</td>");
        out.println ("    <td>" + bookmarks[i].getAttribute ("comments") + "</td>");
        out.println ("    <td>[<a href=\"dispatch.jsp?method=edit&action=edit&bookmark=" + i + "\">edit</a>][<a href=\"dispatch.jsp?method=edit&action=delete&bookmark=" + i + "\">delete</a>]</td>");
        out.println ("  </tr>");
      }
      out.println ("</table>");
      out.println ("<table border=0><tr><form>");
      out.println ("<td><br><input type=button name=add value=\"Add Bookmark\" onClick=\"location=\'dispatch.jsp?method=edit&action=add\'\"></td>");
      out.println ("<td><br><input type=button name=finished value=\"Finished\" onClick=\"location=\'dispatch.jsp?method=edit&action=done\'\"></td>");
      out.println ("</form></tr></table>");
    }
    catch (Exception e)
    {
      e.printStackTrace ();
    }
  }
  
  protected void doEditBookmark (HttpServletRequest req, HttpServletResponse res, JspWriter out)
  {
    try
{'fraction_non_alphanumeric': 0.163289124668435, 'fraction_numerical': 0.002546419098143236, 'mean_word_length': 2.73602853745541, 'pattern_counts': {'":': 0, '<': 112, '<?xml version=': 0, '>': 108, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7551062', 'n_tokens_mistral': 2907, 'n_tokens_neox': 2886, 'n_words': 705}