KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > projector > processor > security > ListRoles


1 package org.apache.slide.projector.processor.security;
2
3 import java.util.Map JavaDoc;
4
5 import org.apache.slide.projector.Context;
6 import org.apache.slide.projector.Processor;
7 import org.apache.slide.projector.Projector;
8 import org.apache.slide.projector.Result;
9 import org.apache.slide.projector.URI;
10 import org.apache.slide.projector.descriptor.ParameterDescriptor;
11 import org.apache.slide.projector.descriptor.ResultDescriptor;
12 import org.apache.slide.projector.descriptor.ResultEntryDescriptor;
13 import org.apache.slide.projector.descriptor.StateDescriptor;
14 import org.apache.slide.projector.descriptor.URIValueDescriptor;
15 import org.apache.slide.projector.i18n.DefaultMessage;
16 import org.apache.slide.projector.i18n.ParameterMessage;
17 import org.apache.slide.projector.value.ArrayValue;
18
19 /**
20  * @version $Revision: 1.3 $
21  */

22
23 public class ListRoles implements Processor {
24     private final static String JavaDoc USER = "user";
25
26     private final static String JavaDoc ROLES = "roles";
27     private final static String JavaDoc OK = "ok";
28     private final static String JavaDoc FAILED = "failed";
29
30     private final static ParameterDescriptor [] parameterDescriptor = new ParameterDescriptor[] {
31             new ParameterDescriptor(USER, new ParameterMessage("listRoles/parameter/user"), new URIValueDescriptor())
32         };
33
34     private final static ResultDescriptor resultDescriptor = new ResultDescriptor(
35             new StateDescriptor[] { StateDescriptor.OK_DESCRIPTOR },
36             new ResultEntryDescriptor[] {
37                 new ResultEntryDescriptor(ROLES, new DefaultMessage("listRoles/result/roles"), ArrayValue.CONTENT_TYPE, false)
38             });
39
40     public Result process(Map JavaDoc parameter, Context context) throws Exception JavaDoc {
41         URI user = (URI)parameter.get(USER);
42         ArrayValue roles = Projector.getRepository().listRoles(user, context.getCredentials());
43         return new Result(StateDescriptor.OK, ROLES, roles);
44     }
45
46     public ParameterDescriptor[] getParameterDescriptors() {
47         return parameterDescriptor;
48     }
49
50     public ResultDescriptor getResultDescriptor() {
51         return resultDescriptor;
52     }
53 }
Popular Tags