KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > applications > ApplicationShortcutChangeEvent


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.applications;
21
22 import java.util.Iterator JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import com.sslexplorer.core.CoreAttributeConstants;
26 import com.sslexplorer.extensions.ApplicationParameterDefinition;
27 import com.sslexplorer.extensions.ExtensionDescriptor;
28 import com.sslexplorer.extensions.store.ExtensionStore;
29 import com.sslexplorer.policyframework.ResourceChangeEvent;
30 import com.sslexplorer.security.SessionInfo;
31
32
33 /**
34  * Extension of {@link ResourceChangeEvent} specifically for
35  * {@link ApplicationShortcut} resources.
36  *
37  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
38  */

39 public class ApplicationShortcutChangeEvent extends ResourceChangeEvent {
40
41     /**
42      * Constructor.
43      *
44      * @param source source
45      * @param id id
46      * @param session session
47      * @param exception error
48      */

49     public ApplicationShortcutChangeEvent(Object JavaDoc source, int id, SessionInfo session, Throwable JavaDoc exception) {
50         super(source, id, session, exception);
51     }
52
53     /**
54      * Constructor.
55      *
56      * @param source source
57      * @param id id
58      * @param shortcut client configuration
59      * @param session session
60      * @param state state
61      */

62     public ApplicationShortcutChangeEvent(Object JavaDoc source, int id, ApplicationShortcut shortcut, SessionInfo session, int state) {
63         super(source, id, shortcut, session, state);
64         if(shortcut != null) {
65             addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_ID, shortcut.getApplication());
66             try {
67                 ExtensionDescriptor des = ExtensionStore.getInstance().getExtensionDescriptor(shortcut.getApplication());
68                 if(des != null) {
69                     addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_NAME, des.getName());
70                     for (Iterator JavaDoc i = des.getParametersAndDefaults().entrySet().iterator(); i.hasNext();) {
71                         Map.Entry JavaDoc entry = (Map.Entry JavaDoc) i.next();
72                         String JavaDoc val = (String JavaDoc)shortcut.getParameters().get(entry.getKey());
73                         ApplicationParameterDefinition def = (ApplicationParameterDefinition) entry.getValue();
74                         addAttribute(def.getName(), def.getType() == ApplicationParameterDefinition.TYPE_PASSWORD ? "******" : ( val == null ? "" : val ) );
75                     }
76                 }
77             }
78             catch(Exception JavaDoc e) {
79             }
80         }
81     }
82     
83     /**
84      * Get the application shortcut object. This will be <code>null</code>
85      * if the event was constructed for an error.
86      *
87      * @return application shortcut
88      */

89     public ApplicationShortcut getClientConfiguration() {
90         return ((ApplicationShortcut)getResource());
91     }
92
93 }
94
Popular Tags