Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add active external Visio connector to profile property settings list - EXO-69942_68649 #16

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}
}
Loading