import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Arrays;

/**
 * Shows the admin a list of all issues
 */
public class Issues_IndexController extends BaseController {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        super.doGet(request, response);

        if (this.isLoggedIn()) {
            if (this.getUser().isAdmin()) {
                Issue_DBWrapper issueWrapper = this.getPortalBean().getIssues();

                issueWrapper.reset();

                String column = request.getParameter("column");
                request.setAttribute("column", column);

                if (column != null && column.equals("") == false) {
                    String[] split = column.split("\\|");

                    String sortBy = split[0];
                    String direction = split[1];

                    issueWrapper.addSort(sortBy, direction);
                }

                List<Issue> issues = Arrays.asList(issueWrapper.runQuery());
                request.setAttribute("issues", issues);

                Status_DBWrapper statusWrapper = this.getPortalBean().getStatuses();

                statusWrapper.reset();
                statusWrapper.addSort("id", "ASC");

                Status[] statuses = statusWrapper.runQuery();
                request.setAttribute("statuses", statuses);

                Category_DBWrapper categoryWrapper = this.getPortalBean().getCategories();

                categoryWrapper.reset();
                categoryWrapper.addSort("title", "ASC");

                Category[] categories = categoryWrapper.runQuery();
                request.setAttribute("categories", categories);

                request.getRequestDispatcher("/WEB-INF/jsp/issues/index.jsp").forward(request, response);
            } else {
                response.sendRedirect(this.getBaseURL());
            }
        } else {
            response.sendRedirect(this.getBaseURL() + "login");
        }
    }
}


@@ -14,32 +14,109 @@
 servlet.
-ServletException
+RequestDispatcher;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.ServletRequest
 ;%0Aimport
@@ -588,56 +588,8 @@
 ) %7B%0A
-            if (this.getUser().isAdmin()) %7B%0A    
     
@@ -666,36 +666,32 @@
 );%0A%0A            
-    
 issueWrapper.res
@@ -693,28 +693,24 @@
 r.reset();%0A%0A
-    
             
@@ -761,36 +761,32 @@
 %22);%0A            
-    
 request.setAttri
@@ -818,28 +818,24 @@
             
-   
- 
 if (column !
@@ -886,28 +886,24 @@
             
-    
 String%5B%5D spl
@@ -941,28 +941,24 @@
             
-  
-  
 String sortB
@@ -971,20 +971,16 @@
 lit%5B0%5D;%0A
-    
         
@@ -1025,36 +1025,32 @@
                 
- 
-   
 issueWrapper.add
@@ -1074,20 +1074,16 @@
 ction);%0A
-    
         
@@ -1093,146 +1093,8 @@
  %7D%0A%0A
-                List%3CIssue%3E issues = Arrays.asList(issueWrapper.runQuery());%0A                request.setAttribute(%22issues%22, issues);%0A%0A    
     
@@ -1175,36 +1175,32 @@
 );%0A%0A            
-  
-  
 statusWrapper.re
@@ -1198,36 +1198,32 @@
 rapper.reset();%0A
-    
             stat
@@ -1263,28 +1263,24 @@
             
- 
-   
 Status%5B%5D sta
@@ -1305,36 +1305,32 @@
 per.runQuery();%0A
-    
             requ
@@ -1374,36 +1374,32 @@
 );%0A%0A            
-    
 Category_DBWrapp
@@ -1462,36 +1462,32 @@
 );%0A%0A            
-   
- 
 categoryWrapper.
@@ -1487,36 +1487,32 @@
 rapper.reset();%0A
-    
             cate
@@ -1553,36 +1553,32 @@
 );%0A%0A            
-  
-  
 Category%5B%5D categ
@@ -1617,36 +1617,32 @@
 ();%0A            
-    
 request.setAttri
@@ -1670,24 +1670,205 @@
 tegories);%0A%0A
+%0A            if (this.getUser().isAdmin()) %7B%0A%0A%0A                List%3CIssue%3E issues = Arrays.asList(issueWrapper.runQuery());%0A                request.setAttribute(%22issues%22, issues);%0A%0A
             
@@ -1974,32 +1974,33 @@
        %7D else %7B%0A
+%0A
                 
@@ -2003,80 +2003,507 @@
     
-response.sendRedirect(this.getBaseURL());%0A            %7D%0A        %7D else %7B
+List%3CIssue%3E issues = Arrays.asList(issueWrapper.getIssuesbyUserId(this.getUser().getUserId()));%0A                request.setAttribute(%22issues%22, issues);%0A%0A%0A                request.getRequestDispatcher(%22/WEB-INF/jsp/issues/index.jsp%22).forward(request, response);%0A            %7D%0A        %7D else %7B%0A%0A%0A            //request.setAttribute(%22r%22, %22/issues%22);%0A            //request.getParameterMap().put(%22r%22, new String%5B%5D%7B%22/issues%22%7D);%0A            //request.getRequestDispatcher(%22/login%22).forward(request,response);
 %0A   

Send user back to log in page, if not log in.