use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ApiContentInterface method addContent.
public StringApiResponse addContent(JAXBContent jaxbContent, Properties properties) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String typeCode = jaxbContent.getTypeCode();
Content prototype = (Content) this.getContentManager().getEntityPrototype(typeCode);
if (null == prototype) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Content type with code '" + typeCode + "' does not exist", Response.Status.CONFLICT);
}
Content content = (Content) jaxbContent.buildEntity(prototype, this.getCategoryManager());
if (null != content.getId()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "You cannot specify Content Id", Response.Status.CONFLICT);
}
UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
content.setFirstEditor((null != user) ? user.getUsername() : SystemConstants.GUEST_USER_NAME);
response = this.validateAndSaveContent(content, properties);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error adding content", t);
throw new ApsSystemException("Error adding content", t);
}
return response;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ApiContentInterface method getContentToHtml.
public String getContentToHtml(Properties properties) throws ApiException, Throwable {
String render = null;
String id = properties.getProperty("id");
String modelId = properties.getProperty("modelId");
try {
if (null == modelId || modelId.trim().length() == 0) {
return null;
}
Content mainContent = this.getPublicContent(id);
Integer modelIdInteger = this.checkModel(modelId, mainContent);
if (null != modelIdInteger) {
String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
render = this.getRenderedContent(id, modelIdInteger, langCode);
}
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("error in getContentToHtml", t);
throw new ApsSystemException("Error into API method", t);
}
return render;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ApiContentTypeInterface method checkNewEntityType.
@Override
protected void checkNewEntityType(JAXBEntityType jaxbEntityType, IApsEntity newEntityType, StringApiResponse response) throws ApiException, Throwable {
JAXBContentType jaxbContentType = (JAXBContentType) jaxbEntityType;
Content contentType = (Content) newEntityType;
boolean defaultModelCheck = this.checkContentModel(jaxbContentType.getDefaultModelId(), contentType, response);
if (defaultModelCheck) {
contentType.setDefaultModel(String.valueOf(jaxbContentType.getDefaultModelId()));
}
boolean listModelCheck = this.checkContentModel(jaxbContentType.getListModelId(), contentType, response);
if (listModelCheck) {
contentType.setListModel(String.valueOf(jaxbContentType.getListModelId()));
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ApiContentTypeInterface method checkEntityTypeToUpdate.
@Override
protected void checkEntityTypeToUpdate(JAXBEntityType jaxbEntityType, IApsEntity entityTypeToUpdate, StringApiResponse response) throws ApiException, Throwable {
JAXBContentType jaxbContentType = (JAXBContentType) jaxbEntityType;
Content contentType = (Content) entityTypeToUpdate;
boolean defaultModelCheck = this.checkContentModel(jaxbContentType.getDefaultModelId(), contentType, response);
if (defaultModelCheck) {
contentType.setDefaultModel(String.valueOf(jaxbContentType.getDefaultModelId()));
}
boolean listModelCheck = this.checkContentModel(jaxbContentType.getListModelId(), contentType, response);
if (listModelCheck) {
contentType.setListModel(String.valueOf(jaxbContentType.getListModelId()));
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class BaseContentBulkCommand method apply.
@Override
protected boolean apply(String item) throws ApsSystemException {
boolean performed = false;
Content content = this.getContent(item);
if (content == null) {
this.getTracer().traceError(item, ApsCommandErrorCode.NOT_FOUND);
} else if (!this.isAuthOnContent(content)) {
this.getTracer().traceError(item, ApsCommandErrorCode.USER_NOT_ALLOWED);
} else {
performed = this.apply(content);
}
return performed;
}
Aggregations