[SYNCOPE-156] merge from master
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/1dce5383 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/1dce5383 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/1dce5383 Branch: refs/heads/master Commit: 1dce5383d52ca0eb89d289acc8d6e04b4f5ead82 Parents: 0419594 0098875 Author: fmartelli <[email protected]> Authored: Wed Sep 9 12:08:55 2015 +0200 Committer: fmartelli <[email protected]> Committed: Wed Sep 9 12:08:55 2015 +0200 ---------------------------------------------------------------------- .gitignore | 1 - .../main/resources/archetype-resources/pom.xml | 134 ----------- archetype/src/main/resources/meta-pom.xml | 37 +-- .../console/SyncopeConsoleApplication.java | 8 +- .../syncope/client/console/pages/Login.java | 1 + .../console/pages/MustChangePassword.java | 120 ++++++++++ .../client/console/panels/ConnectorModal.java | 10 +- .../client/console/panels/GroupModalPanel.java | 5 +- .../console/panels/GroupSearchResultPanel.java | 2 +- .../client/console/panels/RealmDetails.java | 3 +- .../client/console/panels/RealmModalPanel.java | 6 +- .../client/console/panels/ResourceModal.java | 2 - .../client/console/rest/UserSelfRestClient.java | 10 +- .../console/topology/WebSocketBehavior.java | 29 ++- .../wicket/markup/html/form/FieldPanel.java | 2 +- .../syncope/client/console/pages/Login.html | 5 +- .../console/pages/MustChangePassword.html | 62 ++++++ .../console/pages/MustChangePassword.properties | 21 ++ .../pages/MustChangePassword_it.properties | 21 ++ .../pages/MustChangePassword_pt_BR.properties | 21 ++ .../html/form/AjaxPasswordFieldPanel.html | 9 +- .../client/lib/RestClientExceptionMapper.java | 101 ++++++--- .../syncope/common/lib/AnyOperations.java | 2 + .../apache/syncope/common/lib/mod/UserMod.java | 13 +- .../apache/syncope/common/lib/to/RealmTO.java | 28 +++ .../apache/syncope/common/lib/to/SyncopeTO.java | 19 +- .../apache/syncope/common/lib/to/UserTO.java | 10 + .../common/lib/types/ClientExceptionType.java | 10 +- .../syncope/common/lib/types/Entitlement.java | 4 + .../common/lib/types/EntityViolationType.java | 2 +- .../rest/api/service/UserSelfService.java | 14 +- .../syncope/core/logic/AbstractAnyLogic.java | 154 ++++++++++++- .../syncope/core/logic/AnyObjectLogic.java | 68 +++--- .../apache/syncope/core/logic/GroupLogic.java | 72 +++--- .../apache/syncope/core/logic/SyncopeLogic.java | 7 +- .../apache/syncope/core/logic/UserLogic.java | 134 +++++------ .../init/ClassPathScanImplementationLookup.java | 16 +- .../syncope/core/logic/init/LoggerLoader.java | 2 - core/logic/src/main/resources/logic.properties | 1 - core/logic/src/main/resources/logicContext.xml | 1 - .../syncope/core/misc/ConnObjectUtils.java | 139 +----------- .../apache/syncope/core/misc/MappingUtils.java | 9 +- .../apache/syncope/core/misc/TemplateUtils.java | 223 +++++++++++++++++++ .../core/misc/security/AuthDataAccessor.java | 76 +++---- .../DelegatedAdministrationException.java | 33 +++ .../misc/security/MustChangePasswordFilter.java | 80 +++++++ .../security/SyncopeAccessDeniedHandler.java | 43 ++++ .../SyncopeAuthenticationEntryPoint.java | 43 ++++ .../misc/security/UnauthorizedException.java | 33 --- .../misc/spring/ApplicationContextProvider.java | 11 - .../DomainTransactionInterceptorInjector.java | 38 ++++ .../misc/src/main/resources/securityContext.xml | 19 +- .../persistence/api/ImplementationLookup.java | 1 + .../persistence/api/entity/AnyTemplate.java | 32 +++ .../api/entity/AnyTemplateRealm.java | 26 +++ .../core/persistence/api/entity/Realm.java | 13 +- .../api/entity/task/AnyTemplate.java | 38 ---- .../api/entity/task/AnyTemplateSyncTask.java | 28 +++ .../persistence/api/entity/task/SyncTask.java | 8 +- .../core/persistence/api/entity/user/User.java | 4 + .../persistence/jpa/dao/JPAAnyObjectDAO.java | 4 +- .../core/persistence/jpa/dao/JPAAnyTypeDAO.java | 4 + .../core/persistence/jpa/dao/JPAGroupDAO.java | 4 +- .../core/persistence/jpa/dao/JPARealmDAO.java | 2 + .../core/persistence/jpa/dao/JPAUserDAO.java | 4 +- .../core/persistence/jpa/dao/SearchSupport.java | 6 +- .../jpa/entity/JPAAnyTemplateRealm.java | 61 +++++ .../jpa/entity/JPAEntityFactory.java | 11 +- .../core/persistence/jpa/entity/JPARealm.java | 57 +++++ .../entity/resource/AbstractAnyTemplate.java | 74 ++++++ .../jpa/entity/task/JPAAnyTemplate.java | 104 --------- .../jpa/entity/task/JPAAnyTemplateSyncTask.java | 61 +++++ .../jpa/entity/task/JPASyncTask.java | 21 +- .../jpa/entity/user/JPADynRoleMembership.java | 2 +- .../jpa/entity/user/JPAUDynGroupMembership.java | 2 +- .../persistence/jpa/entity/user/JPAUser.java | 34 +-- .../entity/ProvisioningTaskValidator.java | 7 +- .../jpa/validation/entity/RealmValidator.java | 36 ++- .../resources/META-INF/spring-orm-oracle.xml | 15 +- .../resources/META-INF/spring-orm-sqlserver.xml | 15 +- .../src/main/resources/META-INF/spring-orm.xml | 15 +- .../src/main/resources/domains.xml | 4 +- .../src/main/resources/indexes.xml | 8 +- .../src/main/resources/views.xml | 24 +- .../core/persistence/jpa/outer/TaskTest.java | 5 +- .../test/resources/domains/MasterContent.xml | 32 +-- .../core/provisioning/api/AnyTransformer.java | 33 --- .../core/provisioning/api/LogicActions.java | 40 ++++ .../core/provisioning/api/sync/PushActions.java | 52 +++-- .../core/provisioning/api/sync/SyncActions.java | 54 +++-- .../java/DefaultAnyTransformer.java | 40 ---- .../provisioning/java/DefaultLogicActions.java | 57 +++++ .../java/data/AnyObjectDataBinderImpl.java | 8 +- .../java/data/GroupDataBinderImpl.java | 2 +- .../java/data/RealmDataBinderImpl.java | 63 ++++++ .../java/data/TaskDataBinderImpl.java | 61 +---- .../java/data/UserDataBinderImpl.java | 14 +- .../java/sync/AbstractSyncResultHandler.java | 34 +-- .../java/sync/DBPasswordSyncActions.java | 14 +- .../java/sync/DefaultPushActions.java | 20 +- .../java/sync/DefaultSyncActions.java | 38 ++-- .../java/sync/LDAPMembershipSyncActions.java | 8 +- .../java/sync/LDAPPasswordSyncActions.java | 14 +- .../provisioning/java/sync/SyncJobDelegate.java | 2 +- core/rest-cxf/pom.xml | 4 - .../rest/cxf/RestServiceExceptionMapper.java | 23 +- .../rest/cxf/service/UserSelfServiceImpl.java | 12 +- .../core/logic/init/CamelRouteLoader.java | 39 +--- fit/core-reference/pom.xml | 28 ++- .../reference/DoubleValueAnyTransformer.java | 75 ------- .../core/reference/DoubleValueLogicActions.java | 75 +++++++ .../fit/core/reference/TestSyncActions.java | 14 +- .../resources/jboss/domains/MasterDomain.xml | 4 +- .../main/resources/jboss/domains/TwoDomain.xml | 131 +++++++++++ .../src/main/resources/logic.properties | 1 - .../resources/mariadb/domains/Master.properties | 28 +++ .../resources/mariadb/persistence.properties | 30 --- .../resources/mariadb/provisioning.properties | 24 ++ .../resources/mysql/domains/Master.properties | 28 +++ .../main/resources/mysql/persistence.properties | 30 --- .../resources/mysql/provisioning.properties | 24 ++ .../resources/oracle/domains/Master.properties | 28 +++ .../resources/oracle/persistence.properties | 30 --- .../resources/oracle/provisioning.properties | 24 ++ .../postgres/domains/Master.properties | 28 +++ .../resources/postgres/persistence.properties | 29 --- .../resources/postgres/provisioning.properties | 24 ++ .../sqlserver/domains/Master.properties | 28 +++ .../resources/sqlserver/persistence.properties | 30 --- .../resources/sqlserver/provisioning.properties | 24 ++ .../core/reference/AuthenticationITCase.java | 8 +- .../syncope/fit/core/reference/GroupITCase.java | 2 +- .../syncope/fit/core/reference/UserITCase.java | 12 +- .../fit/core/reference/UserSelfITCase.java | 32 +++ .../fit/core/reference/VirAttrITCase.java | 98 ++++++++ installer/pom.xml | 4 +- .../installer/files/MasterDomainXml.java | 35 +++ .../installer/files/MasterProperties.java | 97 ++++++++ .../files/PersistenceContextEMFactoryXml.java | 34 --- .../installer/files/PersistenceProperties.java | 110 --------- .../installer/files/ProvisioningProperties.java | 69 ++++++ .../installer/processes/ArchetypeProcess.java | 64 +++--- .../installer/processes/BaseProcess.java | 10 +- .../installer/processes/ContainerProcess.java | 119 ++++------ .../installer/processes/PersistenceProcess.java | 59 ++--- .../installer/utilities/FileSystemUtils.java | 1 + .../syncope/installer/utilities/MavenUtils.java | 8 +- .../src/main/resources/installer.properties | 6 +- .../main/resources/izpack/ProcessPanel.Spec.xml | 2 - installer/src/main/resources/modelerPom.xml | 2 +- pom.xml | 13 +- src/site/xdoc/downloads.xml | 16 +- src/site/xdoc/release-process.xml | 2 +- 153 files changed, 3093 insertions(+), 1755 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java ---------------------------------------------------------------------- diff --cc client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java index 9c5a1d8,dd12e64..5c03587 --- a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java @@@ -33,7 -30,7 +34,8 @@@ import org.apache.syncope.client.consol import org.apache.syncope.client.console.resources.FilesystemResource; import org.apache.syncope.client.console.resources.WorkflowDefGETResource; import org.apache.syncope.client.console.resources.WorkflowDefPUTResource; +import org.apache.syncope.client.console.themes.AdminLTE; + import org.apache.syncope.common.lib.types.Entitlement; import org.apache.wicket.Page; import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession; import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication; http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/client/console/src/main/java/org/apache/syncope/client/console/pages/MustChangePassword.java ---------------------------------------------------------------------- diff --cc client/console/src/main/java/org/apache/syncope/client/console/pages/MustChangePassword.java index 0000000,8c1e341..5396561 mode 000000,100644..100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/MustChangePassword.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/pages/MustChangePassword.java @@@ -1,0 -1,120 +1,120 @@@ + /* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.apache.syncope.client.console.pages; + + import org.apache.syncope.client.console.SyncopeConsoleSession; + import org.apache.syncope.client.console.commons.Constants; + import org.apache.syncope.client.console.panels.NotificationPanel; + import org.apache.syncope.client.console.rest.UserSelfRestClient; + import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPasswordFieldPanel; + import org.apache.wicket.ajax.AjaxRequestTarget; + import org.apache.wicket.ajax.markup.html.form.AjaxButton; + import org.apache.wicket.markup.html.WebPage; + import org.apache.wicket.markup.html.form.Form; + import org.apache.wicket.markup.html.form.PasswordTextField; + import org.apache.wicket.markup.html.form.StatelessForm; + import org.apache.wicket.markup.html.form.TextField; + import org.apache.wicket.markup.html.form.validation.EqualPasswordInputValidator; + import org.apache.wicket.model.Model; + import org.apache.wicket.request.mapper.parameter.PageParameters; + import org.apache.wicket.spring.injection.annot.SpringBean; + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + + public class MustChangePassword extends WebPage { + + private static final long serialVersionUID = 5889157642852559004L; + + private static final Logger LOG = LoggerFactory.getLogger(MustChangePassword.class); + + @SpringBean + private UserSelfRestClient userSelfRestClient; + + private final NotificationPanel feedbackPanel; + + private final StatelessForm<Void> form; + + private final TextField<String> usernameField; + + private final AjaxPasswordFieldPanel passwordField; + + private final AjaxPasswordFieldPanel confirmPasswordField; + + public MustChangePassword(final PageParameters parameters) { + super(parameters); + + feedbackPanel = new NotificationPanel(Constants.FEEDBACK); + add(feedbackPanel); + + form = new StatelessForm<>("changePassword"); + form.setOutputMarkupId(true); + + usernameField = new TextField<>("username", new Model<>(SyncopeConsoleSession.get().getSelfTO().getUsername())); + usernameField.setMarkupId("username"); + usernameField.setEnabled(false); + form.add(usernameField); + + passwordField = new AjaxPasswordFieldPanel("password", "password", new Model<String>()); + passwordField.setRequired(true); + passwordField.setMarkupId("password"); - passwordField.setPlaceholder(getString("password")); ++ passwordField.setPlaceholder("password"); + ((PasswordTextField) passwordField.getField()).setResetPassword(true); + form.add(passwordField); + + confirmPasswordField = new AjaxPasswordFieldPanel("confirmPassword", "confirmPassword", new Model<String>()); + confirmPasswordField.setRequired(true); + confirmPasswordField.setMarkupId("confirmPassword"); - confirmPasswordField.setPlaceholder(getString("confirmPassword")); ++ confirmPasswordField.setPlaceholder("confirmPassword"); + ((PasswordTextField) confirmPasswordField.getField()).setResetPassword(true); + form.add(confirmPasswordField); + + form.add(new EqualPasswordInputValidator(passwordField.getField(), confirmPasswordField.getField())); + + AjaxButton submitButton = new AjaxButton("submit", new Model<>(getString("submit"))) { + + private static final long serialVersionUID = 429178684321093953L; + + @Override + protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { + try { + userSelfRestClient.changePassword(passwordField.getModelObject()); + + SyncopeConsoleSession.get().invalidate(); + + setResponsePage(getApplication().getHomePage()); + } catch (Exception e) { + LOG.error("While changing password for {}", + SyncopeConsoleSession.get().getSelfTO().getUsername(), e); + error(getString(Constants.ERROR) + ": " + e.getMessage()); + feedbackPanel.refresh(target); + } + } + + @Override + protected void onError(final AjaxRequestTarget target, final Form<?> form) { + feedbackPanel.refresh(target); + } + + }; + form.add(submitButton); + form.setDefaultButton(submitButton); + + add(form); + } + } http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupModalPanel.java ---------------------------------------------------------------------- diff --cc client/console/src/main/java/org/apache/syncope/client/console/panels/GroupModalPanel.java index 9594e3f,0000000..b8150aa mode 100644,000000..100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupModalPanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupModalPanel.java @@@ -1,122 -1,0 +1,121 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.client.console.panels; + +import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal; +import org.apache.commons.lang3.SerializationUtils; +import org.apache.syncope.client.console.commons.Constants; +import org.apache.syncope.client.console.commons.Mode; +import org.apache.syncope.common.lib.AnyOperations; +import org.apache.syncope.common.lib.mod.GroupMod; +import org.apache.syncope.common.lib.to.GroupTO; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxButton; +import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.model.CompoundPropertyModel; +import org.apache.wicket.model.ResourceModel; + +/** + * Modal window with Group form. + */ +public class GroupModalPanel extends AbstractModalPanel { + + private static final long serialVersionUID = -1732493223434085205L; + + protected final Mode mode; + + protected final boolean createFlag; + + protected final GroupPanel groupPanel; + + protected GroupTO originalGroupTO; + - public GroupModalPanel(final String id, final Modal window, final GroupTO groupTO) { ++ public GroupModalPanel(final String id, final Modal<?> window, final GroupTO groupTO) { + this(id, window, groupTO, Mode.ADMIN); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) - public GroupModalPanel(final String id, final Modal window, final GroupTO groupTO, final Mode mode) { ++ public GroupModalPanel(final String id, final Modal<?> window, final GroupTO groupTO, final Mode mode) { + + super(id); + + this.mode = mode; + + this.createFlag = groupTO.getKey() == 0; + if (!createFlag) { + originalGroupTO = SerializationUtils.clone(groupTO); + } + + final Form<GroupTO> form = new Form<>("groupForm"); + form.setMultiPart(true); + + add(new Label("displayName", groupTO.getKey() == 0 ? "" : groupTO.getDisplayName())); + + form.setModel(new CompoundPropertyModel<>(groupTO)); + + this.groupPanel = new GroupPanel.Builder("groupPanel"). + form(form).groupTO(groupTO).groupModalPageMode(mode).build(); + form.add(groupPanel); + + final AjaxButton submit = new IndicatingAjaxButton(SUBMIT, new ResourceModel(SUBMIT)) { + + private static final long serialVersionUID = -958724007591692537L; + + @Override + protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { + try { + submitAction(target, form); - + } catch (Exception e) { + LOG.error("Failure managing groupTO {}", groupTO, e); + error(getString(Constants.ERROR) + ": " + e.getMessage()); + feedbackPanel.refresh(target); + } + } + + @Override + protected void onError(final AjaxRequestTarget target, final Form<?> form) { + feedbackPanel.refresh(target); + } + }; + form.add(submit); + form.setDefaultButton(submit); + } + + protected void submitAction(final AjaxRequestTarget target, final Form<?> form) { + final GroupTO groupTO = (GroupTO) form.getDefaultModelObject(); + + GroupTO result; + if (createFlag) { + result = groupRestClient.create(groupTO); + } else { + GroupMod groupMod = AnyOperations.diff(groupTO, groupTO); + + // update group just if it is changed + if (groupMod.isEmpty()) { + result = groupTO; + } else { + result = groupRestClient.update(originalGroupTO.getETagValue(), groupMod); + } + } + + //setResponsePage(new ResultStatusModal.Builder(window, result).build()); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java ---------------------------------------------------------------------- diff --cc client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java index b58acd8,0000000..cfa05a1 mode 100644,000000..100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java @@@ -1,230 -1,0 +1,230 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.client.console.panels; + +import de.agilecoders.wicket.extensions.markup.html.bootstrap.behavior.Draggable; +import de.agilecoders.wicket.extensions.markup.html.bootstrap.behavior.DraggableConfig; +import de.agilecoders.wicket.extensions.markup.html.bootstrap.behavior.Resizable; +import java.io.Serializable; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import org.apache.syncope.client.console.commons.Constants; +import org.apache.syncope.client.console.pages.GroupDisplayAttributesModalPage; +import org.apache.syncope.client.console.rest.AbstractAnyRestClient; +import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn; +import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AttrColumn; +import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal; +import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink; +import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink.ActionType; +import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel; +import org.apache.syncope.common.lib.SyncopeClientException; +import org.apache.syncope.common.lib.to.AnyTO; +import org.apache.syncope.common.lib.to.AnyTypeClassTO; +import org.apache.syncope.common.lib.to.GroupTO; +import org.apache.syncope.common.lib.types.SchemaType; +import org.apache.wicket.Page; +import org.apache.wicket.PageReference; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; +import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; +import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.ResourceModel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.ReflectionUtils; + +public class GroupSearchResultPanel extends AnySearchResultPanel { + + private static final long serialVersionUID = -1100228004207271270L; + + protected static final Logger LOG = LoggerFactory.getLogger(GroupSearchResultPanel.class); + + private final String entitlement = "GROUP_READ"; + + private final BaseModal<AbstractModalPanel> editModal; + + public GroupSearchResultPanel(final String type, final String parentId, + final boolean filtered, final String fiql, final PageReference callerRef, + final AbstractAnyRestClient restClient, final List<AnyTypeClassTO> anyTypeClassTOs, final String realm) { + + super(type, parentId, filtered, fiql, callerRef, restClient, anyTypeClassTOs, realm); + + editModal = new BaseModal<>("editModal"); + editModal.add(new Resizable().withChildSelector(".modal-content")); + editModal.add(new Draggable(new DraggableConfig().withHandle(".modal-header").withCursor("move"))); + editModal.setUseKeyboard(true).addCloseButton(); + editModal.setFadeIn(true); + editModal.setFooterVisible(true); + editModal.setHeaderVisible(true); + editModal.setOutputMarkupId(true); + } + + @Override + protected List<IColumn<AnyTO, String>> getColumns() { + + final List<IColumn<AnyTO, String>> columns = new ArrayList<>(); + + for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_DETAILS_VIEW)) { + final Field field = ReflectionUtils.findField(GroupTO.class, name); + + if ("token".equalsIgnoreCase(name)) { + columns.add(new PropertyColumn<AnyTO, String>(new ResourceModel(name, name), name, name)); + } else if (field != null && field.getType().equals(Date.class)) { + columns.add(new PropertyColumn<AnyTO, String>(new ResourceModel(name, name), name, name)); + } else { + columns.add( + new PropertyColumn<AnyTO, String>(new ResourceModel(name, name), name, name)); + } + } + + for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_ATTRIBUTES_VIEW)) { + if (schemaNames.contains(name)) { + columns.add(new AttrColumn(name, SchemaType.PLAIN)); + } + } + + for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_DERIVED_ATTRIBUTES_VIEW)) { + if (dSchemaNames.contains(name)) { + columns.add(new AttrColumn(name, SchemaType.DERIVED)); + } + } + + // Add defaults in case of no selection + if (columns.isEmpty()) { + for (String name : GroupDisplayAttributesModalPage.GROUP_DEFAULT_SELECTION) { + columns.add( + new PropertyColumn<AnyTO, String>(new ResourceModel(name, name), name, name)); + } + + prefMan.setList(getRequest(), getResponse(), Constants.PREF_GROUP_DETAILS_VIEW, + Arrays.asList(GroupDisplayAttributesModalPage.GROUP_DEFAULT_SELECTION)); + } + + columns.add(new ActionColumn<AnyTO, String>(new ResourceModel("actions", "")) { + + private static final long serialVersionUID = -3503023501954863131L; + + @Override - public ActionLinksPanel getActions(final String componentId, final IModel<AnyTO> model) { ++ public ActionLinksPanel<AnyTO> getActions(final String componentId, final IModel<AnyTO> model) { + + final ActionLinksPanel.Builder<AnyTO> panel = ActionLinksPanel.builder(page.getPageReference()); + + panel.add(new ActionLink<AnyTO>() { + + private static final long serialVersionUID = -7978723352517770644L; + + @Override + public void onClick(final AjaxRequestTarget target, final AnyTO anyTO) { + editModal.addOrReplace(new GroupModalPanel( + BaseModal.getModalContentId(), editModal, (GroupTO) model.getObject())); + + target.add(editModal); + editModal.show(target); + } + }, ActionLink.ActionType.EDIT, entitlement).add(new ActionLink<AnyTO>() { + + private static final long serialVersionUID = -7978723352517770644L; + + @Override + public void onClick(final AjaxRequestTarget target, final AnyTO anyTO) { + try { + final GroupTO groupTO = (GroupTO) restClient. + delete(model.getObject().getETagValue(), model.getObject().getKey()); + + //editmodal.setContent(new ResultStatusModal.Builder(editmodal, groupTO).build()); +// editModal.addOrReplace(new GroupModalPanel( +// BaseModal.getModalContentId(), editModal, (GroupTO) model.getObject())); +// +// target.add(editModal); +// editModal.show(target); + } catch (SyncopeClientException scce) { + error(getString(Constants.OPERATION_ERROR) + ": " + scce.getMessage()); + feedbackPanel.refresh(target); + } + } + }, ActionLink.ActionType.DELETE, entitlement); + + return panel.build(componentId); + } + + @Override + public ActionLinksPanel getHeader(final String componentId) { + final ActionLinksPanel.Builder<Serializable> panel = ActionLinksPanel.builder(page.getPageReference()); + + panel.add(new ActionLink<Serializable>() { + + private static final long serialVersionUID = -7978723352517770644L; + + @Override + public void onClick(final AjaxRequestTarget target, final Serializable ignore) { + displaymodal.setPageCreator(new ModalWindow.PageCreator() { + + private static final long serialVersionUID = -7834632442532690940L; + + @Override + public Page createPage() { + return new GroupDisplayAttributesModalPage( + page.getPageReference(), displaymodal, schemaNames, dSchemaNames); + } + }); + + displaymodal.show(target); + } + }, ActionLink.ActionType.CHANGE_VIEW, entitlement); + + panel.add(new ActionLink<Serializable>() { + + private static final long serialVersionUID = -7978723352517770644L; + + @Override + public void onClick(final AjaxRequestTarget target, final Serializable ignore) { + if (target != null) { + target.add(container); + } + } + }, ActionLink.ActionType.RELOAD, entitlement); + + return panel.build(componentId); + } + }); + + return columns; + } + + @Override + protected <T extends AnyTO> Collection<ActionLink.ActionType> getBulkActions() { + final List<ActionType> bulkActions = new ArrayList<>(); + + bulkActions.add(ActionType.DELETE); + bulkActions.add(ActionType.SUSPEND); + bulkActions.add(ActionType.REACTIVATE); + + return bulkActions; + } + + @Override + protected String getPageId() { + return pageID; + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/client/console/src/main/java/org/apache/syncope/client/console/panels/RealmDetails.java ---------------------------------------------------------------------- diff --cc client/console/src/main/java/org/apache/syncope/client/console/panels/RealmDetails.java index a106402,391dba2..b9abec3 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/RealmDetails.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/RealmDetails.java @@@ -18,8 -18,8 +18,9 @@@ */ package org.apache.syncope.client.console.panels; +import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel; +import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel; + import org.apache.syncope.common.lib.to.RealmTO; -import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.PropertyModel; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/client/console/src/main/java/org/apache/syncope/client/console/panels/RealmModalPanel.java ---------------------------------------------------------------------- diff --cc client/console/src/main/java/org/apache/syncope/client/console/panels/RealmModalPanel.java index 36409e8,0000000..29506f4 mode 100644,000000..100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/RealmModalPanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/RealmModalPanel.java @@@ -1,119 -1,0 +1,119 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.client.console.panels; + +import static org.apache.wicket.Component.ENABLE; + +import com.googlecode.wicket.jquery.ui.markup.html.link.AjaxSubmitLink; +import org.apache.syncope.client.console.SyncopeConsoleSession; +import org.apache.syncope.client.console.commons.Constants; +import org.apache.syncope.client.console.pages.BasePage; +import org.apache.syncope.client.console.rest.RealmRestClient; +import org.apache.syncope.client.console.wicket.markup.html.bootstrap.buttons.PrimaryModalButton; +import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal; +import org.apache.syncope.common.lib.to.RealmTO; +import org.apache.wicket.PageReference; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.model.CompoundPropertyModel; +import org.apache.wicket.spring.injection.annot.SpringBean; + +public class RealmModalPanel extends AbstractModalPanel { + + private static final long serialVersionUID = -4285220460543213901L; + + protected RealmTO realmTO; + + private final PageReference pageRef; + + private final BaseModal<RealmTO> modal; + + @SpringBean + private RealmRestClient realmRestClient; + + private final String parentPath; + + public RealmModalPanel( + final String id, + final PageReference pageRef, + final BaseModal<RealmTO> modal, + final RealmTO realmTO, + final String parentPath, + final String entitlement) { + + super(id); + + this.pageRef = pageRef; + this.modal = modal; + this.realmTO = realmTO; + this.parentPath = parentPath; + + final Form<RealmTO> form = new Form<>("realmForm"); + form.setModel(new CompoundPropertyModel<>(realmTO)); + - final RealmDetails<RealmTO> realmDetail = new RealmDetails<>("details", realmTO); ++ final RealmDetails realmDetail = new RealmDetails("details", realmTO); + if (SyncopeConsoleSession.get().owns(entitlement)) { + MetaDataRoleAuthorizationStrategy.authorize(realmDetail, ENABLE, entitlement); + } + form.add(realmDetail); + + final AjaxSubmitLink submit = getOnSubmit(form); + modal.addFooterInput(submit); + add(form); + } + - protected PrimaryModalButton getOnSubmit(final Form form) { - return new PrimaryModalButton(modal.getModalInputId(), "submit", form) { ++ protected final PrimaryModalButton getOnSubmit(final Form form) { ++ return new PrimaryModalButton(BaseModal.getModalInputId(), "submit", form) { + + private static final long serialVersionUID = -958724007591692537L; + + @Override + protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { + try { + submitAction(target, form); + + if (pageRef.getPage() instanceof BasePage) { + ((BasePage) pageRef.getPage()).setModalResult(true); + } + + closeAction(target, form); + } catch (Exception e) { + LOG.error("While creating or updating realm", e); + error(getString(Constants.ERROR) + ": " + e.getMessage()); + feedbackPanel.refresh(target); + } + } + + @Override + protected void onError(final AjaxRequestTarget target, final Form<?> form) { + feedbackPanel.refresh(target); + } + }; + } + + protected void submitAction(final AjaxRequestTarget target, final Form<?> form) { + final RealmTO updatedRealmTO = (RealmTO) form.getModelObject(); + realmRestClient.create(this.parentPath, updatedRealmTO); + } + + protected void closeAction(final AjaxRequestTarget target, final Form<?> form) { + this.modal.close(target); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/FieldPanel.java ---------------------------------------------------------------------- diff --cc client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/FieldPanel.java index ed95c4c,e0f2f3e..3a48d38 --- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/FieldPanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/FieldPanel.java @@@ -128,7 -122,7 +128,7 @@@ public abstract class FieldPanel<T> ext } public T getModelObject() { -- return (T) field.getModelObject(); ++ return field.getModelObject(); } public FieldPanel<T> setNewModel(final IModel<T> model) { http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/client/console/src/main/resources/org/apache/syncope/client/console/pages/Login.html ---------------------------------------------------------------------- diff --cc client/console/src/main/resources/org/apache/syncope/client/console/pages/Login.html index 3b8a3d4,6d6c397..ce13f8f --- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Login.html +++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Login.html @@@ -26,12 -26,17 +26,13 @@@ under the License <title>Apache Syncope - Login</title> <link rel="shortcut icon" href="img/favicon.png" type="image/png"/> - <link href="webjars/bootstrap-select/${bootstrap-select.version}/dist/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" /> + - <link href="webjars/bootstrap/${bootstrap.version}/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> + <link href="webjars/bootstrap-select/${bootstrap-select.version}/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" /> <link href="webjars/font-awesome/${font-awesome.version}/css/font-awesome.min.css" rel="stylesheet" type="text/css" /> <link href="webjars/ionicons/${ionicons.version}/css/ionicons.min.css" rel="stylesheet" type="text/css" /> - <link href="css/AdminLTE.css" rel="stylesheet" type="text/css" /> <link href="css/login.css" rel="stylesheet" type="text/css" /> <link href="css/syncopeConsole.css" rel="stylesheet" type="text/css" /> - <script type="text/javascript" src="webjars/bootstrap-select/${bootstrap-select.version}/dist/js/bootstrap-select.min.js"></script> - - <script type="text/javascript" src="webjars/bootstrap/${bootstrap.version}/js/bootstrap.min.js"></script> + <script type="text/javascript" src="webjars/bootstrap-select/${bootstrap-select.version}/js/bootstrap-select.min.js"></script> </head> <body class="skin-green"> <div class="container"> http://git-wip-us.apache.org/repos/asf/syncope/blob/1dce5383/pom.xml ---------------------------------------------------------------------- diff --cc pom.xml index 6e323f8,6b121bc..c2547a9 --- a/pom.xml +++ b/pom.xml @@@ -375,8 -375,7 +375,10 @@@ under the License <jquery-ui.version>1.11.4</jquery-ui.version> <jquery-cookie.version>1.4.1-1</jquery-cookie.version> <bootstrap.version>3.3.5</bootstrap.version> - <bootstrap-select.version>1.6.3</bootstrap-select.version> ++ + <bootstrap-select.version>1.7.3</bootstrap-select.version> + <wicket-bootstrap.version>0.10.3</wicket-bootstrap.version> ++ <font-awesome.version>4.4.0</font-awesome.version> <ionicons.version>2.0.1</ionicons.version> <highlightjs.version>8.7</highlightjs.version>
