Search in sources :

Example 96 with EntException

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));
        }
    });
}
Also used : ConsumerRecordVO(org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO) EntException(org.entando.entando.ent.exception.EntException) Test(org.junit.jupiter.api.Test)

Example 97 with EntException

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));
        }
    });
}
Also used : ConsumerRecordVO(org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO) EntException(org.entando.entando.ent.exception.EntException) Test(org.junit.jupiter.api.Test)

Example 98 with EntException

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);
    }
}
Also used : EntException(org.entando.entando.ent.exception.EntException) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 99 with EntException

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);
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) EntException(org.entando.entando.ent.exception.EntException)

Example 100 with EntException

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);
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) EntException(org.entando.entando.ent.exception.EntException)

Aggregations

EntException (org.entando.entando.ent.exception.EntException)296 RestServerError (org.entando.entando.aps.system.exception.RestServerError)44 ArrayList (java.util.ArrayList)31 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)22 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)18 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)18 ApsProperties (com.agiletec.aps.util.ApsProperties)16 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)15 HashMap (java.util.HashMap)14 Cache (org.springframework.cache.Cache)14 IPage (com.agiletec.aps.system.services.page.IPage)13 StringReader (java.io.StringReader)12 Connection (java.sql.Connection)12 SQLException (java.sql.SQLException)12 List (java.util.List)11 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)11 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)11 Date (java.util.Date)10 DataSource (javax.sql.DataSource)10 SAXBuilder (org.jdom.input.SAXBuilder)10