Search in sources :

Example 1 with Content

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;
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) JAXBContent(org.entando.entando.plugins.jacms.aps.system.services.api.model.JAXBContent) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 2 with Content

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;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) JAXBContent(org.entando.entando.plugins.jacms.aps.system.services.api.model.JAXBContent) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 3 with Content

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()));
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) JAXBContentType(org.entando.entando.plugins.jacms.aps.system.services.api.model.JAXBContentType)

Example 4 with Content

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()));
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) JAXBContentType(org.entando.entando.plugins.jacms.aps.system.services.api.model.JAXBContentType)

Example 5 with Content

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;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Aggregations

Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)227 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)35 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)29 ArrayList (java.util.ArrayList)26 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 ActionSupport (com.opensymphony.xwork2.ActionSupport)14 List (java.util.List)14 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)13 HttpSession (javax.servlet.http.HttpSession)13 UserDetails (com.agiletec.aps.system.services.user.UserDetails)12 IPage (com.agiletec.aps.system.services.page.IPage)10 Date (java.util.Date)8 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)7 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)7 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)7 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)7 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)6 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6