View Javadoc

1   package org.astrogrid.portal.cocoon.community;
2   import org.apache.avalon.framework.parameters.Parameters;
3   import org.apache.cocoon.acting.AbstractAction;
4   import org.apache.cocoon.environment.Request;
5   import org.apache.cocoon.environment.Session;
6   import org.apache.cocoon.environment.Redirector;
7   import org.apache.cocoon.environment.SourceResolver;
8   import org.apache.cocoon.environment.ObjectModelHelper;
9   import java.util.Map;
10  import java.util.ArrayList;
11  import java.util.HashMap;
12  import java.util.Hashtable;
13  import java.util.LinkedHashMap;
14  import org.astrogrid.portal.login.common.SessionKeys;
15  import org.astrogrid.config.Config;
16  import org.astrogrid.config.SimpleConfig;
17  import org.astrogrid.community.common.policy.data.AccountData;
18  import org.astrogrid.community.common.security.data.SecurityToken;
19  import org.astrogrid.community.common.exception.CommunitySecurityException;
20  import org.astrogrid.community.resolver.security.manager.SecurityManagerResolver;
21  import org.astrogrid.community.resolver.security.service.SecurityServiceResolver;
22  import org.astrogrid.community.resolver.policy.manager.PolicyManagerResolver;
23  import org.astrogrid.community.client.policy.manager.PolicyManagerDelegate;
24  import org.astrogrid.community.client.security.manager.SecurityManagerDelegate;
25  import org.astrogrid.community.client.security.service.SecurityServiceDelegate;
26  import java.net.MalformedURLException;
27  import java.net.URL;
28  import org.apache.avalon.framework.logger.ConsoleLogger;
29  import org.apache.avalon.framework.logger.Logger;
30  import org.astrogrid.store.Ivorn;
31  
32  
33  /***
34   *
35   * AdministrationAction is a custom cocoon Action used for the Administraiton page.  And is used in conjunction with
36   * astrogrid.xsl and astrogrid.xsp
37   * 
38   * @author Kevin Benson
39   *
40   */
41  public class AdministrationAction extends AbstractAction
42  {
43     
44     
45     /***
46      * Switch for our debug statements. 
47      * JDT: I know we shouldn't be using System.outs but they
48      * can be *so* useful. Retain, but switch off for deployment and
49      * supplement with logging to files.
50      *  
51      */
52     private static final boolean debugToSystemOutOn = true;
53     
54     
55     /***
56      * Logger
57      */
58     private Logger log;
59     
60     
61  	/***
62  	 * Switch for our debug statements.
63  	 *
64  	 */
65  	public static boolean DEBUG_FLAG = true;
66     
67     /***
68  	 * Cocoon param for the user param in the session.
69  	 *
70  	 */
71  	public static final String USER_PARAM_NAME = "user-param" ;
72  	
73  	private static final String ACTION = "action";
74  	
75  	private static final String ACTION_INSERT_RESOURCE = "insertresource";
76  
77  	private static final String ACTION_INSERT_MEMBER = "insertmember";
78  	
79  	private static final String ACTION_INSERT_PERMISSION = "insertpermission";
80  	
81  	private static final String ACTION_INSERT_GROUP = "insertgroup";
82  	
83  	private static final String ACTION_INSERT_COMMUNITY = "insertcommunity";
84  	
85  	private static final String ACTION_REMOVE_RESOURCE = "removeresource";
86  
87  	private static final String ACTION_REMOVE_MEMBER = "removemember";
88  
89  	private static final String ACTION_REMOVE_PERMISSION = "removepermission";
90  
91  	private static final String ACTION_REMOVE_GROUP = "removegroup";
92  	
93  	private static final String ACTION_REMOVE_COMMUNITY = "removecommunity";
94  	
95  	private static final String ACTION_REMOVE_ACCOUNT = "removeaccount";
96     
97     private static final String ACTION_INSERT_ACCOUNT = "insertaccount";   
98  		
99  	private static final String ACTION_VIEW_GROUPS = "viewgroups";	
100    
101    private static final String ACTION_VIEW_ACCOUNTS = "viewaccounts";   
102    
103    private static final String ACTION_VIEW_COMMUNITY = "viewcommunity";   
104    
105    private static final String ACTION_VIEW_RESOURCES = "viewresources";
106    
107    private static final String ACTION_VIEW_MEMBERS = "viewmembers";   
108    
109    private static final String ACTION_CHANGE_PASSWORD = "changeofpassword";
110    
111    private static final String IDENT = "ident";
112    
113    private static final String PROCESS_ACTION = "processaction";   
114 
115    private static final String PARAM_COMMUNITY_LIST = "communitylist";   
116    
117    private static final String PARAM_RESOURCE_LIST = "resourcelist";   
118    
119    private static final String PARAM_ACCOUNT_LIST = "accountlist";   
120 
121    private static final String PARAM_GROUP_LIST = "grouplist";
122       
123    private static final String PARAM_MEMBERS_LIST = "memberslist";   
124    
125    private static final String HTTPS_CONNECTION = "on";   
126    
127    
128    /***
129     * During unit tests the logger isn't setup properly, hence this method to
130     * use a console logger instead.  Also will log to console
131     * if debugToSystemOutOn - can be useful.
132     *  
133     */
134    private void checkLogger() {
135        log = super.getLogger();
136        if (log == null || debugToSystemOutOn) {
137            enableLogging(new ConsoleLogger());
138            log = super.getLogger();
139        }
140    }   
141 		
142 	/***
143 	 * Our action method.
144 	 *
145 	 */
146 	public Map act(
147 		Redirector redirector, 
148 		SourceResolver resolver, 
149 		Map objectModel, 
150 		String source, 
151 		Parameters params)
152 		{
153 	      
154       String community_name = null;//CommunityConfig.getCommunityName();
155       //System.out.println(community_name);
156       
157       checkLogger();
158 		//
159 		// Get our current request and session.
160 		Request request = ObjectModelHelper.getRequest(objectModel);
161       Session session = request.getSession();
162 
163       //Create a new HashMap for our results.  Will be used to
164       //pass to the transformer (xsl page)
165       Map results = new HashMap();
166       
167             
168       String errorMessage = null;
169       String message = null;
170       
171 		String action = request.getParameter(ACTION);
172       String processAction = request.getParameter(PROCESS_ACTION);
173       System.out.println("the action = " + action + " and processAction = " + processAction);
174       if(processAction != null && processAction.length() > 0 ) {
175          action = processAction;
176       }
177       String endpoint = null;
178       SecurityManagerResolver smr = null;
179       SecurityServiceResolver ssr = null;
180       PolicyManagerResolver pmr = null;
181       try {
182           smr = new SecurityManagerResolver();
183           ssr = new SecurityServiceResolver();
184           pmr = new PolicyManagerResolver();
185       } catch (MalformedURLException e1) {
186           log.error("Unable to create registry URL", e1);
187           errorMessage = "No registry url foSecurityManagerResolverund";
188           //throw new LoginException("Unable to contact registry.  Please check your registry URL",e1);
189       }
190 
191       
192             
193       System.out.println("By default at the moment secure connections are turned off");
194       String secureConn = "off";//CommunityConfig.getProperty("portal.security","on");
195       String securePort = null;//CommunityConfig.getProperty("portal.secure.port",String.valueOf(request.getServerPort()));
196       String nonSecurePort = null;//CommunityConfig.getProperty("portal.nonsecure.port",String.valueOf(request.getServerPort()));      
197       
198       String redirect_url = null;
199       if(HTTPS_CONNECTION.equals(secureConn) && 
200          (ACTION_INSERT_ACCOUNT.equals(action) || ACTION_CHANGE_PASSWORD.equals(action) )) {
201          if(!request.isSecure()) {
202             if(securePort == null || securePort.length() <= 0) {
203                errorMessage = "Cannot find a secure url port for redirecting which is required for this operation.";
204                results.put(ACTION,action);
205                results.put("errormessage",errorMessage);
206                results.put("message",message);
207                return results;               
208             }else {
209                try {
210                   redirect_url = "https://" + request.getServerName() + ":" +
211                                securePort + request.getRequestURI() + "?" +
212                                request.getQueryString();
213                   System.out.println(redirect_url);
214                   redirector.redirect(true,redirect_url);
215                 }catch(Exception e) {
216                    e.printStackTrace();
217                 }
218             }
219          }
220       }else {
221          if(request.isSecure()) {
222             try {
223                redirect_url = "http://" + request.getServerName() + ":" +
224                                            request.getServerPort() + request.getRequestURI() + "?" +
225                                            request.getQueryString();               
226                System.out.println(redirect_url);
227                redirector.redirect(true,redirect_url);
228              }catch(Exception e) {
229                 e.printStackTrace();
230              }
231          }
232       }
233       
234 		if(DEBUG_FLAG) {
235 			System.out.println("the action is = " + action);		
236 		}
237       
238       //AdministrationDelegate adminDelegate = new AdministrationDelegate();
239 
240       String ident = (String)request.getParameter(IDENT);
241       if(ident != null && ident.trim().length() > 0 ) {
242          ident = ident.trim();
243          ident = ident.toLowerCase();  
244       }
245       boolean isAdmin = false;
246       LinkedHashMap actionTable = new LinkedHashMap();
247 /*
248       try {
249          adminDelegate.getPassword(comm_account);
250       }catch(Exception e) {
251         e.printStackTrace();  
252       }      
253 */
254       if((String)session.getAttribute(SessionKeys.USER) == null || ((String)session.getAttribute(SessionKeys.USER)).trim().length() <= 0 ) {
255          actionTable.put(ACTION_INSERT_ACCOUNT,"Insert Account");
256       }else {         
257          actionTable.put(ACTION_CHANGE_PASSWORD,"Change Password");
258          actionTable.put(ACTION_INSERT_ACCOUNT,"Insert Account");
259          /*
260          try {
261             isAdmin = adminDelegate.isAdminAccount(comm_account,community_name);
262          }catch(Exception e) {
263             e.printStackTrace();
264             isAdmin = false;
265          }
266          */
267          
268          /*
269          isAdmin = true;
270 
271          if(isAdmin) {
272             actionTable.put(ACTION_INSERT_ACCOUNT,"Insert Account");
273             actionTable.put(ACTION_REMOVE_ACCOUNT,"Remove Account");
274             actionTable.put(ACTION_INSERT_GROUP,"Insert Group");
275             actionTable.put(ACTION_REMOVE_GROUP,"Remove Group");
276             actionTable.put(ACTION_INSERT_COMMUNITY,"Insert Community");
277             actionTable.put(ACTION_REMOVE_COMMUNITY,"Remove Community");
278             actionTable.put(ACTION_INSERT_RESOURCE,"Insert Resource");
279             actionTable.put(ACTION_REMOVE_RESOURCE,"Remove Resource");
280             actionTable.put(ACTION_INSERT_MEMBER,"Insert Member");            
281             actionTable.put(ACTION_REMOVE_MEMBER,"Remove Member");
282             actionTable.put(ACTION_INSERT_PERMISSION,"Insert Permission");
283             actionTable.put(ACTION_REMOVE_PERMISSION,"Remove Permission");
284             actionTable.put(ACTION_VIEW_COMMUNITY,"View Community");
285             actionTable.put(ACTION_VIEW_ACCOUNTS,"View Accounts");
286             actionTable.put(ACTION_VIEW_RESOURCES,"View Resources");
287             actionTable.put(ACTION_VIEW_GROUPS,"View Groups");
288             actionTable.put(ACTION_CHANGE_PASSWORD,"Change of Password");
289          }else {            
290             actionTable.put(ACTION_VIEW_GROUPS,"View Groups");
291             actionTable.put(ACTION_CHANGE_PASSWORD,"Change of Password");
292          }
293          */
294       }      
295       
296       session.setAttribute("actionlist",actionTable);
297       
298       String community = request.getParameter("community");
299 // DAVE 2003.09.18 19:53
300 //      if(community == null || community.length() > 0) {
301       if(community == null || community.length() <= 0) {
302          community = (String)session.getAttribute("community_name");
303       }
304       /*
305       if(community == null || community.length() <= 0) {
306          community = CommunityConfig.getCommunityName();
307       }
308       */
309       
310       /*
311       if(ACTION_INSERT_PERMISSION.equals(action)) {
312          try {
313           ArrayList al = adminDelegate.getGroupList(community);
314           session.setAttribute(PARAM_GROUP_LIST,al);
315          }catch(Exception e) {
316              errorMessage = e.toString();
317              e.printStackTrace();
318          }         
319       }
320       */
321       /*
322       if(ACTION_REMOVE_GROUP.equals(action) || ACTION_VIEW_GROUPS.equals(action) ||
323          ACTION_REMOVE_MEMBER.equals(action) || ACTION_INSERT_MEMBER.equals(action) ||
324          ACTION_REMOVE_PERMISSION.equals(action)) {
325         try {
326          ArrayList al = adminDelegate.getGroupList(community_name);
327          session.setAttribute(PARAM_GROUP_LIST,al);
328         }catch(Exception e) {
329             errorMessage = e.toString();
330             e.printStackTrace();
331         }
332       }
333       */
334       /*
335       if(ACTION_REMOVE_COMMUNITY.equals(action) || ACTION_VIEW_COMMUNITY.equals(action) ||
336          ACTION_INSERT_MEMBER.equals(action)) {
337         try {
338          ArrayList al = adminDelegate.getCommunityList();
339          session.setAttribute(PARAM_COMMUNITY_LIST,al);
340         }catch(Exception e) {
341             errorMessage = e.toString();
342             e.printStackTrace();
343         }
344       }
345       */
346       /*
347       if(ACTION_REMOVE_RESOURCE.equals(action) ||  ACTION_INSERT_PERMISSION.equals(action)
348          || ACTION_REMOVE_PERMISSION.equals(action) || ACTION_VIEW_RESOURCES.equals(action) ) {
349         try {
350          ArrayList al = adminDelegate.getResourceList();
351          session.setAttribute(PARAM_RESOURCE_LIST,al);
352         }catch(Exception e) {
353             errorMessage = e.toString();
354             e.printStackTrace();
355         }
356       }
357       */
358       /*
359       if(ACTION_REMOVE_ACCOUNT.equals(action) || ACTION_REMOVE_MEMBER.equals(action) 
360          || ACTION_INSERT_MEMBER.equals(action) || ACTION_VIEW_ACCOUNTS.equals(action)) {
361               try {
362                ArrayList al = adminDelegate.getAccountList(community);
363                session.setAttribute(PARAM_ACCOUNT_LIST,al);
364               }catch(Exception e) {
365                   errorMessage = e.toString();
366                   e.printStackTrace();
367               }
368        }      
369       */
370       /*
371       if(ACTION_INSERT_GROUP.equals(processAction)) {
372          if(ident != null && ident.length() > 0) {
373             
374             try {
375                GroupData gd = adminDelegate.addGroup(ident);
376                gd.setDescription(request.getParameter("description"));
377                gd.setType(GroupData.MULTI_TYPE);
378                adminDelegate.setGroup(gd);
379                message = "Group was Inserted.";
380             }catch(Exception e) {
381                errorMessage = e.toString();
382                e.printStackTrace();
383             }
384          }else {
385             errorMessage = "Cannot insert an empty group";
386          }
387       }
388       */
389       /*
390       else if(ACTION_REMOVE_GROUP.equals(processAction)) {
391          
392          if(ident != null && ident.length() > 0) {
393             if(ident.indexOf("admin") != -1 || ident.indexOf("guest") != -1) {
394                errorMessage = "You cannot delete Admin or Guest group";
395             }else {
396                try {
397                   adminDelegate.delGroup(ident);
398                   message = "Group was deleted";
399                }catch(Exception e) {
400                   errorMessage = e.toString();
401                   e.printStackTrace();
402                }
403             }
404          }else {
405             errorMessage = "No group found to remove";
406          } 
407       } else if(ACTION_INSERT_COMMUNITY.equals(processAction)) {
408          if(ident != null && ident.length() > 0) {
409             try {
410                CommunityData commData = adminDelegate.addCommunity(ident);
411                String managerURL = request.getParameter("managerurl");
412                String serviceURL = request.getParameter("serviceurl");
413                message = "Community inserted.";
414                if(managerURL != null && managerURL.length() > 0) {
415                   commData.setManagerUrl(managerURL);
416 
417                }
418                if(serviceURL != null && serviceURL.length() > 0) {
419                   commData.setServiceUrl(serviceURL);
420                }
421                if(serviceURL != null || managerURL != null) {
422                   adminDelegate.setCommunity(commData);                  
423                }
424 
425             }catch(Exception e) {
426                errorMessage = e.toString();
427                e.printStackTrace();
428             }
429          }else {
430             errorMessage = "Cannot insert an empty community";
431          } 
432       } else if(ACTION_REMOVE_COMMUNITY.equals(processAction)) {
433          if(ident != null && ident.length() > 0) {
434             try {
435                adminDelegate.delCommunity(ident);
436                message = "Community deleted";
437             }catch(Exception e) {
438                errorMessage = e.toString();
439                e.printStackTrace();
440             }
441          }else {
442             errorMessage = "No insert empty community";
443          } 
444       } else
445       */
446        Ivorn userIvo = null;
447        SecurityManagerDelegate smd = null;
448        if(ACTION_INSERT_ACCOUNT.equals(processAction)) {
449          String communityName = request.getParameter("community_belong");
450          if(ident != null && ident.length() > 0 && communityName != null && communityName.length() > 0) {
451             
452             //String homeSpace = request.getParameter("community_homespace");
453             String displayName = request.getParameter("community_displayname");
454             
455             
456             String pass = request.getParameter("password");
457             if(pass == null || pass.trim().length() <= 0) {
458                errorMessage = "You cannot have no or empty password";
459             }
460             else {
461                try {
462                   
463                   PolicyManagerDelegate pmd = pmr.resolve(userIvo = new Ivorn(communityName+"/"+ident,null));
464                   smd = smr.resolve(userIvo);
465                   
466                   //pmsd.
467                   //AccountData ad = adminDelegate.addAccount(ident);
468                   AccountData ad = new AccountData();
469                   ad.setDescription(request.getParameter("description"));
470                   //ad.setHomeSpace(homeSpace);
471                   ad.setDisplayName(displayName);
472                   //ad.setIdent(ident);
473                   ad.setIdent(userIvo.toString());
474                   pmd.addAccount(ad);
475                   smd.setPassword(ad.getIdent(),pass);
476                   message = "Account inserted.";
477                   session.setAttribute("community_account",ad.getIdent());
478                }catch(Exception e) {
479                   e.printStackTrace();
480                   errorMessage = "Internal problem communicating with Community service.";
481                }
482             }
483          }else {
484             errorMessage = "No account name or community name given to insert";
485          } 
486       }else if(ACTION_CHANGE_PASSWORD.equals(processAction)) {
487          String password = request.getParameter("current_password");
488          String newpassword = request.getParameter("new_password");
489          String verifypassword = request.getParameter("verify_password");
490          
491          SecurityToken st = null;
492          try {
493             //String ivo_account = (String)session.getAttribute("community_authority") + "/" + (String)session.getAttribute(SessionKeys.USER); 
494             String ivo_account = (String)session.getAttribute(SessionKeys.USER);
495             SecurityServiceDelegate ssd = ssr.resolve(userIvo = new Ivorn(ivo_account));
496             smd = smr.resolve(userIvo);
497             
498             st = ssd.checkPassword(userIvo.toString(),password);
499             if(st != null && st.isValid()) {
500                if(newpassword.equals(verifypassword)) {
501                   if(newpassword == null || newpassword.trim().length() <= 0) {
502                      errorMessage = "You cannot have an empty new password";
503                   }else {
504                      //int newPasswordHashed = newpassword.hashCode();
505                      //ad.setPassword(String.valueOf(newPasswordHashed));
506                      //adminDelegate.setAccount(ad);
507 //                     adminDelegate.setPassword(String.valueOf(newPasswordHashed));
508                      //adminDelegate.setPassword(ident,newpassword);
509                      smd.setPassword(userIvo.toString(),newpassword);
510                      message = "Account's password changed.";
511                   }
512                }else {
513                   errorMessage = "Your new password and the verification password do not match.";
514                }
515             }else {
516                errorMessage = "Your current password is not what is in our system.";
517             }            
518          } catch(CommunitySecurityException cse) {
519             cse.printStackTrace();
520             errorMessage = "Your current password is not what is in our system.";
521          } catch(Exception e) {
522             e.printStackTrace();
523             errorMessage = "Internal problem communicating with Community service.";
524          }
525       }
526       /*
527        
528        else if(ACTION_REMOVE_ACCOUNT.equals(processAction)) {
529          if(ident != null && ident.length() > 0) {
530             try {
531                adminDelegate.delAccount(ident);
532                message = "Account deleted";
533             }catch(Exception e) {
534                errorMessage = e.toString();
535                e.printStackTrace();
536             }
537          }else {
538             errorMessage = "No account given to remove";
539          } 
540       } else if(ACTION_INSERT_PERMISSION.equals(processAction)) {
541 
542          if(ident != null && ident.length() > 0) {
543             try {
544                System.out.println("entered insertpermission = " + ident);
545                String permGroup = request.getParameter("group");
546                String permAction = request.getParameter("policy");
547                if(permGroup == null || permGroup.trim().length() <= 0 ||
548                   permAction == null || permAction.trim().length() <= 0) {
549                   errorMessage = "both the group and action must be filled in.";
550                }else {
551                   permGroup = permGroup.trim().toLowerCase();
552                   permAction = permAction.trim().toLowerCase();
553                   adminDelegate.addPermission(ident,permGroup,permAction);
554                   message = "Permission inserted";
555                }
556             }catch(Exception e) {
557                errorMessage = e.toString();
558                e.printStackTrace();
559             }
560          }else {
561             errorMessage = "All parameters required for inserting permission";
562          } 
563       } else if(ACTION_REMOVE_PERMISSION.equals(processAction)) {
564          if(ident != null && ident.length() > 0) {
565             try {
566                String permGroup = request.getParameter("group");
567                String permAction = request.getParameter("policy");
568                if(permGroup == null || permGroup.trim().length() <= 0 ||
569                   permAction == null || permAction.trim().length() <= 0) {
570                   errorMessage = "both the group and action must be filled in.";
571                }else {
572                   permGroup = permGroup.trim().toLowerCase();
573                   permAction = permAction.trim().toLowerCase();                  
574                   adminDelegate.delPermission(ident,permGroup,permAction);
575                   message = "Permission removed";                  
576                }               
577                
578             }catch(Exception e) {
579                errorMessage = e.toString();
580                e.printStackTrace();
581             }
582          }else {
583             errorMessage = "No Permission given to remove.";
584          } 
585       } else if(ACTION_CHANGE_PASSWORD.equals(processAction)) {
586          ident = (String)session.getAttribute("community_account");
587          if(ident != null && ident.length() > 0) {
588             try {
589                ident = (String)session.getAttribute("community_account");
590                String accountPassword = adminDelegate.getPassword(ident);
591                AccountData ad = adminDelegate.getAccount(ident);
592                String password = request.getParameter("current_password");
593                String newpassword = request.getParameter("new_password");
594                String verifypassword = request.getParameter("verify_password");
595                if(accountPassword.equals(password)) {
596                   if(newpassword.equals(verifypassword)) {
597                      if(newpassword == null || newpassword.trim().length() <= 0) {
598                         errorMessage = "You cannot have an empty new password";
599                      }else {
600                         int newPasswordHashed = newpassword.hashCode();
601                         ad.setPassword(String.valueOf(newPasswordHashed));
602                         adminDelegate.setAccount(ad);
603 //                        adminDelegate.setPassword(String.valueOf(newPasswordHashed));
604                         adminDelegate.setPassword(ident,newpassword);
605                         message = "Account's password changed.";                        
606                      }
607                   }else {
608                      errorMessage = "Your new password and the verification password do not match.";
609                   }
610                }else {
611                   errorMessage = "Your current password is not what is in our system.";
612                }
613                
614             }catch(Exception e) {
615                errorMessage = e.toString();
616                e.printStackTrace();
617             }
618          }else {
619             errorMessage = "No insert empty community";
620          } 
621       } else if(ACTION_INSERT_MEMBER.equals(processAction)) {
622          if(ident != null && ident.length() > 0) {
623             try {
624                adminDelegate.addGroupMember(ident,request.getParameter("group"));
625                message = "Member added.";
626             }catch(Exception e) {
627                errorMessage = e.toString();
628                e.printStackTrace();
629             }
630          }else {
631             errorMessage = "No insert empty community";
632          } 
633       } else if(ACTION_REMOVE_MEMBER.equals(processAction)) {
634          if(ident != null && ident.length() > 0) {
635             try {
636                adminDelegate.delGroupMember(ident,request.getParameter("group"));
637                message = "Member removed.";
638             }catch(Exception e) {
639                errorMessage = e.toString();
640                e.printStackTrace();
641             }
642          }else {
643             errorMessage = "No insert empty community";
644          } 
645       } else if(ACTION_INSERT_RESOURCE.equals(processAction)) {
646               if(ident != null && ident.length() > 0) {
647                  try {
648                     ResourceData rd = adminDelegate.addResource(ident);
649                     rd.setDescription(request.getParameter("description"));
650                     adminDelegate.setResource(rd);
651                     message = "Resource inserted.";
652                  }catch(Exception e) {
653                     errorMessage = e.toString();
654                     e.printStackTrace();
655                  }
656               }else {
657                  errorMessage = "No insert empty community";
658               } 
659       } else if(ACTION_REMOVE_RESOURCE.equals(processAction)) {
660            if(ident != null && ident.length() > 0) {
661               try {
662                  adminDelegate.delResource(ident);
663                  message = "Resource removed.";
664               }catch(Exception e) {
665                  errorMessage = e.toString();
666                  e.printStackTrace();
667               }
668            }else {
669               errorMessage = "No insert empty community";
670            } 
671       }      
672 		*/
673 		//
674 		results.put(ACTION,action);
675       results.put("errormessage",errorMessage);
676       results.put("message",message);
677 		return results;
678 	}	
679 }