01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.lenya.cms.ac.usecases;
19:
20: import org.apache.lenya.ac.Group;
21:
22: /**
23: * Usecase to change the profile of a group.
24: *
25: * @version $Id: GroupProfile.java 407305 2006-05-17 16:21:49Z andreas $
26: */
27: public class GroupProfile extends AccessControlUsecase {
28:
29: protected static final String ID = "groupId";
30: protected static final String NAME = "name";
31: protected static final String DESCRIPTION = "description";
32:
33: private Group group;
34:
35: protected void doExecute() throws Exception {
36: super .doExecute();
37:
38: String name = getParameterAsString(NAME);
39: String description = getParameterAsString(DESCRIPTION);
40:
41: this .group.setName(name);
42: this .group.setDescription(description);
43:
44: this .group.save();
45: }
46:
47: /**
48: * @see org.apache.lenya.cms.usecase.Usecase#setParameter(java.lang.String, java.lang.Object)
49: */
50: public void setParameter(String name, Object value) {
51: super .setParameter(name, value);
52:
53: if (name.equals(ID)) {
54: String id = (String) value;
55: this .group = getGroupManager().getGroup(id);
56: if (this .group == null) {
57: throw new RuntimeException("Group [" + id
58: + "] not found.");
59: }
60:
61: setParameter(DESCRIPTION, this.group.getDescription());
62: setParameter(NAME, this.group.getName());
63: }
64: }
65: }
|