From c13d9948bf4e95e06a7c0e944bf669b74a8c97e3 Mon Sep 17 00:00:00 2001 From: IlhemEssaadi Date: Wed, 28 Feb 2024 16:11:59 +0100 Subject: [PATCH 1/2] feat: Add active external Visio connector to profile property settings list - EXO-69942 This commit adds the external Visio connectors active for users to the list of profile property settings. --- services/pom.xml | 6 ++- .../ExternalVisioConnectorService.java | 5 ++- .../ExternalVisioConnectorServiceImpl.java | 40 +++++++++++++++++-- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/services/pom.xml b/services/pom.xml index 25c372e..4b8a92c 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -64,6 +64,10 @@ along with this program. If not, see jar provided - + + org.exoplatform.social + social-component-api + provided + diff --git a/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/ExternalVisioConnectorService.java b/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/ExternalVisioConnectorService.java index ec44e40..dc2656a 100644 --- a/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/ExternalVisioConnectorService.java +++ b/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/ExternalVisioConnectorService.java @@ -16,6 +16,7 @@ */ package org.exoplatform.webconferencing.externalvisio.service; +import org.exoplatform.commons.ObjectAlreadyExistsException; import org.exoplatform.commons.exception.ObjectNotFoundException; import org.exoplatform.webconferencing.externalvisio.entity.ExternalVisioConnectorEntity; import org.exoplatform.webconferencing.externalvisio.rest.model.ExternalVisioConnector; @@ -25,13 +26,13 @@ public interface ExternalVisioConnectorService { - ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity); + ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectAlreadyExistsException; List getExternalVisioConnectors(boolean enabled); void saveExternalVisioConnectors(ExternalVisioConnectors externalVisioConnectors); - ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException; + ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException, ObjectAlreadyExistsException; List getActiveExternalVisioConnectorsForSpace(); } diff --git a/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/impl/ExternalVisioConnectorServiceImpl.java b/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/impl/ExternalVisioConnectorServiceImpl.java index 3bda608..b079d3f 100644 --- a/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/impl/ExternalVisioConnectorServiceImpl.java +++ b/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/impl/ExternalVisioConnectorServiceImpl.java @@ -17,7 +17,10 @@ package org.exoplatform.webconferencing.externalvisio.service.impl; import org.apache.commons.collections.CollectionUtils; +import org.exoplatform.commons.ObjectAlreadyExistsException; import org.exoplatform.commons.exception.ObjectNotFoundException; +import org.exoplatform.social.core.profileproperty.ProfilePropertyService; +import org.exoplatform.social.core.profileproperty.model.ProfilePropertySetting; import org.exoplatform.webconferencing.externalvisio.dao.ExternalVisioConnectorDAO; import org.exoplatform.webconferencing.externalvisio.entity.ExternalVisioConnectorEntity; import org.exoplatform.webconferencing.externalvisio.rest.model.ExternalVisioConnector; @@ -31,18 +34,24 @@ public class ExternalVisioConnectorServiceImpl implements ExternalVisioConnectorService { private final ExternalVisioConnectorDAO externalVisioConnectorDAO; + + private final ProfilePropertyService profilePropertyService; - public ExternalVisioConnectorServiceImpl(ExternalVisioConnectorDAO externalVisioConnectorDAO) { + public ExternalVisioConnectorServiceImpl(ExternalVisioConnectorDAO externalVisioConnectorDAO, + ProfilePropertyService profilePropertyService) { this.externalVisioConnectorDAO = externalVisioConnectorDAO; + this.profilePropertyService = profilePropertyService; } @Override - public ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) { + public ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectAlreadyExistsException { if (externalVisioConnectorEntity == null) { throw new IllegalArgumentException("externalVisioConnectorEntity is mandatory"); } - + if (externalVisioConnectorEntity.isActiveForUsers()) { + createPropertySetting(externalVisioConnectorEntity); + } return EntityBuilder.fromEntity(externalVisioConnectorDAO.create(externalVisioConnectorEntity)); } @@ -76,7 +85,8 @@ private void processUpdatedExternalVisioConnectors(List }); } - public ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException { + public ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException, + ObjectAlreadyExistsException { if (externalVisioConnectorEntity == null) { throw new IllegalArgumentException("externalVisioConnectorEntity is mandatory"); } @@ -89,6 +99,16 @@ public ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnecto if (oldExternalVisioConnectorEntity.equals(externalVisioConnectorEntity)) { throw new IllegalArgumentException("there are no changes to save"); } + ProfilePropertySetting profilePropertySetting = + profilePropertyService.getProfileSettingByName(oldExternalVisioConnectorEntity.getName()); + + if (profilePropertySetting != null) { + profilePropertySetting.setPropertyName(externalVisioConnectorEntity.getName()); + profilePropertySetting.setActive(externalVisioConnectorEntity.isActiveForUsers()); + profilePropertyService.updatePropertySetting(profilePropertySetting); + } else if (externalVisioConnectorEntity.isActiveForUsers()) { + createPropertySetting(externalVisioConnectorEntity); + } return EntityBuilder.fromEntity(externalVisioConnectorDAO.update(externalVisioConnectorEntity)); } @@ -97,4 +117,16 @@ public List getActiveExternalVisioConnectorsForSpace() { List activeVisioConnectorEntityList = externalVisioConnectorDAO.getActiveExternalVisioConnectorsForSpace(); return activeVisioConnectorEntityList.stream().map(EntityBuilder::fromEntity).toList(); } + + public void createPropertySetting(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectAlreadyExistsException { + ProfilePropertySetting profilePropertySetting = new ProfilePropertySetting(); + profilePropertySetting.setActive(true); + profilePropertySetting.setEditable(true); + profilePropertySetting.setVisible(false); + profilePropertySetting.setPropertyName(externalVisioConnectorEntity.getName()); + profilePropertySetting.setGroupSynchronized(false); + profilePropertySetting.setRequired(false); + profilePropertySetting.setMultiValued(false); + profilePropertyService.createPropertySetting(profilePropertySetting); + } } From 3ae3412b8f64377a2b8ab5018fd24d5a45cba915 Mon Sep 17 00:00:00 2001 From: IlhemEssaadi Date: Thu, 29 Feb 2024 09:49:53 +0100 Subject: [PATCH 2/2] fix review --- .../ExternalVisioConnectorService.java | 6 +++--- .../ExternalVisioConnectorServiceImpl.java | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/ExternalVisioConnectorService.java b/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/ExternalVisioConnectorService.java index dc2656a..233bb02 100644 --- a/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/ExternalVisioConnectorService.java +++ b/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/ExternalVisioConnectorService.java @@ -26,13 +26,13 @@ public interface ExternalVisioConnectorService { - ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectAlreadyExistsException; + ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity); List getExternalVisioConnectors(boolean enabled); void saveExternalVisioConnectors(ExternalVisioConnectors externalVisioConnectors); - - ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException, ObjectAlreadyExistsException; + + ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException; List getActiveExternalVisioConnectorsForSpace(); } diff --git a/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/impl/ExternalVisioConnectorServiceImpl.java b/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/impl/ExternalVisioConnectorServiceImpl.java index b079d3f..37e43f1 100644 --- a/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/impl/ExternalVisioConnectorServiceImpl.java +++ b/services/src/main/java/org/exoplatform/webconferencing/externalvisio/service/impl/ExternalVisioConnectorServiceImpl.java @@ -19,10 +19,13 @@ import org.apache.commons.collections.CollectionUtils; import org.exoplatform.commons.ObjectAlreadyExistsException; import org.exoplatform.commons.exception.ObjectNotFoundException; +import org.exoplatform.services.log.ExoLogger; +import org.exoplatform.services.log.Log; import org.exoplatform.social.core.profileproperty.ProfilePropertyService; import org.exoplatform.social.core.profileproperty.model.ProfilePropertySetting; import org.exoplatform.webconferencing.externalvisio.dao.ExternalVisioConnectorDAO; import org.exoplatform.webconferencing.externalvisio.entity.ExternalVisioConnectorEntity; +import org.exoplatform.webconferencing.externalvisio.rest.ExternalVisioConnectorRest; import org.exoplatform.webconferencing.externalvisio.rest.model.ExternalVisioConnector; import org.exoplatform.webconferencing.externalvisio.rest.model.ExternalVisioConnectors; import org.exoplatform.webconferencing.externalvisio.rest.util.EntityBuilder; @@ -33,6 +36,8 @@ public class ExternalVisioConnectorServiceImpl implements ExternalVisioConnectorService { + private static final Log LOG = ExoLogger.getLogger(ExternalVisioConnectorServiceImpl.class); + private final ExternalVisioConnectorDAO externalVisioConnectorDAO; private final ProfilePropertyService profilePropertyService; @@ -45,7 +50,7 @@ public ExternalVisioConnectorServiceImpl(ExternalVisioConnectorDAO externalVisio } @Override - public ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectAlreadyExistsException { + public ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) { if (externalVisioConnectorEntity == null) { throw new IllegalArgumentException("externalVisioConnectorEntity is mandatory"); } @@ -85,8 +90,7 @@ private void processUpdatedExternalVisioConnectors(List }); } - public ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException, - ObjectAlreadyExistsException { + public ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException { if (externalVisioConnectorEntity == null) { throw new IllegalArgumentException("externalVisioConnectorEntity is mandatory"); } @@ -118,7 +122,7 @@ public List getActiveExternalVisioConnectorsForSpace() { return activeVisioConnectorEntityList.stream().map(EntityBuilder::fromEntity).toList(); } - public void createPropertySetting(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectAlreadyExistsException { + public void createPropertySetting(ExternalVisioConnectorEntity externalVisioConnectorEntity) { ProfilePropertySetting profilePropertySetting = new ProfilePropertySetting(); profilePropertySetting.setActive(true); profilePropertySetting.setEditable(true); @@ -127,6 +131,11 @@ public void createPropertySetting(ExternalVisioConnectorEntity externalVisioConn profilePropertySetting.setGroupSynchronized(false); profilePropertySetting.setRequired(false); profilePropertySetting.setMultiValued(false); - profilePropertyService.createPropertySetting(profilePropertySetting); + + try { + profilePropertyService.createPropertySetting(profilePropertySetting); + } catch (ObjectAlreadyExistsException e) { + LOG.warn("Profile property " + profilePropertySetting.getPropertyName() + " already exists"); + } } }