Skip to content

Commit

Permalink
asd
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Oct 28, 2024
1 parent d7ba067 commit 4add479
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 213 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.eclipse.kapua.KapuaEntityNotFoundException;
import org.eclipse.kapua.model.KapuaEntity;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.storable.exception.StorableNotFoundException;
import org.eclipse.kapua.service.storable.model.Storable;
import org.eclipse.kapua.service.storable.model.id.StorableId;

Expand Down Expand Up @@ -64,34 +63,30 @@ public <T> T returnNotNullEntity(T object) {
* @since 2.0.0
*/
public <T extends KapuaEntity> T returnNotNullEntity(T entity, String entityType, KapuaId entityId) throws KapuaEntityNotFoundException {
if (entity == null) {
throw new KapuaEntityNotFoundException(entityType, entityId);
}

return entity;
return returnNotNullEntity(entity, entityType, entityId.getId().toString());
}

/**
* Checks id the given {@link Storable} is {@code null}.
* <p>
* Similar to {@link #returnNotNullEntity(KapuaEntity, String, KapuaId)} but for {@link Storable}s.
* Checks id the given {@link Object} is {@code null}.
*
* @param storable The {@link Storable} to check.
* @param storableType The {@link Storable#getType()}
* @param storableId The {@link StorableId}
* @return The given {@link Storable} if not {@code null}
* @param <T> The type of the {@link Storable}.
* @throws StorableNotFoundException if given {@link Storable} is {@code null}.
* @param entity The {@link Object} to check.
* @param entityType The {@link Object} type.
* @param entityId The {@link Object} id.
* @return The given entity if not {@code null}
* @param <T> The {@link Object} type.
* @throws KapuaEntityNotFoundException if given {@link Object} is {@code null}.
* @since 2.0.0
*/
public <T extends Storable> T returnNotNullStorable(T storable, String storableType, StorableId storableId) throws StorableNotFoundException {
if (storable == null) {
throw new StorableNotFoundException(storableType, storableId);
public <T> T returnNotNullEntity(T entity, String entityType, String entityId) throws KapuaEntityNotFoundException {
if (entity == null) {
throw new KapuaEntityNotFoundException(entityType, entityId);
}

return storable;
return entity;
}



/**
* Builds a 200 HTTP Response.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@ public ChannelInfo find(@PathParam("scopeId") ScopeId scopeId,
throws KapuaException {
ChannelInfo channelInfo = channelInfoRegistryService.find(scopeId, channelInfoId);

return returnNotNullStorable(channelInfo, ChannelInfo.TYPE, channelInfoId);
return returnNotNullEntity(channelInfo, ChannelInfo.TYPE, channelInfoId.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,4 @@ public enum StorableErrorCodes implements KapuaErrorCode {
* @since 1.3.0
*/
UNSUPPORTED_TYPE,

/**
* See {@link StorableNotFoundException}
*
* @since 2.0.0
*/
STORABLE_NOT_FOUND
}

This file was deleted.

0 comments on commit 4add479

Please sign in to comment.