use of org.entando.entando.ent.exception.EntException in project entando-engine by entando.
the class OAuthConsumerManagerTest method failUpdateConsumer.
@Test
void failUpdateConsumer() throws Exception {
Assertions.assertThrows(EntException.class, () -> {
ConsumerRecordVO record = this.createMockConsumer("key_2", "secret", false);
Mockito.doThrow(RuntimeException.class).when(this.consumerDAO).updateConsumer(record);
try {
this.consumerManager.updateConsumer(record);
} catch (EntException e) {
throw e;
} finally {
Mockito.verify(consumerDAO, Mockito.times(1)).updateConsumer(Mockito.any(ConsumerRecordVO.class));
}
});
}
use of org.entando.entando.ent.exception.EntException in project entando-engine by entando.
the class OAuthConsumerManagerTest method failAddConsumer.
@Test
void failAddConsumer() throws Exception {
Assertions.assertThrows(EntException.class, () -> {
ConsumerRecordVO record = this.createMockConsumer("key_2", "secret", false);
Mockito.doThrow(RuntimeException.class).when(this.consumerDAO).addConsumer(record);
try {
this.consumerManager.addConsumer(record);
} catch (EntException e) {
throw e;
} finally {
Mockito.verify(consumerDAO, Mockito.times(1)).addConsumer(Mockito.any(ConsumerRecordVO.class));
}
});
}
use of org.entando.entando.ent.exception.EntException in project entando-engine by entando.
the class ApsEntityManager method reloadEntitySearchReferencesByType.
/**
* Reload the entity references.
*
* @param typeCode The type Code of entities to reload references. If null,
* will reload all entities.
* @throws EntException In case of error.
*/
protected synchronized void reloadEntitySearchReferencesByType(String typeCode) throws EntException {
if (null == typeCode) {
throw new EntException("Error: invalid type code detected");
}
this.setStatus(ApsEntityManager.STATUS_RELOADING_REFERENCES_IN_PROGRESS, typeCode);
try {
EntitySearchFilter filter = new EntitySearchFilter(ENTITY_TYPE_CODE_FILTER_KEY, false, typeCode, false);
EntitySearchFilter[] filters = { filter };
List<String> entitiesId = this.getEntitySearcherDao().searchId(filters);
for (int i = 0; i < entitiesId.size(); i++) {
String entityId = (String) entitiesId.get(i);
this.reloadEntityReferences(entityId);
}
} catch (Throwable t) {
logger.error("Error reloading entity references of type: {}", typeCode, t);
throw new EntException("Error reloading entity references of type: " + typeCode, t);
} finally {
this.setStatus(ApsEntityManager.STATUS_READY, typeCode);
}
}
use of org.entando.entando.ent.exception.EntException in project entando-engine by entando.
the class ApsEntityManager method removeEntityPrototype.
/**
* Remove an entity type from the catalog.
*
* @param entityTypeCode The code of the entity type to remove.
* @throws EntException In case of error.
*/
@Override
public void removeEntityPrototype(String entityTypeCode) throws EntException {
Map<String, IApsEntity> entityTypes = this.getEntityTypes();
IApsEntity entityTypeToRemove = entityTypes.get(entityTypeCode);
if (null == entityTypeToRemove) {
throw new EntException("No entity type to remove with code '" + entityTypeCode + "' were found");
}
entityTypes.remove(entityTypeCode);
this.updateEntityPrototypes(entityTypes);
this.notifyEntityTypesChanging(entityTypeToRemove, null, EntityTypesChangingEvent.REMOVE_OPERATION_CODE);
}
use of org.entando.entando.ent.exception.EntException in project entando-engine by entando.
the class ApsEntityManager method updateEntityPrototype.
/**
* Update an entity prototype on the catalog.
*
* @param entityType The entity type to update.
* @throws EntException In case of error.
*/
@Override
public void updateEntityPrototype(IApsEntity entityType) throws EntException {
if (null == entityType) {
throw new EntException("Invalid entity type to update");
}
Map<String, IApsEntity> entityTypes = this.getEntityTypes();
IApsEntity oldEntityType = entityTypes.get(entityType.getTypeCode());
if (null == oldEntityType) {
throw new EntException("No entity type to update with code '" + entityType.getTypeCode() + "' where found");
}
entityTypes.put(entityType.getTypeCode(), entityType);
this.updateEntityPrototypes(entityTypes);
this.verifyReloadingNeeded(oldEntityType, entityType);
this.notifyEntityTypesChanging(oldEntityType, entityType, EntityTypesChangingEvent.UPDATE_OPERATION_CODE);
}
Aggregations