use of com.agiletec.aps.system.common.entity.IEntityTypesConfigurer in project entando-core by entando.
the class AbstractEntityService method deleteEntityType.
protected void deleteEntityType(String entityManagerCode, String entityTypeCode) {
IEntityManager entityManager = this.extractEntityManager(entityManagerCode);
try {
IApsEntity entityType = entityManager.getEntityPrototype(entityTypeCode);
if (null == entityType) {
return;
}
List<String> ids = entityManager.searchId(entityTypeCode, null);
if (null != ids && ids.size() > 0) {
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(entityType, "entityType");
bindingResult.reject(EntityTypeValidator.ERRCODE_ENTITY_TYPE_REFERENCES, new Object[] { entityTypeCode }, "entityType.cannot.delete.references");
throw new ValidationConflictException(bindingResult);
}
((IEntityTypesConfigurer) entityManager).removeEntityPrototype(entityTypeCode);
} catch (ApsSystemException e) {
logger.error("Error in delete entityType {}", entityTypeCode, e);
throw new RestServerError("error in delete entityType", e);
}
}
use of com.agiletec.aps.system.common.entity.IEntityTypesConfigurer in project entando-core by entando.
the class ApiUserProfileTypeInterface method deleteUserProfileType.
public void deleteUserProfileType(Properties properties) throws ApiException, Throwable {
try {
String typeCode = properties.getProperty("typeCode");
IApsEntity masterProfileType = this.getUserProfileManager().getEntityPrototype(typeCode);
if (null == masterProfileType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "User Profile type with code '" + typeCode + "' doesn't exist");
}
EntitySearchFilter filter = new EntitySearchFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, false, typeCode, false);
List<String> profileIds = this.getUserProfileManager().searchId(new EntitySearchFilter[] { filter });
if (null != profileIds && !profileIds.isEmpty()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "User profile type '" + typeCode + "' are used into " + profileIds.size() + " profiles");
}
((IEntityTypesConfigurer) this.getUserProfileManager()).removeEntityPrototype(typeCode);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error deleting user Profile type", t);
// ApsSystemUtils.logThrowable(t, this, "deleteProfileType");
throw new ApsSystemException("Error deleting user Profile type", t);
}
}
use of com.agiletec.aps.system.common.entity.IEntityTypesConfigurer in project entando-core by entando.
the class TestJacmsEntityManagersAction method addEntityTypeForTest.
private void addEntityTypeForTest(String typeCode, String typeDescr) throws Throwable {
assertNull(this._contentManager.getEntityPrototype(typeCode));
IApsEntity prototype = this._contentManager.getEntityPrototype("ART");
prototype.setTypeCode(typeCode);
prototype.setTypeDescr(typeDescr);
((IEntityTypesConfigurer) this._contentManager).addEntityPrototype(prototype);
}
use of com.agiletec.aps.system.common.entity.IEntityTypesConfigurer in project entando-core by entando.
the class TestJacmsEntityTypeConfigAction method testSaveEntityType.
public void testSaveEntityType() throws Throwable {
String typeCode = "TST";
assertNull(this._contentManager.getEntityPrototype(typeCode));
try {
IApsEntity prototype = this._contentManager.getEntityPrototype("ART");
prototype.setTypeCode(typeCode);
prototype.setTypeDescr("Entity type Description");
this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_MANAGER_SESSION_PARAM, JacmsSystemConstants.CONTENT_MANAGER);
this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_OPERATION_ID_SESSION_PARAM, new Integer(ApsAdminSystemConstants.ADD));
this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM, prototype);
String result = this.executeSaveEntityType(prototype.getTypeCode(), prototype.getTypeDescr());
assertEquals(Action.SUCCESS, result);
assertNotNull(this._contentManager.getEntityPrototype(typeCode));
assertNull(this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM));
result = this.executeEditEntityPrototype(typeCode, JacmsSystemConstants.CONTENT_MANAGER);
assertEquals(Action.SUCCESS, result);
assertNotNull(this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM));
} catch (Throwable t) {
throw t;
} finally {
if (null != this._contentManager.getEntityPrototype(typeCode)) {
((IEntityTypesConfigurer) this._contentManager).removeEntityPrototype(typeCode);
}
}
}
use of com.agiletec.aps.system.common.entity.IEntityTypesConfigurer in project entando-core by entando.
the class EntityTypeConfigAction method saveEntityType.
@Override
public String saveEntityType() {
try {
IApsEntity entityType = this.getEntityType();
entityType.setDefaultLang(this.getLangManager().getDefaultLang().getCode());
if (this.getOperationId() == ApsAdminSystemConstants.ADD) {
((IEntityTypesConfigurer) this.getEntityManager()).addEntityPrototype(entityType);
} else {
((IEntityTypesConfigurer) this.getEntityManager()).updateEntityPrototype(entityType);
}
String entityManagerName = (String) this.getRequest().getSession().getAttribute(ENTITY_TYPE_MANAGER_SESSION_PARAM);
this.setEntityManagerName(entityManagerName);
} catch (Throwable t) {
_logger.error("error in saveEntityType", t);
// ApsSystemUtils.logThrowable(t, this, "saveEntityType");
return FAILURE;
} finally {
this.getRequest().getSession().removeAttribute(ENTITY_TYPE_MANAGER_SESSION_PARAM);
this.getRequest().getSession().removeAttribute(ENTITY_TYPE_OPERATION_ID_SESSION_PARAM);
this.getRequest().getSession().removeAttribute(ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
}
return SUCCESS;
}
Aggregations