Package org.apache.jsp

Source Code of org.apache.jsp.viewgroup_jsp

package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
import com.opensymphony.module.user.UserManager;
import java.util.Collection;
import com.opensymphony.module.user.Group;
import java.util.Iterator;
import com.opensymphony.module.user.User;
import java.net.URLEncoder;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.module.propertyset.PropertySet;

public class viewgroup_jsp extends HttpJspBase {


private String getTypeName(int type)
{
    switch (type)
    {
        case 1:
            return "Boolean";
        case 2:
            return "Integer";
        case 3:
            return "Long";
        case 4:
            return "Double";
        case 5:
            return "String";
        case 6:
            return "Text";
        case 7:
            return "Date";
        case 8:
            return "Object";
        case 9:
            return "XML";
        case 10:
            return "Data";
        case 11:
            return "Properties";
        default:
            return "Unknown";
    }
}

public String getPropertyValue(PropertySet ps, String key) throws Exception
{
    int type = ps.getType(key);

    switch(type)
    {
        case PropertySet.STRING:
            return ps.getString(key);
        case PropertySet.BOOLEAN:
            return ps.getBoolean(key) + "";
        case PropertySet.INT:
      return ps.getInt(key) + "";
        case PropertySet.LONG:
      return ps.getLong(key) + "";
        case PropertySet.DATE:
            return ps.getDate(key) + "";
    case PropertySet.TEXT:
      return ps.getText(key) + "";
        default:
            return "Cannot display property value";
    }
}

public void setPropertyValue(PropertySet ps, String key, int type, String newVal) throws Exception
{
    try
    {
        switch (type)
        {
            case PropertySet.STRING:
                ps.setString(key, newVal); break;
      case PropertySet.TEXT:
                ps.setText(key, newVal); break;
            case PropertySet.BOOLEAN:
                ps.setBoolean(key, Boolean.valueOf(newVal).booleanValue()); break;
            case PropertySet.INT:
                ps.setInt(key, Integer.valueOf(newVal).intValue()); break;
      case PropertySet.LONG:
                ps.setLong(key, Long.valueOf(newVal).intValue()); break;
      case PropertySet.DOUBLE:
                ps.setDouble(key, Double.valueOf(newVal).intValue()); break;
            case PropertySet.DATE:
                ps.setDate(key, java.text.DateFormat.getDateInstance().parse(newVal)); break;
            default:
                throw new Exception("Type not recognised");
        }
    } catch (Exception e)
    {
        throw e;
    }
}

  private static java.util.Vector _jspx_includes;

  static {
    _jspx_includes = new java.util.Vector(2);
    _jspx_includes.add("/manager/nav.jsp");
    _jspx_includes.add("/manager/includes/propertysetMethods.jsp");
  }

