From 5bdf9b6cd3f56cd9ad3d5b59cf093dae9bb7d7db Mon Sep 17 00:00:00 2001 From: IlhemEssaadi <93516534+IlhemEssaadi@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:10:03 +0100 Subject: [PATCH] feat: Add active external Visio connector to profile property settings list - EXO-69942_68649 (#16) This commit adds the external Visio connectors active for users to the list of profile property settings. --- services/pom.xml | 6 ++- .../ExternalVisioConnectorService.java | 3 +- .../ExternalVisioConnectorServiceImpl.java | 45 ++++++++++++++++++- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/services/pom.xml b/services/pom.xml index f30ae64..a4d5360 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..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 @@ -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; @@ -30,7 +31,7 @@ public interface ExternalVisioConnectorService { List getExternalVisioConnectors(boolean enabled); void saveExternalVisioConnectors(ExternalVisioConnectors externalVisioConnectors); - + 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 3bda608..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 @@ -17,9 +17,15 @@ 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.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; @@ -30,10 +36,16 @@ public class ExternalVisioConnectorServiceImpl implements ExternalVisioConnectorService { + private static final Log LOG = ExoLogger.getLogger(ExternalVisioConnectorServiceImpl.class); + private final ExternalVisioConnectorDAO externalVisioConnectorDAO; + + private final ProfilePropertyService profilePropertyService; - public ExternalVisioConnectorServiceImpl(ExternalVisioConnectorDAO externalVisioConnectorDAO) { + public ExternalVisioConnectorServiceImpl(ExternalVisioConnectorDAO externalVisioConnectorDAO, + ProfilePropertyService profilePropertyService) { this.externalVisioConnectorDAO = externalVisioConnectorDAO; + this.profilePropertyService = profilePropertyService; } @@ -42,7 +54,9 @@ public ExternalVisioConnector createExternalVisioConnector(ExternalVisioConnecto if (externalVisioConnectorEntity == null) { throw new IllegalArgumentException("externalVisioConnectorEntity is mandatory"); } - + if (externalVisioConnectorEntity.isActiveForUsers()) { + createPropertySetting(externalVisioConnectorEntity); + } return EntityBuilder.fromEntity(externalVisioConnectorDAO.create(externalVisioConnectorEntity)); } @@ -89,6 +103,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 +121,21 @@ public List getActiveExternalVisioConnectorsForSpace() { List activeVisioConnectorEntityList = externalVisioConnectorDAO.getActiveExternalVisioConnectorsForSpace(); return activeVisioConnectorEntityList.stream().map(EntityBuilder::fromEntity).toList(); } + + public void createPropertySetting(ExternalVisioConnectorEntity externalVisioConnectorEntity) { + 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); + + try { + profilePropertyService.createPropertySetting(profilePropertySetting); + } catch (ObjectAlreadyExistsException e) { + LOG.warn("Profile property " + profilePropertySetting.getPropertyName() + " already exists"); + } + } }