View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.ui.commons.wizards.any;
20  
21  import org.apache.commons.collections4.ListUtils;
22  import org.apache.commons.lang3.StringUtils;
23  import org.apache.syncope.client.ui.commons.ajax.markup.html.LabelInfo;
24  import org.apache.syncope.common.lib.to.AnyTO;
25  import org.apache.wicket.extensions.wizard.WizardModel.ICondition;
26  import org.apache.wicket.extensions.wizard.WizardStep;
27  import org.apache.wicket.markup.html.WebMarkupContainer;
28  import org.apache.wicket.markup.html.basic.Label;
29  
30  public abstract class AbstractGroups extends WizardStep implements ICondition {
31  
32      private static final long serialVersionUID = 552437609667518888L;
33  
34      protected static final int MAX_GROUP_LIST_CARDINALITY = 30;
35  
36      protected final AnyTO anyTO;
37  
38      protected WebMarkupContainer dyngroupsContainer;
39  
40      protected WebMarkupContainer dynrealmsContainer;
41  
42      protected WebMarkupContainer groupsContainer;
43  
44      public <T extends AnyTO> AbstractGroups(final AnyWrapper<T> modelObject) {
45          super();
46          this.anyTO = modelObject.getInnerObject();
47  
48          setOutputMarkupId(true);
49  
50          groupsContainer = new WebMarkupContainer("groupsContainer");
51          groupsContainer.setOutputMarkupId(true);
52          groupsContainer.setOutputMarkupPlaceholderTag(true);
53          add(groupsContainer);
54  
55          // ------------------
56          // insert changed label if needed
57          // ------------------
58          if (modelObject instanceof UserWrapper
59                  && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
60                  && !ListUtils.isEqualList(
61                          UserWrapper.class.cast(modelObject).getInnerObject().getMemberships(),
62                          UserWrapper.class.cast(modelObject).getPreviousUserTO().getMemberships())) {
63              groupsContainer.add(new LabelInfo("changed", StringUtils.EMPTY));
64          } else {
65              groupsContainer.add(new Label("changed", StringUtils.EMPTY));
66          }
67          // ------------------
68      }
69  
70      protected abstract void addGroupsPanel();
71  
72      protected abstract void addDynamicRealmsContainer();
73  
74      protected abstract void addDynamicGroupsContainer();
75  
76      @Override
77      public boolean evaluate() {
78          return true;
79      }
80  }