diff --git a/component/api/src/main/java/org/exoplatform/social/metadata/MetadataService.java b/component/api/src/main/java/org/exoplatform/social/metadata/MetadataService.java index 0214d77eb68..ca25e32f121 100644 --- a/component/api/src/main/java/org/exoplatform/social/metadata/MetadataService.java +++ b/component/api/src/main/java/org/exoplatform/social/metadata/MetadataService.java @@ -117,35 +117,6 @@ public interface MetadataService { MetadataItem createMetadataItem(MetadataObject metadataObject, MetadataKey metadataKey, long userIdentityId) throws ObjectAlreadyExistsException; - - /** - * Creates a new Metadata Item. When the metadata with the designated key - * doesn't exists, it will create a new one - * - * @param metadataObject object to store - * @param metadataKey {@link MetadataKey} that contains - * {@link MetadataType} name - * {@link Metadata} name and - * {@link Metadata} audience - * @param properties {@link Map} properties of - * {@link MetadataItem} - * @param userIdentityId {@link Identity} technical identifier - * designating the user making the - * operation - * @param broadcast whether broadcast event after creating or - * not - * @return Created {@link MetadataItem} - * @throws ObjectAlreadyExistsException when the {@link MetadataTypePlugin} - * doesn't allow multiple objects per - * {@link Metadata} and an object is - * already associated to the designated - * {@link Metadata} - */ - MetadataItem createMetadataItem(MetadataObject metadataObject, - MetadataKey metadataKey, - Map properties, - long userIdentityId, - boolean broadcast) throws ObjectAlreadyExistsException; /** * Creates a new Metadata Item. When the metadata with the designated key @@ -172,31 +143,6 @@ MetadataItem createMetadataItem(MetadataObject metadataObject, MetadataKey metadataKey, Map properties, long userIdentityId) throws ObjectAlreadyExistsException; - - /** - * Creates a new Metadata Item. When the metadata with the designated key - * doesn't exists, it will create a new one - * - * @param metadataObject object to store - * @param metadataKey {@link MetadataKey} that contains - * {@link MetadataType} name - * {@link Metadata} name and - * {@link Metadata} audience - * @param properties {@link Map} properties of - * {@link MetadataItem} - * @param broadcast whether broadcast event after creating or - * not - * @return Created {@link MetadataItem} - * @throws ObjectAlreadyExistsException when the {@link MetadataTypePlugin} - * doesn't allow multiple objects per - * {@link Metadata} and an object is - * already associated to the designated - * {@link Metadata} - */ - MetadataItem createMetadataItem(MetadataObject metadataObject, - MetadataKey metadataKey, - Map properties, - boolean broadcast) throws ObjectAlreadyExistsException; /** * Creates a new Metadata Item. When the metadata with the designated key @@ -224,17 +170,7 @@ MetadataItem createMetadataItem(MetadataObject metadataObject, * @param metadataItem {@link MetadataItem} * @param userIdentityId {@link Identity} technical identifier designating the * user making the operation - * @param broadcast whether broadcast event after updating or - * not - * @return Updated {@link MetadataItem} - */ - MetadataItem updateMetadataItem(MetadataItem metadataItem, long userIdentityId, boolean broadcast); - - /** - * @param metadataItem {@link MetadataItem} - * @param userIdentityId {@link Identity} technical identifier designating the - * user making the operation - * @return Updated {@link MetadataItem} + * @return Deleted {@link MetadataItem} */ MetadataItem updateMetadataItem(MetadataItem metadataItem, long userIdentityId); diff --git a/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemAdded.java b/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemAdded.java index 93968673abc..fb16f0dc4a6 100644 --- a/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemAdded.java +++ b/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemAdded.java @@ -16,12 +16,14 @@ package org.exoplatform.social.core.listeners; import org.exoplatform.commons.search.index.IndexingService; +import org.exoplatform.services.listener.Asynchronous; import org.exoplatform.services.listener.Event; import org.exoplatform.social.core.storage.api.ActivityStorage; import org.exoplatform.social.core.storage.api.SpaceStorage; import org.exoplatform.social.metadata.MetadataService; import org.exoplatform.social.metadata.model.MetadataItem; +@Asynchronous public class MetadataItemAdded extends AbstractMetadataItemListener { public MetadataItemAdded(MetadataService metadataService, diff --git a/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemDeleted.java b/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemDeleted.java index b634c4785c3..709624bbeba 100644 --- a/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemDeleted.java +++ b/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemDeleted.java @@ -16,12 +16,14 @@ package org.exoplatform.social.core.listeners; import org.exoplatform.commons.search.index.IndexingService; +import org.exoplatform.services.listener.Asynchronous; import org.exoplatform.services.listener.Event; import org.exoplatform.social.core.storage.api.ActivityStorage; import org.exoplatform.social.core.storage.api.SpaceStorage; import org.exoplatform.social.metadata.MetadataService; import org.exoplatform.social.metadata.model.MetadataItem; +@Asynchronous public class MetadataItemDeleted extends AbstractMetadataItemListener { public MetadataItemDeleted(MetadataService metadataService, diff --git a/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemModified.java b/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemModified.java index 881c36761e0..655096c46ee 100644 --- a/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemModified.java +++ b/component/core/src/main/java/org/exoplatform/social/core/listeners/MetadataItemModified.java @@ -16,12 +16,14 @@ package org.exoplatform.social.core.listeners; import org.exoplatform.commons.search.index.IndexingService; +import org.exoplatform.services.listener.Asynchronous; import org.exoplatform.services.listener.Event; import org.exoplatform.social.core.storage.api.ActivityStorage; import org.exoplatform.social.core.storage.api.SpaceStorage; import org.exoplatform.social.metadata.MetadataService; import org.exoplatform.social.metadata.model.MetadataItem; +@Asynchronous public class MetadataItemModified extends AbstractMetadataItemListener { public MetadataItemModified(MetadataService metadataService, diff --git a/component/core/src/main/java/org/exoplatform/social/core/metadata/MetadataServiceImpl.java b/component/core/src/main/java/org/exoplatform/social/core/metadata/MetadataServiceImpl.java index 20de21edf9b..7b26b062004 100644 --- a/component/core/src/main/java/org/exoplatform/social/core/metadata/MetadataServiceImpl.java +++ b/component/core/src/main/java/org/exoplatform/social/core/metadata/MetadataServiceImpl.java @@ -132,8 +132,7 @@ public MetadataItem createMetadataItem(MetadataObject metadataObject, public MetadataItem createMetadataItem(MetadataObject metadataObject, MetadataKey metadataKey, Map properties, - long userIdentityId, - boolean broadcast) throws ObjectAlreadyExistsException { + long userIdentityId) throws ObjectAlreadyExistsException { validateUserIdentityId(userIdentityId); Metadata metadata = checkAndCreateMetadata(metadataObject, metadataKey, userIdentityId); MetadataItem metadataItem = new MetadataItem(0, @@ -142,22 +141,13 @@ public MetadataItem createMetadataItem(MetadataObject metadataObject, userIdentityId, System.currentTimeMillis(), properties); - return createMetadataItem(metadataItem, userIdentityId, broadcast); + return createMetadataItem(metadataItem, userIdentityId); } - - @Override - public MetadataItem createMetadataItem(MetadataObject metadataObject, - MetadataKey metadataKey, - Map properties, - long userIdentityId) throws ObjectAlreadyExistsException { - return createMetadataItem(metadataObject, metadataKey, properties, userIdentityId, true); - } - + @Override public MetadataItem createMetadataItem(MetadataObject metadataObject, MetadataKey metadataKey, - Map properties, - boolean broadcast) throws ObjectAlreadyExistsException { + Map properties) throws ObjectAlreadyExistsException { Metadata metadata = checkAndCreateMetadata(metadataObject, metadataKey, 0); MetadataItem metadataItem = new MetadataItem(0, metadata, @@ -165,39 +155,25 @@ public MetadataItem createMetadataItem(MetadataObject metadataObject, 0, System.currentTimeMillis(), properties); - return createMetadataItem(metadataItem, 0, broadcast); + return createMetadataItem(metadataItem, 0); } @Override - public MetadataItem createMetadataItem(MetadataObject metadataObject, - MetadataKey metadataKey, - Map properties) throws ObjectAlreadyExistsException { - return createMetadataItem(metadataObject, metadataKey, properties, true); - } - - @Override - public MetadataItem updateMetadataItem(MetadataItem metadataItem, long userIdentityId, boolean broadcast) { + public MetadataItem updateMetadataItem(MetadataItem metadataItem, long userIdentityId) { if (metadataItem == null) { throw new IllegalArgumentException("MetadataItem is mandatory"); } validateMetadataItemId(metadataItem.getId()); validateUserIdentityId(userIdentityId); metadataItem = metadataStorage.updateMetadataItem(metadataItem); - if (broadcast) { - try { - this.listenerService.broadcast("social.metadataItem.updated", userIdentityId, metadataItem); - } catch (Exception e) { - LOG.warn("Error while broadcasting event for metadataItem update", e); - } + try { + this.listenerService.broadcast("social.metadataItem.updated", userIdentityId, metadataItem); + } catch (Exception e) { + LOG.warn("Error while broadcasting event for metadataItem update", e); } return metadataItem; } - @Override - public MetadataItem updateMetadataItem(MetadataItem metadataItem, long userIdentityId) { - return updateMetadataItem(metadataItem, userIdentityId, true); - } - @Override public MetadataItem deleteMetadataItem(long itemId, boolean broadcast) throws ObjectNotFoundException { validateMetadataItemId(itemId); @@ -633,14 +609,12 @@ private Metadata createMetadataAndBroadcast(Metadata metadata, long userIdentity return metadata; } - private MetadataItem createMetadataItem(MetadataItem metadataItem, long userIdentityId, boolean broadcast) { + private MetadataItem createMetadataItem(MetadataItem metadataItem, long userIdentityId) { metadataItem = metadataStorage.createMetadataItem(metadataItem); - if (broadcast) { - try { - this.listenerService.broadcast("social.metadataItem.created", userIdentityId, metadataItem); - } catch (Exception e) { - LOG.warn("Error while broadcasting event for metadata item creation", e); - } + try { + this.listenerService.broadcast("social.metadataItem.created", userIdentityId, metadataItem); + } catch (Exception e) { + LOG.warn("Error while broadcasting event for metadata item creation", e); } return metadataItem; }