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: Revert "feat: Implement createMetadataItem and updateMetadataIt…em with broadcast param - EXO-73685 - Meeds-io/MIPs#128" and make MetadataItem listeners Asynchronous - EXO-73685 - Meeds-io/MIPs#128 #4014

Draft
wants to merge 1 commit into
base: develop-exo
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> properties,
long userIdentityId,
boolean broadcast) throws ObjectAlreadyExistsException;

/**
* Creates a new Metadata Item. When the metadata with the designated key
Expand All @@ -172,31 +143,6 @@ MetadataItem createMetadataItem(MetadataObject metadataObject,
MetadataKey metadataKey,
Map<String, String> 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<String, String> properties,
boolean broadcast) throws ObjectAlreadyExistsException;

/**
* Creates a new Metadata Item. When the metadata with the designated key
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long, MetadataItem> {

public MetadataItemAdded(MetadataService metadataService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long, MetadataItem> {

public MetadataItemDeleted(MetadataService metadataService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long, MetadataItem> {

public MetadataItemModified(MetadataService metadataService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ public MetadataItem createMetadataItem(MetadataObject metadataObject,
public MetadataItem createMetadataItem(MetadataObject metadataObject,
MetadataKey metadataKey,
Map<String, String> properties,
long userIdentityId,
boolean broadcast) throws ObjectAlreadyExistsException {
long userIdentityId) throws ObjectAlreadyExistsException {
validateUserIdentityId(userIdentityId);
Metadata metadata = checkAndCreateMetadata(metadataObject, metadataKey, userIdentityId);
MetadataItem metadataItem = new MetadataItem(0,
Expand All @@ -142,62 +141,39 @@ 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<String, String> properties,
long userIdentityId) throws ObjectAlreadyExistsException {
return createMetadataItem(metadataObject, metadataKey, properties, userIdentityId, true);
}


@Override
public MetadataItem createMetadataItem(MetadataObject metadataObject,
MetadataKey metadataKey,
Map<String, String> properties,
boolean broadcast) throws ObjectAlreadyExistsException {
Map<String, String> properties) throws ObjectAlreadyExistsException {
Metadata metadata = checkAndCreateMetadata(metadataObject, metadataKey, 0);
MetadataItem metadataItem = new MetadataItem(0,
metadata,
metadataObject,
0,
System.currentTimeMillis(),
properties);
return createMetadataItem(metadataItem, 0, broadcast);
return createMetadataItem(metadataItem, 0);
}

@Override
public MetadataItem createMetadataItem(MetadataObject metadataObject,
MetadataKey metadataKey,
Map<String, String> 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);
Expand Down Expand Up @@ -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;
}
Expand Down