  public java.util.List getIncludes() {
    return _jspx_includes;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response,
            null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");

  UserManager um = UserManager.getInstance();
  Group group = um.getGroup(request.getParameter("name"));

  PropertySet ps = null;

  if (request.getParameter("propertyAdd") != null) {
    ps = group.getPropertySet();
        setPropertyValue(ps, request.getParameter("propertyKey"), Integer.parseInt(request.getParameter("propertyType")), request.getParameter("propertyValue"));
  }
  else if (request.getParameter("propertyDel") != null)
  {
    ps = group.getPropertySet();
    ps.remove(request.getParameter("propertyDel"));
  }
      out.write("\r\n\r\n");
      out.write("<h1>View Group : ");
      out.print( group.getName() );
      out.write("</h1>\r\n");
      out.write("<hr>\r\n\r\n");
      out.write("<h4>Details");
      out.write("</h4>\r\nName: ");
      out.print( group.getName() );
      out.write("<br>\r\nClass: ");
      out.print( group.getClass() );
      out.write("<br>\r\n\r\n");
      out.write("<h4>Providers");
      out.write("</h4>\r\nCredentialsProvider: ");
      out.print( (group.getCredentialsProvider() != null ? group.getCredentialsProvider().getClass().toString() : "None") );
      out.write("<br>\r\nAccessProvider: ");
      out.print( (group.getAccessProvider() != null ? group.getAccessProvider().getClass().toString() : "None" ));
      out.write("<br>\r\nProfileProvider: ");
      out.print( (group.getProfileProvider() != null ? group.getProfileProvider().getClass().toString() : "None"));
      out.write("<br>\r\n\r\n");
      out.write("<h4>Users");
      out.write("</h4>\r\n\r\n");

  Collection users = group.getUsers();
      out.write("\r\n");
      out.print( users.size() );
      out.write(" users");
      out.write("<br>\r\n\r\n");
      out.write("<ol>\r\n");

  for (Iterator iterator = users.iterator(); iterator.hasNext();)
  {
    String userName = (String) iterator.next();
      out.write("\r\n\t\t");
      out.write("<li>");
      out.write("<a href=\"viewuser.jsp?name=");
      out.print( URLEncoder.encode(userName) );
      out.write("\">");
      out.print( userName);
      out.write("</a>");
      out.write("</li>\r\n");

  }
      out.write("\r\n");
      out.write("</ol>\r\n\r\n");
      out.write("<h4>Properties");
      out.write("</h4>\r\n");

  ps = group.getPropertySet();
  if (ps != null)
  {
    Collection keys = ps.getKeys();
    for (Iterator iterator = keys.iterator(); iterator.hasNext();)
    {
      String key = (String) iterator.next();
      out.write("\r\n\t\t");
      out.print( key );
      out.write(" : ");
      out.print( getPropertyValue(ps, key) );
      out.write(" (");
      out.print( getTypeName(ps.getType(key)) );
      out.write(") [");
      out.write("<a href=\"viewgroup.jsp?name=");
      out.print( URLEncoder.encode(group.getName()) );
      out.write("&propertyDel=");
      out.print( URLEncoder.encode(key) );
      out.write("\">Del");
      out.write("</a>]");
      out.write("<br>\r\n");

    }
      out.write("\r\n\r\n");
      out.write("<form action=\"viewgroup.jsp\" method=\"post\">\r\n");
      out.write("<input type=\"hidden\" name=\"name\" value=\"");
      out.print( group.getName() );
      out.write("\">\r\n");
      out.write("<h4>Add Property");
      out.write("</h4>\r\nKey: ");
      out.write("<input name=\"propertyKey\" type=\"text\">");
      out.write("<br>\r\nType:\r\n");
      out.write("<select name=\"propertyType\">\r\n\t");
for (int i = 1; i <= 7; i++) {       out.write("\r\n\t\t");
      out.write("<option value=\"");
      out.print( i );
      out.write("\">");
      out.print( getTypeName(i) );
      out.write("</option>\r\n\t");
}       out.write("\r\n");
      out.write("</select>");
      out.write("<br>\r\nValue: ");
      out.write("<input name=\"propertyValue\" type=\"text\">");
      out.write("<br>\r\n");
      out.write("<input type=\"submit\" name=\"propertyAdd\" value=\"Add Property\">\r\n");
      out.write("</form>\r\n\r\n");

  }
  else
  {
      out.write("\r\n\t\tNo PropertySet for this group\r\n");

  }
      out.write("\r\n\r\n\r\n");
      out.write("<hr>\r\n");
      out.write("<a href=\"default.jsp\">Home");
      out.write("</a> |\r\n");
      out.write("<a href=\"users.jsp\">Users");
      out.write("</a> |\r\n");
      out.write("<a href=\"groups.jsp\">Groups");
      out.write("</a>\r\n");
      out.write("\r\n\r\n");
      out.write("\r\n");
      out.write("\r\n\r\n");
    } catch (Throwable t) {
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0)
        out.clearBuffer();
      if (pageContext != null) pageContext.handlePageException(t);
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
    }
  }
}
TOP

Related Classes of org.apache.jsp.viewgroup_jsp

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.