Skip to content

Commit

Permalink
feat: Add active external Visio connector to profile property setting…
Browse files Browse the repository at this point in the history
…s list - EXO-69942_68649 (#16)

This commit adds the external Visio connectors active for users to the list of profile property settings.
  • Loading branch information
IlhemEssaadi committed Mar 4, 2024
1 parent 1be677f commit 5bdf9b6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
6 changes: 5 additions & 1 deletion services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ along with this program. If not, see <http://www.gnu.org/licenses
<type>jar</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.exoplatform.social</groupId>
<artifactId>social-component-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,7 +31,7 @@ public interface ExternalVisioConnectorService {
List<ExternalVisioConnector> getExternalVisioConnectors(boolean enabled);

void saveExternalVisioConnectors(ExternalVisioConnectors externalVisioConnectors);

ExternalVisioConnector updateExternalVisioConnector(ExternalVisioConnectorEntity externalVisioConnectorEntity) throws ObjectNotFoundException;

List<ExternalVisioConnector> getActiveExternalVisioConnectorsForSpace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

}

Expand All @@ -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));

}
Expand Down Expand Up @@ -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));
}

Expand All @@ -97,4 +121,21 @@ public List<ExternalVisioConnector> getActiveExternalVisioConnectorsForSpace() {
List<ExternalVisioConnectorEntity> 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");
}
}
}

0 comments on commit 5bdf9b6

Please sign in to comment.