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.console.panels;
20  
21  import java.util.Date;
22  import org.apache.commons.lang3.time.DateFormatUtils;
23  import org.apache.syncope.client.ui.commons.DateOps;
24  import org.apache.syncope.client.ui.commons.markup.html.form.AjaxDateTimeFieldPanel;
25  import org.apache.syncope.client.ui.commons.markup.html.form.AjaxSpinnerFieldPanel;
26  import org.apache.syncope.client.ui.commons.markup.html.form.AjaxTextFieldPanel;
27  import org.apache.syncope.common.lib.scim.SCIMConf;
28  import org.apache.syncope.common.lib.scim.SCIMGeneralConf;
29  import org.apache.wicket.model.Model;
30  import org.apache.wicket.model.PropertyModel;
31  
32  public class SCIMConfGeneralPanel extends SCIMConfTabPanel {
33  
34      private static final long serialVersionUID = 2765863608539154422L;
35  
36      public SCIMConfGeneralPanel(final String id, final SCIMConf scimConf) {
37          super(id);
38  
39          SCIMGeneralConf scimGeneralConf = scimConf.getGeneralConf();
40  
41          AjaxDateTimeFieldPanel creationDatePanel =
42                  new AjaxDateTimeFieldPanel("creationDate", "creationDate", new Model<>() {
43  
44                      private static final long serialVersionUID = 7075312408615929880L;
45  
46                      @Override
47                      public Date getObject() {
48                          return DateOps.convert(scimGeneralConf.getCreationDate());
49                      }
50  
51                      @Override
52                      public void setObject(final Date object) {
53                          scimGeneralConf.setCreationDate(DateOps.toOffsetDateTime(object));
54                      }
55                  }, DateFormatUtils.ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT);
56          creationDatePanel.setEnabled(false);
57  
58          AjaxDateTimeFieldPanel lastChangeDatePanel =
59                  new AjaxDateTimeFieldPanel("lastChangeDate", "lastChangeDate", new Model<>() {
60  
61                      private static final long serialVersionUID = 7075312408615929880L;
62  
63                      @Override
64                      public Date getObject() {
65                          return DateOps.convert(scimGeneralConf.getLastChangeDate());
66                      }
67  
68                      @Override
69                      public void setObject(final Date object) {
70                          scimGeneralConf.setLastChangeDate(DateOps.toOffsetDateTime(object));
71                      }
72                  }, DateFormatUtils.ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT);
73          lastChangeDatePanel.setEnabled(false);
74  
75          AjaxSpinnerFieldPanel<Integer> bulkMaxOperationsPanel = new AjaxSpinnerFieldPanel.Builder<Integer>().
76                  build("bulkMaxOperations", "bulkMaxOperations", Integer.class,
77                          new PropertyModel<>(scimGeneralConf, "bulkMaxOperations"));
78  
79          AjaxSpinnerFieldPanel<Integer> bulkMaxPayloadSizePanel = new AjaxSpinnerFieldPanel.Builder<Integer>().
80                  build("bulkMaxPayloadSize", "bulkMaxPayloadSize", Integer.class,
81                          new PropertyModel<>(scimGeneralConf, "bulkMaxPayloadSize"));
82  
83          AjaxSpinnerFieldPanel<Integer> filterMaxResultsPanel = new AjaxSpinnerFieldPanel.Builder<Integer>().
84                  build("filterMaxResults", "filterMaxResults", Integer.class,
85                          new PropertyModel<>(scimGeneralConf, "filterMaxResults"));
86  
87          AjaxTextFieldPanel eTagValuePanel = new AjaxTextFieldPanel("eTagValue", "eTagValue",
88                  new PropertyModel<>("eTagValue", "eTagValue") {
89  
90              private static final long serialVersionUID = -6427731218492117883L;
91  
92              @Override
93              public String getObject() {
94                  return scimGeneralConf.getETagValue();
95              }
96  
97              @Override
98              public void setObject(final String object) {
99                  // nothing to do
100             }
101         });
102         eTagValuePanel.setEnabled(false);
103 
104         add(creationDatePanel);
105         add(lastChangeDatePanel);
106         add(bulkMaxOperationsPanel);
107         add(bulkMaxPayloadSizePanel);
108         add(filterMaxResultsPanel);
109         add(eTagValuePanel);
110     }
111 }