diff --git a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESMappingAPIImpl.java b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESMappingAPIImpl.java index d00518b23c12..7fda180b8a6f 100644 --- a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESMappingAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESMappingAPIImpl.java @@ -1,17 +1,5 @@ package com.dotcms.content.elasticsearch.business; -import static com.dotcms.content.elasticsearch.business.ESIndexAPI.INDEX_OPERATIONS_TIMEOUT_IN_MS; -import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.PERSONA_KEY_TAG; -import static com.dotcms.contenttype.model.field.LegacyFieldTypes.CUSTOM_FIELD; -import static com.dotcms.contenttype.model.type.PersonaContentType.PERSONA_KEY_TAG_FIELD_VAR; -import static com.dotmarketing.business.PermissionAPI.PERMISSION_PUBLISH; -import static com.dotmarketing.business.PermissionAPI.PERMISSION_READ; -import static com.dotmarketing.business.PermissionAPI.PERMISSION_WRITE; -import static com.dotmarketing.util.UtilMethods.isNotSet; -import static com.liferay.util.StringPool.BLANK; -import static com.liferay.util.StringPool.COMMA; -import static com.liferay.util.StringPool.PERIOD; - import com.dotcms.business.CloseDBIfOpened; import com.dotcms.content.business.ContentMappingAPI; import com.dotcms.content.business.DotMappingException; @@ -42,6 +30,7 @@ import com.dotmarketing.business.VersionableAPI; import com.dotmarketing.cache.FieldsCache; import com.dotmarketing.common.db.DotConnect; +import com.dotmarketing.exception.DotCorruptedDataException; import com.dotmarketing.exception.DotDataException; import com.dotmarketing.exception.DotSecurityException; import com.dotmarketing.portlets.categories.business.CategoryAPI; @@ -76,6 +65,19 @@ import com.liferay.portal.model.User; import io.vavr.Lazy; import io.vavr.control.Try; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.time.FastDateFormat; +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.indices.GetFieldMappingsRequest; +import org.elasticsearch.client.indices.GetFieldMappingsResponse; +import org.elasticsearch.client.indices.GetMappingsRequest; +import org.elasticsearch.client.indices.GetMappingsResponse; +import org.elasticsearch.client.indices.PutMappingRequest; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.XContentType; + import java.io.IOException; import java.io.StringWriter; import java.text.DecimalFormat; @@ -97,18 +99,21 @@ import java.util.TimeZone; import java.util.function.Supplier; import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.time.FastDateFormat; -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.client.RequestOptions; -import org.elasticsearch.client.indices.GetFieldMappingsRequest; -import org.elasticsearch.client.indices.GetFieldMappingsResponse; -import org.elasticsearch.client.indices.GetMappingsRequest; -import org.elasticsearch.client.indices.GetMappingsResponse; -import org.elasticsearch.client.indices.PutMappingRequest; -import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.xcontent.XContentType; + +import static com.dotcms.content.elasticsearch.business.ESIndexAPI.INDEX_OPERATIONS_TIMEOUT_IN_MS; +import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.CREATION_DATE; +import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.PERSONA_KEY_TAG; +import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.SYS_PUBLISH_USER; +import static com.dotcms.contenttype.model.field.LegacyFieldTypes.CUSTOM_FIELD; +import static com.dotcms.contenttype.model.type.PersonaContentType.PERSONA_KEY_TAG_FIELD_VAR; +import static com.dotcms.util.DotPreconditions.checkNotEmpty; +import static com.dotmarketing.business.PermissionAPI.PERMISSION_PUBLISH; +import static com.dotmarketing.business.PermissionAPI.PERMISSION_READ; +import static com.dotmarketing.business.PermissionAPI.PERMISSION_WRITE; +import static com.dotmarketing.util.UtilMethods.isNotSet; +import static com.liferay.util.StringPool.BLANK; +import static com.liferay.util.StringPool.COMMA; +import static com.liferay.util.StringPool.PERIOD; /** * Implementation class for the {@link ContentMappingAPI}. @@ -382,6 +387,8 @@ public Map toMap(final Contentlet contentlet) throws DotMappingEx contentletMap.put(ESMappingConstants.MOD_DATE + TEXT, datetimeFormat.format(contentlet.getModDate())); contentletMap.put(ESMappingConstants.OWNER, contentlet.getOwner()==null ? "0" : contentlet.getOwner()); contentletMap.put(ESMappingConstants.MOD_USER, contentlet.getModUser()); + contentletMap.put(CREATION_DATE, elasticSearchDateTimeFormat.format(contentIdentifier.getCreateDate())); + contentletMap.put(CREATION_DATE + TEXT, datetimeFormat.format(contentIdentifier.getCreateDate())); contentletMap.put(ESMappingConstants.LIVE, contentlet.isLive()); contentletMap.put(ESMappingConstants.LIVE + TEXT, Boolean.toString(contentlet.isLive())); contentletMap.put(ESMappingConstants.WORKING, contentlet.isWorking()); @@ -396,7 +403,7 @@ public Map toMap(final Contentlet contentlet) throws DotMappingEx contentletMap.put(ESMappingConstants.IDENTIFIER, contentIdentifier.getId()); contentletMap.put(ESMappingConstants.CONTENTLET_HOST, contentIdentifier.getHostId()); contentletMap.put(ESMappingConstants.CONTENTLET_HOSTNAME, contentSite.getHostname()); - contentletMap.put(ESMappingConstants.CONTENTLET_FOLER, contentFolder!=null && InodeUtils.isSet(contentFolder.getInode()) ? contentFolder.getInode() : contentlet.getFolder()); + contentletMap.put(ESMappingConstants.CONTENTLET_FOLER, InodeUtils.isSet(contentFolder.getInode()) ? contentFolder.getInode() : contentlet.getFolder()); contentletMap.put(ESMappingConstants.PARENT_PATH, contentIdentifier.getParentPath()); contentletMap.put(ESMappingConstants.PATH, contentIdentifier.getPath()); // makes shorties searchable regardless of length @@ -417,7 +424,9 @@ public Map toMap(final Contentlet contentlet) throws DotMappingEx contentlet.getDateProperty(expireDateVar) : null; loadDateTimeFieldValue(contentletMap, ESMappingConstants.EXPIRE_DATE, expireDate); - + if (contentlet.isLive()) { + contentletMap.put(SYS_PUBLISH_USER, contentlet.getModUser()); + } loadDateTimeFieldValue(contentletMap, ESMappingConstants.SYS_PUBLISH_DATE, versionInfo.get().getPublishDate()); @@ -431,7 +440,7 @@ public Map toMap(final Contentlet contentlet) throws DotMappingEx } } catch (final Exception e) { Logger.warn(this.getClass(), "Cannot get URLMap for Content Type: " + contentType.name() + " and " + - "contentlet.id : " + ((contentIdentifier != null) ? contentIdentifier.getId() : contentlet) + + "contentlet.id : " + contentIdentifier.getId() + " , reason: " + e.getMessage()); } @@ -480,6 +489,9 @@ public Map toMap(final Contentlet contentlet) throws DotMappingEx //The url is now stored under the identifier for html pages, so we need to index that also. if (contentlet.getContentType().baseType().getType() == BaseContentType.HTMLPAGE.getType()) { + checkNotEmpty(contentlet.getContentType().variable(), + DotCorruptedDataException.class, "Contentlet '%s' " + + "points to a Content Type with an empty Velocity Var Name", contentlet.getIdentifier()); mapLowered.put(contentlet.getContentType().variable().toLowerCase() + ".url", contentIdentifier.getAssetName()); mapLowered.put(contentlet.getContentType().variable().toLowerCase() + ".url_dotraw", contentIdentifier.getAssetName()); sw.append(contentIdentifier.getAssetName()); diff --git a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/constants/ESMappingConstants.java b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/constants/ESMappingConstants.java index 910dc9a45e50..c3c4e8f02e0d 100644 --- a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/constants/ESMappingConstants.java +++ b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/constants/ESMappingConstants.java @@ -54,6 +54,7 @@ private ESMappingConstants(){} public static final String SYSTEM_TYPE = "systemType"; public static final String MOD_DATE = "modDate"; + public static final String CREATION_DATE = "creationDate"; public static final String OWNER = "owner"; public static final String MOD_USER = "modUser"; public static final String LIVE = "live"; @@ -81,6 +82,7 @@ private ESMappingConstants(){} public static final String EXPIRE_DATE = "expdate"; public static final String VERSION_TS = "versionTs"; public static final String SYS_PUBLISH_DATE = "sysPublishDate"; + public static final String SYS_PUBLISH_USER = "sysPublishUser"; public static final String URL_MAP = "urlMap"; public static final String VANITY_URL = "vanityUrl"; public static final String CATEGORIES = "categories"; diff --git a/dotCMS/src/main/java/com/dotcms/graphql/ContentFields.java b/dotCMS/src/main/java/com/dotcms/graphql/ContentFields.java index 9e6bcc8d1c59..85a8dbc2782e 100644 --- a/dotCMS/src/main/java/com/dotcms/graphql/ContentFields.java +++ b/dotCMS/src/main/java/com/dotcms/graphql/ContentFields.java @@ -1,7 +1,26 @@ package com.dotcms.graphql; +import com.dotcms.graphql.datafetcher.ContentMapDataFetcher; +import com.dotcms.graphql.datafetcher.FolderFieldDataFetcher; +import com.dotcms.graphql.datafetcher.LanguageDataFetcher; +import com.dotcms.graphql.datafetcher.SiteFieldDataFetcher; +import com.dotcms.graphql.datafetcher.TitleImageFieldDataFetcher; +import com.dotcms.graphql.datafetcher.UserDataFetcher; +import com.dotcms.graphql.util.TypeUtil.TypeFetcher; +import com.dotmarketing.portlets.contentlet.model.Contentlet; +import com.dotmarketing.util.UtilMethods; +import graphql.scalars.ExtendedScalars; +import graphql.schema.GraphQLArgument; +import graphql.schema.GraphQLTypeReference; +import graphql.schema.PropertyDataFetcher; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; + import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.BASE_TYPE; import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.CONTENT_TYPE; +import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.CREATION_DATE; import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.IDENTIFIER; import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.INODE; import static com.dotcms.content.elasticsearch.constants.ESMappingConstants.LIVE; @@ -20,29 +39,14 @@ import static com.dotmarketing.portlets.contentlet.model.Contentlet.LOCKED_KEY; import static com.dotmarketing.portlets.contentlet.model.Contentlet.MOD_USER_KEY; import static com.dotmarketing.portlets.contentlet.model.Contentlet.OWNER_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.PUBLISH_DATE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.PUBLISH_USER_KEY; import static com.dotmarketing.portlets.contentlet.model.Contentlet.TITLE_IMAGE_KEY; import static graphql.Scalars.GraphQLBoolean; import static graphql.Scalars.GraphQLID; import static graphql.Scalars.GraphQLInt; import static graphql.Scalars.GraphQLString; -import com.dotcms.graphql.datafetcher.ContentMapDataFetcher; -import com.dotcms.graphql.datafetcher.FolderFieldDataFetcher; -import com.dotcms.graphql.datafetcher.LanguageDataFetcher; -import com.dotcms.graphql.datafetcher.SiteFieldDataFetcher; -import com.dotcms.graphql.datafetcher.TitleImageFieldDataFetcher; -import com.dotcms.graphql.datafetcher.UserDataFetcher; -import com.dotcms.graphql.util.TypeUtil.TypeFetcher; -import com.dotmarketing.portlets.contentlet.model.Contentlet; -import com.dotmarketing.util.UtilMethods; -import graphql.scalars.ExtendedScalars; -import graphql.schema.GraphQLArgument; -import graphql.schema.GraphQLTypeReference; -import graphql.schema.PropertyDataFetcher; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; - /** * Utility class that defines and returns the available fields for the {@link InterfaceType#CONTENTLET} */ @@ -52,6 +56,7 @@ private ContentFields() {} public static Map getContentFields() { final Map contentFields = new HashMap<>(); + contentFields.put(CREATION_DATE, new TypeFetcher(GraphQLString)); contentFields.put(MOD_DATE, new TypeFetcher(GraphQLString)); contentFields.put(TITLE, new TypeFetcher(GraphQLString)); contentFields.put(TITLE_IMAGE_KEY, new TypeFetcher(GraphQLTypeReference.typeRef(BINARY.getTypeName()), @@ -84,6 +89,13 @@ public static Map getContentFields() { GraphQLArgument.newArgument().name("depth").defaultValue(0).type(GraphQLInt).build(), GraphQLArgument.newArgument().name("render").defaultValue(false) .type(GraphQLBoolean).build())); + contentFields.put(PUBLISH_DATE_KEY, new TypeFetcher(GraphQLString, PropertyDataFetcher + .fetching((Function) contentlet -> + UtilMethods.isSet(contentlet.getStringProperty("publishDate")) + ? contentlet.getStringProperty("publishDate") + : ""))); + contentFields.put(PUBLISH_USER_KEY, new TypeFetcher(GraphQLTypeReference.typeRef(USER.getTypeName()), + new UserDataFetcher())); return contentFields; } diff --git a/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java b/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java index 6a7e90bc24c3..f2daee397c8a 100644 --- a/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java +++ b/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java @@ -7,19 +7,14 @@ import com.dotcms.contenttype.model.type.BaseContentType; import com.dotcms.contenttype.model.type.ContentType; import com.dotcms.contenttype.transform.field.LegacyFieldTransformer; +import com.dotcms.exception.ExceptionUtil; import com.dotcms.rendering.velocity.viewtools.content.util.ContentUtils; import com.dotcms.repackage.org.apache.commons.httpclient.HttpStatus; -import com.dotcms.util.xstream.XStreamHandler; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import com.dotcms.util.JsonUtil; -import com.dotmarketing.portlets.structure.model.Field.FieldType; -import com.dotmarketing.util.json.JSONArray; -import com.dotmarketing.util.json.JSONException; -import com.dotmarketing.util.json.JSONObject; import com.dotcms.rest.api.v1.authentication.ResponseUtil; import com.dotcms.rest.exception.ForbiddenException; import com.dotcms.rest.exception.mapper.ExceptionMapperUtil; +import com.dotcms.util.JsonUtil; +import com.dotcms.util.xstream.XStreamHandler; import com.dotcms.uuid.shorty.ShortyId; import com.dotcms.uuid.shorty.ShortyIdAPI; import com.dotcms.workflow.form.FireActionForm; @@ -42,6 +37,7 @@ import com.dotmarketing.portlets.htmlpageasset.business.HTMLPageAssetAPI; import com.dotmarketing.portlets.structure.model.ContentletRelationships; import com.dotmarketing.portlets.structure.model.Field; +import com.dotmarketing.portlets.structure.model.Field.FieldType; import com.dotmarketing.portlets.structure.model.Relationship; import com.dotmarketing.portlets.workflows.business.WorkflowAPI.SystemAction; import com.dotmarketing.portlets.workflows.model.WorkflowAction; @@ -54,7 +50,11 @@ import com.dotmarketing.util.UUIDUtil; import com.dotmarketing.util.UtilHTML; import com.dotmarketing.util.UtilMethods; +import com.dotmarketing.util.json.JSONArray; +import com.dotmarketing.util.json.JSONException; +import com.dotmarketing.util.json.JSONObject; import com.liferay.portal.model.User; +import com.liferay.util.StringPool; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.converters.MarshallingContext; @@ -62,6 +62,8 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.glassfish.jersey.media.multipart.BodyPart; import org.glassfish.jersey.media.multipart.ContentDisposition; import org.glassfish.jersey.media.multipart.FormDataMultiPart; @@ -554,10 +556,9 @@ public Response unlockContent(@Context HttpServletRequest request, @Produces(MediaType.APPLICATION_JSON) public Response getContent(@Context HttpServletRequest request, @Context final HttpServletResponse response, @PathParam("params") String params) { - final InitDataObject initData = this.webResource.init (params, request, response, false, null); - //Creating an utility response object + // Creating a utility response object final ResourceResponse responseResource = new ResourceResponse(initData.getParamsMap()); final Map paramsMap = initData.getParamsMap(); final User user = initData.getUser(); @@ -569,9 +570,7 @@ public Response getContent(@Context HttpServletRequest request, @Context final H final String offsetStr = paramsMap.get(RESTParams.OFFSET.getValue()); final String inode = paramsMap.get(RESTParams.INODE.getValue()); final String respectFrontEndRolesKey = RESTParams.RESPECT_FRONT_END_ROLES.getValue().toLowerCase(); - final boolean respectFrontendRoles = UtilMethods.isSet(paramsMap.get(respectFrontEndRolesKey)) - ? Boolean.valueOf(paramsMap.get(respectFrontEndRolesKey)) - : true; + final boolean respectFrontendRoles = !UtilMethods.isSet(paramsMap.get(respectFrontEndRolesKey)) || Boolean.parseBoolean(paramsMap.get(respectFrontEndRolesKey)); final long language = toLong(paramsMap.get(RESTParams.LANGUAGE.getValue()), () -> APILocator.getLanguageAPI().getDefaultLanguage().getId()); /* Limit and Offset Parameters Handling, if not passed, using default */ @@ -597,44 +596,37 @@ public Response getContent(@Context HttpServletRequest request, @Context final H /* Fetching the content using a query if passed or an id */ List contentlets = new ArrayList<>(); - Boolean idPassed = false; - Boolean inodePassed = false; - Boolean queryPassed = false; + boolean idPassed = UtilMethods.isSet(id); + boolean inodePassed = UtilMethods.isSet(inode); + boolean queryPassed = UtilMethods.isSet(query); String result = null; Optional status = Optional.empty(); String type = paramsMap.get(RESTParams.TYPE.getValue()); String orderBy = paramsMap.get(RESTParams.ORDERBY.getValue()); final String tmDate = (String) request.getSession().getAttribute("tm_date"); - type = UtilMethods.isSet(type) ? type : "json"; - final String relatedOrder = UtilMethods.isSet(orderBy) ? orderBy: null; orderBy = UtilMethods.isSet(orderBy) ? orderBy : "modDate desc"; try { - - if (idPassed = UtilMethods.isSet(id)) { - + if (idPassed) { final Contentlet contentlet = APILocator.getContentletAPI() .findContentletByIdentifier(id, live, language, user, respectFrontendRoles); - if (contentlet != null){ - contentlets.add(this.contentHelper.hydrateContentlet(contentlet)); + contentlets.add(contentlet); } - - } else if (inodePassed = UtilMethods.isSet(inode)) { - + } else if (inodePassed) { final Contentlet contentlet = APILocator.getContentletAPI() .find(inode, user, respectFrontendRoles); if (contentlet != null){ - contentlets.add(this.contentHelper.hydrateContentlet(contentlet)); + contentlets.add(contentlet); } } else if (UtilMethods.isSet(related)){ //Related identifier are expected this way: "ContentTypeVarName.FieldVarName:contentletIdentifier" //In case of multiple relationships, they must be sent as a comma separated list //i.e.: ContentTypeVarName1.FieldVarName1:contentletIdentifier1,ContentTypeVarName2.FieldVarName2:contentletIdentifier2 int i = 0; - for(String relationshipValue: related.split(",")){ + for (final String relationshipValue : related.split(StringPool.COMMA)) { if (i == 0) { contentlets.addAll(getPullRelated(user, limit, offset, relatedOrder, tmDate, processQuery(query), relationshipValue, language, live)); @@ -648,16 +640,14 @@ public Response getContent(@Context HttpServletRequest request, @Context final H i++; } - } else if (queryPassed = UtilMethods.isSet(query)){ + } else if (queryPassed){ contentlets = ContentUtils .pull(processQuery(query), offset, limit, orderBy, user, tmDate); } - - } catch (DotSecurityException e) { - + } catch (final DotSecurityException e) { Logger.debug(this, "Permission error: " + e.getMessage(), e); return ExceptionMapperUtil.createResponse(new DotStateException("No Permissions"), Response.Status.FORBIDDEN); - } catch (Exception e) { + } catch (final Exception e) { if (idPassed) { Logger.warnAndDebug(this.getClass(), "Can't find Content with Identifier: " + id + " " + e.getMessage(), e); } else if (queryPassed || UtilMethods.isSet(related)) { @@ -677,10 +667,10 @@ public Response getContent(@Context HttpServletRequest request, @Context final H result = getJSON(contentlets, request, response, render, user, depth, respectFrontendRoles, language, live, allCategoriesInfo); } - } catch (Exception e) { - Logger.warn(this, "Error converting result to XML/JSON"); + } catch (final Exception e) { + Logger.warn(this, String.format("Error converting result to %s for request [ %s ]: " + + "%s", type, params, ExceptionUtil.getErrorMessage(e))); } - return responseResource.response(result, null, status); } diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/model/Contentlet.java b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/model/Contentlet.java index f37d17951a6f..de78d669f9a8 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/model/Contentlet.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/model/Contentlet.java @@ -114,9 +114,15 @@ public class Contentlet implements Serializable, Permissionable, Categorizable, public static final String ARCHIVED_KEY = "archived"; public static final String LIVE_KEY = "live"; public static final String WORKING_KEY = "working"; + public static final String CREATION_DATE_KEY = "creationDate"; public static final String MOD_DATE_KEY = "modDate"; public static final String MOD_USER_KEY = "modUser"; + public static final String MOD_USER_NAME_KEY = "modUserName"; public static final String OWNER_KEY = "owner"; + public static final String OWNER_NAME_KEY = "ownerName"; + public static final String PUBLISH_DATE_KEY = "publishDate"; + public static final String PUBLISH_USER_KEY = "publishUser"; + public static final String PUBLISH_USER_NAME_KEY = "publishUserName"; public static final String HOST_KEY = "host"; public static final String FOLDER_KEY = "folder"; public static final String SORT_ORDER_KEY = "sortOrder"; diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/DefaultTransformStrategy.java b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/DefaultTransformStrategy.java index 67756103fa35..a33ac6fa79ec 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/DefaultTransformStrategy.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/transform/strategy/DefaultTransformStrategy.java @@ -1,34 +1,5 @@ package com.dotmarketing.portlets.contentlet.transform.strategy; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.ARCHIVED_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.BASE_TYPE_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.CONTENT_TYPE_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.HAS_TITLE_IMAGE_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.HOST_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.HOST_NAME; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.IDENTIFIER_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.INODE_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.LANGUAGEID_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.LIVE_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.LOCKED_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.TITLE_IMAGE_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.TITLE_IMAGE_NOT_FOUND; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.TITTLE_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.URL_MAP_FOR_CONTENT_KEY; -import static com.dotmarketing.portlets.contentlet.model.Contentlet.WORKING_KEY; -import static com.dotmarketing.portlets.contentlet.transform.strategy.LanguageViewStrategy.mapLanguage; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.BINARIES; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.CATEGORIES_INFO; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.CATEGORIES_NAME; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.COMMON_PROPS; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.CONSTANTS; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.FILTER_BINARIES; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.LANGUAGE_PROPS; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.TAGS; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.USE_ALIAS; -import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.VERSION_INFO; -import static com.dotmarketing.portlets.htmlpageasset.business.HTMLPageAssetAPI.URL_FIELD; - import com.dotcms.api.APIProvider; import com.dotcms.content.elasticsearch.constants.ESMappingConstants; import com.dotcms.contenttype.model.field.BinaryField; @@ -40,6 +11,7 @@ import com.dotmarketing.beans.Host; import com.dotmarketing.beans.Identifier; import com.dotmarketing.business.APILocator; +import com.dotmarketing.business.IdentifierAPI; import com.dotmarketing.exception.DotDataException; import com.dotmarketing.exception.DotSecurityException; import com.dotmarketing.portlets.categories.model.Category; @@ -48,10 +20,11 @@ import com.dotmarketing.portlets.fileassets.business.FileAssetAPI; import com.dotmarketing.portlets.languagesmanager.model.Language; import com.dotmarketing.util.Logger; +import com.dotmarketing.util.UtilMethods; import com.google.common.collect.ImmutableMap; import com.liferay.portal.model.User; import io.vavr.control.Try; -import java.io.File; + import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; @@ -62,6 +35,43 @@ import java.util.Set; import java.util.stream.Collectors; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.ARCHIVED_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.BASE_TYPE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.CONTENT_TYPE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.CREATION_DATE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.HAS_TITLE_IMAGE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.HOST_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.HOST_NAME; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.IDENTIFIER_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.INODE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.LANGUAGEID_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.LIVE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.LOCKED_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.MOD_USER_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.MOD_USER_NAME_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.OWNER_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.OWNER_NAME_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.PUBLISH_DATE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.PUBLISH_USER_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.PUBLISH_USER_NAME_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.TITLE_IMAGE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.TITLE_IMAGE_NOT_FOUND; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.TITTLE_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.URL_MAP_FOR_CONTENT_KEY; +import static com.dotmarketing.portlets.contentlet.model.Contentlet.WORKING_KEY; +import static com.dotmarketing.portlets.contentlet.transform.strategy.LanguageViewStrategy.mapLanguage; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.BINARIES; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.CATEGORIES_INFO; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.CATEGORIES_NAME; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.COMMON_PROPS; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.CONSTANTS; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.FILTER_BINARIES; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.LANGUAGE_PROPS; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.TAGS; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.USE_ALIAS; +import static com.dotmarketing.portlets.contentlet.transform.strategy.TransformOptions.VERSION_INFO; +import static com.dotmarketing.portlets.htmlpageasset.business.HTMLPageAssetAPI.URL_FIELD; + /** * If any Options marked as property is found this class gets instantiated since props are most likely to be resolved here */ @@ -132,9 +142,9 @@ private void addCommonProperties(final Contentlet contentlet, final Map contentletProperties) throws DotDataException, DotSecurityException { + final User modUser = Try.of(() -> toolBox.userAPI.loadUserById(contentlet.getModUser())).getOrNull(); + final User owner = Try.of(() -> toolBox.userAPI.loadUserById(contentlet.getOwner())).getOrNull(); + if (contentletProperties.containsKey(MOD_USER_KEY)) { + contentletProperties.put(MOD_USER_NAME_KEY, null != modUser ? modUser.getFullName() : NOT_APPLICABLE); + } + if (contentletProperties.containsKey(OWNER_KEY)) { + contentletProperties.put(OWNER_NAME_KEY, null != owner ? owner.getFullName() : NOT_APPLICABLE); + } + final Identifier identifier = toolBox.identifierAPI.find(contentlet.getIdentifier()); + if (null != identifier && UtilMethods.isSet(identifier.getId()) && !IdentifierAPI.IDENT404.equals(identifier.getAssetType())) { + contentletProperties.put(CREATION_DATE_KEY, identifier.getCreateDate()); + } + if (contentlet.isLive()) { + final Optional versionInfoOpt = + this.toolBox.versionableAPI.getContentletVersionInfo(contentlet.getIdentifier(), contentlet.getLanguageId(), contentlet.getVariantId()); + versionInfoOpt.ifPresent(contentletVersionInfo -> contentletProperties.put(PUBLISH_DATE_KEY, contentletVersionInfo.getPublishDate())); + contentletProperties.put(PUBLISH_USER_KEY, null != modUser ? modUser.getUserId() : NOT_APPLICABLE); + contentletProperties.put(PUBLISH_USER_NAME_KEY, null != modUser ? modUser.getFullName() : NOT_APPLICABLE); + } } /** diff --git a/dotcms-postman/src/main/resources/postman/ContentResourceV1.postman_collection.json b/dotcms-postman/src/main/resources/postman/ContentResourceV1.postman_collection.json index a8fa2506eab4..a5cf0d89d8f1 100644 --- a/dotcms-postman/src/main/resources/postman/ContentResourceV1.postman_collection.json +++ b/dotcms-postman/src/main/resources/postman/ContentResourceV1.postman_collection.json @@ -1,10 +1,211 @@ { "info": { - "_postman_id": "a7037756-a113-4775-888b-9a96d00896bc", + "_postman_id": "b266d3ff-f351-46a7-b796-9f793963cedb", "name": "ContentResourceV1", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "5403727" }, "item": [ + { + "name": "Checking JSON Attributes", + "item": [ + { + "name": "Checking Content Audit Attributes", + "item": [ + { + "name": "Creating Test Generic Content", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Test content created successfully\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.errors.length).to.eql(0);", + " var contentId = Object.keys(jsonData.entity.results[0]);", + " pm.collectionVariables.set(\"testContentId\", jsonData.entity.results[0][contentId].identifier);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"contentlets\": [\n {\n \"contentType\": \"webPageContent\",\n \"title\": \"Test Generic Content\",\n \"contentHost\": \"default\",\n \"body\": \"This is my Test Generic Content\"\n }\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/workflow/actions/default/fire/PUBLISH", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "workflow", + "actions", + "default", + "fire", + "PUBLISH" + ] + } + }, + "response": [] + }, + { + "name": "Retrieving Test Generic Content", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().entity;", + " ", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.ownerName).to.not.equal(undefined, \"The 'ownerName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUserName).to.not.equal(undefined, \"The 'modUserName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUserName).to.not.equal(undefined, \"The 'publishUserName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{serverURL}}/api/v1/content/{{testContentId}}", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "content", + "{{testContentId}}" + ] + } + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "pm.test(\"HTTP Status code must be 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "" + ] + } + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ] + }, { "name": "Content not exists", "event": [ @@ -1429,42 +1630,26 @@ "response": [] } ], - "variable": [ - { - "key": "contentletIdentifier", - "value": "" - }, - { - "key": "contentletInode", - "value": "" - }, - { - "key": "fireActionLanguageKey", - "value": "" - }, - { - "key": "parentId1", - "value": "" - }, - { - "key": "parentInode1", - "value": "" - }, - { - "key": "parentId2", - "value": "" - }, - { - "key": "parentInode2", - "value": "" - }, + "event": [ { - "key": "parent1contentlets", - "value": "" + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } }, { - "key": "parent2contentlets", - "value": "" + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } } ] } \ No newline at end of file diff --git a/dotcms-postman/src/main/resources/postman/Content_Resource.postman_collection.json b/dotcms-postman/src/main/resources/postman/Content_Resource.postman_collection.json index 37cbe0feb598..d759faca0d4c 100644 --- a/dotcms-postman/src/main/resources/postman/Content_Resource.postman_collection.json +++ b/dotcms-postman/src/main/resources/postman/Content_Resource.postman_collection.json @@ -1,11 +1,10 @@ { "info": { - "_postman_id": "e7d6d683-f049-4c68-8712-0f2c8513bda8", + "_postman_id": "19eae33b-46d1-4607-83d4-d79afe27e8a0", "name": "Content Resource", "description": "Content Resource test", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "5403727", - "_collection_link": "https://cloudy-robot-285072.postman.co/workspace/JCastro-Workspace~5bfa586e-54db-429b-b7d5-c4ff997e3a0d/collection/5403727-e7d6d683-f049-4c68-8712-0f2c8513bda8?action=share&creator=5403727&source=collection_link" + "_exporter_id": "5403727" }, "item": [ { @@ -65,8 +64,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -357,8 +354,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -572,12 +567,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -1628,8 +1621,7 @@ "header": [ { "key": "Origin", - "value": "{{serverURL}}", - "type": "text" + "value": "{{serverURL}}" } ], "body": { @@ -1782,8 +1774,7 @@ "header": [ { "key": "Origin", - "value": "{{serverURL}}", - "type": "text" + "value": "{{serverURL}}" } ], "body": { @@ -1867,8 +1858,7 @@ "header": [ { "key": "Origin", - "value": "{{serverURL}}", - "type": "text" + "value": "{{serverURL}}" } ], "body": { @@ -1952,8 +1942,7 @@ "header": [ { "key": "Origin", - "value": "{{serverURL}}", - "type": "text" + "value": "{{serverURL}}" } ], "body": { @@ -2050,8 +2039,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -2489,6 +2476,206 @@ ], "description": "The Auto-Save feature allows dotCMS to automatically save any changes made to a given Contentlet by the User after X amount of seconds have passed.\n\nThe new Endpoint method created for this: **`/api/v1/_draft`** , works like this:\n\n- If the User is working **on the live version of the current Contentlet** and make changes to it, the draft request will create a working version in order to auto-save any changes.\n- When a second change is made, the draft method will re-use the previously generated Inode and will overwrite it with the new changes.\n- Finally, any incoming changes will keep overwriting the previous working Inode. This way, dotCMS will overwrite one single working Inode instead of creating hundreds if not thousands of \"useless\" records for any change." }, + { + "name": "Checking JSON Attributes", + "item": [ + { + "name": "Checking Content Audit Attributes", + "item": [ + { + "name": "Creating Test Generic Content", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Test content created successfully\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.errors.length).to.eql(0);", + " var contentId = Object.keys(jsonData.entity.results[0]);", + " pm.collectionVariables.set(\"testContentId\", jsonData.entity.results[0][contentId].identifier);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"contentlets\": [\n {\n \"contentType\": \"webPageContent\",\n \"title\": \"Test Generic Content\",\n \"contentHost\": \"default\",\n \"body\": \"This is my Test Generic Content\"\n }\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/workflow/actions/default/fire/PUBLISH", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "workflow", + "actions", + "default", + "fire", + "PUBLISH" + ] + } + }, + "response": [] + }, + { + "name": "Retrieving Test Generic Content", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().contentlets[0];", + " ", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.ownerName).to.not.equal(undefined, \"The 'ownerName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUserName).to.not.equal(undefined, \"The 'modUserName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUserName).to.not.equal(undefined, \"The 'publishUserName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{serverURL}}/api/content/id/{{testContentId}}", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "content", + "id", + "{{testContentId}}" + ] + } + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "pm.test(\"HTTP Status code must be 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "" + ] + } + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ] + }, { "name": "invalidateSession", "event": [ @@ -3122,59 +3309,5 @@ ] } } - ], - "variable": [ - { - "key": "contentTypeId", - "value": "" - }, - { - "key": "fieldId", - "value": "" - }, - { - "key": "contentTypeName", - "value": "" - }, - { - "key": "identifier22756", - "value": "" - }, - { - "key": "fileId", - "value": "" - }, - { - "key": "fileInode", - "value": "" - }, - { - "key": "fileName", - "value": "" - }, - { - "key": "originalTitle", - "value": "" - }, - { - "key": "contentInode", - "value": "" - }, - { - "key": "contentIdentifier", - "value": "" - }, - { - "key": "firstAutoSaveTitle", - "value": "" - }, - { - "key": "secondAutoSaveTitle", - "value": "" - }, - { - "key": "thirdAutoSaveTitle", - "value": "" - } ] -} +} \ No newline at end of file diff --git a/dotcms-postman/src/main/resources/postman/GraphQLTests.json b/dotcms-postman/src/main/resources/postman/GraphQLTests.json index cbb0b2df26b1..4bf769b78b00 100644 --- a/dotcms-postman/src/main/resources/postman/GraphQLTests.json +++ b/dotcms-postman/src/main/resources/postman/GraphQLTests.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "611b379f-e7c5-4732-8b92-2d34993515d4", + "_postman_id": "7d417544-c1a3-4b9c-a227-0869ee7c27df", "name": "GraphQL", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "5403727" @@ -256,411 +256,1159 @@ "name": "Page API", "item": [ { - "name": "pre_ImportBundleWithContext", - "event": [ + "name": "Init And Test Data Import", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Bundle uploaded sucessfully\", function () {", - " pm.response.to.have.status(200);", - "", - " var jsonData = pm.response.json();", - " console.log(jsonData);", - "", - " pm.expect(jsonData[\"bundleName\"]).to.eql(\"assets.tar.gz\");", - " pm.expect(jsonData[\"status\"]).to.eql(\"SUCCESS\");", - "});" + "name": "pre_ImportBundleWithContext", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Bundle uploaded sucessfully\", function () {", + " pm.response.to.have.status(200);", + "", + " var jsonData = pm.response.json();", + " console.log(jsonData);", + "", + " pm.expect(jsonData[\"bundleName\"]).to.eql(\"assets.tar.gz\");", + " pm.expect(jsonData[\"status\"]).to.eql(\"SUCCESS\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "password", + "value": "admin", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/octet-stream" + }, + { + "key": "Content-Disposition", + "value": "attachment" + } ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "basic", - "basic": [ + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "file", + "type": "file", + "src": "resources/GraphQL/assets.tar.gz" + } + ] + }, + "url": { + "raw": "{{serverURL}}/api/bundle?sync=true", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "bundle" + ], + "query": [ + { + "key": "sync", + "value": "true" + }, + { + "key": "AUTH_TOKEN", + "value": "", + "disabled": true + } + ] + }, + "description": "Imports a Bundle that includes:\n* A piece of content with a tag field without any tags selected" + }, + "response": [] + }, + { + "name": "pre_ImportBundleWithPersonas", + "event": [ { - "key": "username", - "value": "admin@dotcms.com", - "type": "string" + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Bundle uploaded sucessfully\", function () {", + " pm.response.to.have.status(200);", + "", + " var jsonData = pm.response.json();", + " console.log(jsonData);", + "", + " pm.expect(jsonData[\"bundleName\"]).to.eql(\"personas.tar.gz\");", + " pm.expect(jsonData[\"status\"]).to.eql(\"SUCCESS\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "password", + "value": "admin", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/octet-stream" + }, + { + "key": "Content-Disposition", + "value": "attachment" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "file", + "type": "file", + "src": "resources/GraphQL/personas.tar.gz" + } + ] }, + "url": { + "raw": "{{serverURL}}/api/bundle?sync=true", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "bundle" + ], + "query": [ + { + "key": "sync", + "value": "true" + }, + { + "key": "AUTH_TOKEN", + "value": "", + "disabled": true + } + ] + }, + "description": "Imports a Bundle that includes:\n* Imports personas" + }, + "response": [] + }, + { + "name": "pre_ImportBundleWithDemoHost", + "event": [ { - "key": "password", - "value": "admin", - "type": "string" + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Bundle uploaded sucessfully\", function () {", + " pm.response.to.have.status(200);", + "", + " var jsonData = pm.response.json();", + " console.log(jsonData);", + "", + " pm.expect(jsonData[\"bundleName\"]).to.eql(\"demo.dotcms.com.tar.gz\");", + " pm.expect(jsonData[\"status\"]).to.eql(\"SUCCESS\");", + "});" + ], + "type": "text/javascript" + } } - ] + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "password", + "value": "admin", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/octet-stream" + }, + { + "key": "Content-Disposition", + "value": "attachment" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "file", + "type": "file", + "src": "resources/GraphQL/demo.dotcms.com.tar.gz" + } + ] + }, + "url": { + "raw": "{{serverURL}}/api/bundle?sync=true", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "bundle" + ], + "query": [ + { + "key": "sync", + "value": "true" + }, + { + "key": "AUTH_TOKEN", + "value": "", + "disabled": true + } + ] + }, + "description": "Imports a Bundle that includes:\n* Imports demo.dotcms.com" + }, + "response": [] }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/octet-stream" + { + "name": "pre_ImportBundleWithTestPage", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Bundle uploaded sucessfully\", function () {", + " pm.response.to.have.status(200);", + "", + " var jsonData = pm.response.json();", + " console.log(jsonData);", + "", + " pm.expect(jsonData[\"bundleName\"]).to.eql(\"test-page-graphql-render.tar.gz\");", + " pm.expect(jsonData[\"status\"]).to.eql(\"SUCCESS\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "password", + "value": "admin", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/octet-stream" + }, + { + "key": "Content-Disposition", + "value": "attachment" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "file", + "type": "file", + "src": "resources/GraphQL/test-page-graphql-render.tar.gz" + } + ] + }, + "url": { + "raw": "{{serverURL}}/api/bundle?sync=true", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "bundle" + ], + "query": [ + { + "key": "sync", + "value": "true" + }, + { + "key": "AUTH_TOKEN", + "value": "", + "disabled": true + } + ] + }, + "description": "Imports a Bundle that includes:\n\n* pp-test page with all the dependencies. pp-test page was created on a demo.dotcms.com site" }, - { - "key": "Content-Disposition", - "type": "text", - "value": "attachment" - } - ], - "body": { - "mode": "formdata", - "formdata": [ + "response": [] + }, + { + "name": "Switch site to 'demo.dotcms.com'", + "event": [ { - "key": "file", - "type": "file", - "src": "resources/GraphQL/assets.tar.gz" + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 \", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "", + "", + "pm.test(\"Valid response\", function () {", + " var jsonData = pm.response.json();", + "", + " pm.expect(jsonData.entity.hostSwitched).equal(true);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{serverURL}}/api/v1/site/switch/48190c8c-42c4-46af-8d1a-0cd5db894797", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "site", + "switch", + "48190c8c-42c4-46af-8d1a-0cd5db894797" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Checking Content Audit Attributes", + "item": [ + { + "name": "Page API", + "item": [ + { + "name": "Retrieving HTML Page Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().data.page;", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.owner.firstName).to.not.equal(undefined, \"The 'owner.firstName' attribute must be present\");", + " pm.expect(entity.owner.lastName).to.not.equal(undefined, \"The 'owner.lastName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUser.firstName).to.not.equal(undefined, \"The 'modUser.firstName' attribute must be present\");", + " pm.expect(entity.modUser.lastName).to.not.equal(undefined, \"The 'modUser.lastName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUser.firstName).to.not.equal(undefined, \"The 'publishUser.firstName' attribute must be present\");", + " pm.expect(entity.publishUser.lastName).to.not.equal(undefined, \"The 'publishUser.lastName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query PageAPI {\n page(url: \"/pp-test\") {\n title\n creationDate\n owner {\n firstName\n lastName\n userId\n email\n }\n modDate\n modUser {\n firstName\n lastName\n userId\n email\n }\n publishDate\n publishUser {\n firstName\n lastName\n userId\n email\n }\n }\n}", + "variables": "" + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/graphql", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "graphql" + ] + } + }, + "response": [] } ] }, - "url": { - "raw": "{{serverURL}}/api/bundle/sync", - "host": [ - "{{serverURL}}" - ], - "path": [ - "api", - "bundle", - "sync" - ], - "query": [ + { + "name": "Page Render", + "item": [ { - "key": "AUTH_TOKEN", - "value": "", - "disabled": true + "name": "Retrieving HTML Page Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().data.page;", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.owner.firstName).to.not.equal(undefined, \"The 'owner.firstName' attribute must be present\");", + " pm.expect(entity.owner.lastName).to.not.equal(undefined, \"The 'owner.lastName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUser.firstName).to.not.equal(undefined, \"The 'modUser.firstName' attribute must be present\");", + " pm.expect(entity.modUser.lastName).to.not.equal(undefined, \"The 'modUser.lastName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUser.firstName).to.not.equal(undefined, \"The 'publishUser.firstName' attribute must be present\");", + " pm.expect(entity.publishUser.lastName).to.not.equal(undefined, \"The 'publishUser.lastName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query PageRender {\n page(url: \"/pp-test\") {\n title\n creationDate\n owner {\n firstName\n lastName\n userId\n email\n }\n modDate\n modUser {\n firstName\n lastName\n userId\n email\n }\n publishDate\n publishUser {\n firstName\n lastName\n userId\n email\n }\n }\n}", + "variables": "" + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/graphql", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "graphql" + ] + } + }, + "response": [] } ] }, - "description": "Imports a Bundle that includes:\n* A piece of content with a tag field without any tags selected" - }, - "response": [] - }, - { - "name": "pre_ImportBundleWithPersonas", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Bundle uploaded sucessfully\", function () {", - " pm.response.to.have.status(200);", - "", - " var jsonData = pm.response.json();", - " console.log(jsonData);", - "", - " pm.expect(jsonData[\"bundleName\"]).to.eql(\"personas.tar.gz\");", - " pm.expect(jsonData[\"status\"]).to.eql(\"SUCCESS\");", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "basic", - "basic": [ + "name": "Container Rendered", + "item": [ { - "key": "username", - "value": "admin@dotcms.com", - "type": "string" + "name": "Retrieving Test Generic Content Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().data.page;", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.owner.firstName).to.not.equal(undefined, \"The 'owner.firstName' attribute must be present\");", + " pm.expect(entity.owner.lastName).to.not.equal(undefined, \"The 'owner.lastName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUser.firstName).to.not.equal(undefined, \"The 'modUser.firstName' attribute must be present\");", + " pm.expect(entity.modUser.lastName).to.not.equal(undefined, \"The 'modUser.lastName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUser.firstName).to.not.equal(undefined, \"The 'publishUser.firstName' attribute must be present\");", + " pm.expect(entity.publishUser.lastName).to.not.equal(undefined, \"The 'publishUser.lastName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query PageRender {\n page(url: \"/pp-test\") {\n title\n creationDate\n owner {\n firstName\n lastName\n userId\n email\n }\n modDate\n modUser {\n firstName\n lastName\n userId\n email\n }\n publishDate\n publishUser {\n firstName\n lastName\n userId\n email\n }\n }\n}", + "variables": "" + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/graphql", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "graphql" + ] + } + }, + "response": [] }, { - "key": "password", - "value": "admin", - "type": "string" + "name": "Retrieving HTML Page Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().data.page;", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.owner.firstName).to.not.equal(undefined, \"The 'owner.firstName' attribute must be present\");", + " pm.expect(entity.owner.lastName).to.not.equal(undefined, \"The 'owner.lastName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUser.firstName).to.not.equal(undefined, \"The 'modUser.firstName' attribute must be present\");", + " pm.expect(entity.modUser.lastName).to.not.equal(undefined, \"The 'modUser.lastName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUser.firstName).to.not.equal(undefined, \"The 'publishUser.firstName' attribute must be present\");", + " pm.expect(entity.publishUser.lastName).to.not.equal(undefined, \"The 'publishUser.lastName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query PageRender {\n page(url: \"/pp-test\") {\n title\n creationDate\n owner {\n firstName\n lastName\n userId\n email\n }\n modDate\n modUser {\n firstName\n lastName\n userId\n email\n }\n publishDate\n publishUser {\n firstName\n lastName\n userId\n email\n }\n }\n}", + "variables": "" + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/graphql", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "graphql" + ] + } + }, + "response": [] } ] }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/octet-stream" - }, - { - "key": "Content-Disposition", - "type": "text", - "value": "attachment" - } - ], - "body": { - "mode": "formdata", - "formdata": [ + { + "name": "Content API", + "item": [ { - "key": "file", - "type": "file", - "src": "resources/GraphQL/personas.tar.gz" - } - ] - }, - "url": { - "raw": "{{serverURL}}/api/bundle/sync", - "host": [ - "{{serverURL}}" - ], - "path": [ - "api", - "bundle", - "sync" - ], - "query": [ + "name": "Creating Test Generic Content", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Test content created successfully\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.errors.length).to.eql(0);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"contentlets\": [\n {\n \"contentType\": \"webPageContent\",\n \"title\": \"Test Generic Content for GraphQL Tests\",\n \"contentHost\": \"demo.dotcms.com\",\n \"body\": \"This is my Test Generic Content for GraphQL Tests\"\n }\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/workflow/actions/default/fire/PUBLISH", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "workflow", + "actions", + "default", + "fire", + "PUBLISH" + ] + } + }, + "response": [] + }, { - "key": "AUTH_TOKEN", - "value": "", - "disabled": true + "name": "Retrieving Test Generic Content Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().data.webPageContentCollection[0];", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.owner.firstName).to.not.equal(undefined, \"The 'owner.firstName' attribute must be present\");", + " pm.expect(entity.owner.lastName).to.not.equal(undefined, \"The 'owner.lastName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUser.firstName).to.not.equal(undefined, \"The 'modUser.firstName' attribute must be present\");", + " pm.expect(entity.modUser.lastName).to.not.equal(undefined, \"The 'modUser.lastName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUser.firstName).to.not.equal(undefined, \"The 'publishUser.firstName' attribute must be present\");", + " pm.expect(entity.publishUser.lastName).to.not.equal(undefined, \"The 'publishUser.lastName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query ContentAPI {\n webPageContentCollection(\n query: \"+title:Test Generic Content for GraphQL Tests\"\n limit: 10\n offset: 0\n sortBy: \"score\"\n ) {\n title\n creationDate\n owner {\n firstName\n lastName\n userId\n email\n }\n modDate\n modUser {\n firstName\n lastName\n userId\n email\n }\n publishDate\n publishUser {\n firstName\n lastName\n userId\n email\n }\n }\n}\n", + "variables": "" + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/graphql", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "graphql" + ] + } + }, + "response": [] } ] }, - "description": "Imports a Bundle that includes:\n* Imports personas" - }, - "response": [] - }, - { - "name": "pre_ImportBundleWithDemoHost", - "event": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Bundle uploaded sucessfully\", function () {", - " pm.response.to.have.status(200);", - "", - " var jsonData = pm.response.json();", - " console.log(jsonData);", - "", - " pm.expect(jsonData[\"bundleName\"]).to.eql(\"demo.dotcms.com.tar.gz\");", - " pm.expect(jsonData[\"status\"]).to.eql(\"SUCCESS\");", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "basic", - "basic": [ + "name": "Search", + "item": [ { - "key": "username", - "value": "admin@dotcms.com", - "type": "string" + "name": "Creating Test Generic Content", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Test content created successfully\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.errors.length).to.eql(0);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"contentlets\": [\n {\n \"contentType\": \"webPageContent\",\n \"title\": \"Test Generic Content for GraphQL Tests 2\",\n \"contentHost\": \"demo.dotcms.com\",\n \"body\": \"This is my Test Generic Content for GraphQL Tests 2\"\n }\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/workflow/actions/default/fire/PUBLISH", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "workflow", + "actions", + "default", + "fire", + "PUBLISH" + ] + } + }, + "response": [] }, { - "key": "password", - "value": "admin", - "type": "string" - } - ] - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/octet-stream" - }, - { - "key": "Content-Disposition", - "type": "text", - "value": "attachment" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "file", - "type": "file", - "src": "resources/GraphQL/demo.dotcms.com.tar.gz" + "name": "Retrieving Test Generic Content Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().data.search[0];", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.owner.firstName).to.not.equal(undefined, \"The 'owner.firstName' attribute must be present\");", + " pm.expect(entity.owner.lastName).to.not.equal(undefined, \"The 'owner.lastName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUser.firstName).to.not.equal(undefined, \"The 'modUser.firstName' attribute must be present\");", + " pm.expect(entity.modUser.lastName).to.not.equal(undefined, \"The 'modUser.lastName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUser.firstName).to.not.equal(undefined, \"The 'publishUser.firstName' attribute must be present\");", + " pm.expect(entity.publishUser.lastName).to.not.equal(undefined, \"The 'publishUser.lastName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\n search(query: \"+contentType:webPageContent +title:Test Generic Content for GraphQL Tests\", limit: 10) {\n title\n creationDate\n modDate\n modUser {\n firstName\n lastName\n userId\n email\n }\n owner {\n firstName\n lastName\n userId\n email\n }\n publishDate\n publishUser {\n firstName\n lastName\n userId\n email\n }\n }\n}\n", + "variables": "" + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/graphql", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "graphql" + ] + } + }, + "response": [] } ] }, - "url": { - "raw": "{{serverURL}}/api/bundle/sync", - "host": [ - "{{serverURL}}" - ], - "path": [ - "api", - "bundle", - "sync" - ], - "query": [ + { + "name": "Relationship Query", + "item": [ { - "key": "AUTH_TOKEN", - "value": "", - "disabled": true + "name": "Retrieving Related Content Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().data.destinationCollection[0];", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.owner.firstName).to.not.equal(undefined, \"The 'owner.firstName' attribute must be present\");", + " pm.expect(entity.owner.lastName).to.not.equal(undefined, \"The 'owner.lastName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUser.firstName).to.not.equal(undefined, \"The 'modUser.firstName' attribute must be present\");", + " pm.expect(entity.modUser.lastName).to.not.equal(undefined, \"The 'modUser.lastName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUser.firstName).to.not.equal(undefined, \"The 'publishUser.firstName' attribute must be present\");", + " pm.expect(entity.publishUser.lastName).to.not.equal(undefined, \"The 'publishUser.lastName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + }, + { + "key": "saveHelperData", + "type": "any" + }, + { + "key": "showPassword", + "value": false, + "type": "boolean" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query relationshipQuery {\n destinationCollection(\n limit: 10,\n offset: 0,\n sortBy: \"score\"\n ){\n title\n creationDate\n modDate\n modUser {\n firstName\n lastName\n userId\n email\n }\n owner {\n firstName\n lastName\n userId\n email\n }\n publishDate\n publishUser {\n firstName\n lastName\n userId\n email\n }\n activities{\n title\n urlTitle\n image{\n idPath\n }\n }\n } \n}", + "variables": "" + } + }, + "url": { + "raw": "{{serverURL}}/api/v1/graphql", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "graphql" + ] + } + }, + "response": [] } ] - }, - "description": "Imports a Bundle that includes:\n* Imports demo.dotcms.com" - }, - "response": [] - }, - { - "name": "pre_ImportBundleWithTestPage", + } + ], "event": [ { - "listen": "test", + "listen": "prerequest", "script": { + "type": "text/javascript", + "packages": {}, "exec": [ - "pm.test(\"Bundle uploaded sucessfully\", function () {", - " pm.response.to.have.status(200);", - "", - " var jsonData = pm.response.json();", - " console.log(jsonData);", - "", - " pm.expect(jsonData[\"bundleName\"]).to.eql(\"test-page-graphql-render.tar.gz\");", - " pm.expect(jsonData[\"status\"]).to.eql(\"SUCCESS\");", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "basic", - "basic": [ - { - "key": "username", - "value": "admin@dotcms.com", - "type": "string" - }, - { - "key": "password", - "value": "admin", - "type": "string" - } - ] - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/octet-stream" - }, - { - "key": "Content-Disposition", - "type": "text", - "value": "attachment" + "" + ] } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "file", - "type": "file", - "src": "resources/GraphQL/test-page-graphql-render.tar.gz" - } - ] - }, - "url": { - "raw": "{{serverURL}}/api/bundle/sync", - "host": [ - "{{serverURL}}" - ], - "path": [ - "api", - "bundle", - "sync" - ], - "query": [ - { - "key": "sync", - "value": "true" - }, - { - "key": "AUTH_TOKEN", - "value": "", - "disabled": true - } - ] }, - "description": "Imports a Bundle that includes:\n\n* pp-test page with all the dependencies. pp-test page was created on a demo.dotcms.com site" - }, - "response": [] - }, - { - "name": "Switch site to 'demo.dotcms.com'", - "event": [ { "listen": "test", "script": { + "type": "text/javascript", + "packages": {}, "exec": [ - "pm.test(\"Status code is 200 \", function () {", + "pm.test(\"HTTP Status code must be 200\", function () {", " pm.response.to.have.status(200);", "});", - "", - "", - "", - "pm.test(\"Valid response\", function () {", - " var jsonData = pm.response.json();", - "", - " pm.expect(jsonData.entity.hostSwitched).equal(true);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "auth": { - "type": "basic", - "basic": [ - { - "key": "password", - "value": "admin", - "type": "string" - }, - { - "key": "username", - "value": "admin@dotcms.com", - "type": "string" - }, - { - "key": "saveHelperData", - "type": "any" - }, - { - "key": "showPassword", - "value": false, - "type": "boolean" - } - ] - }, - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" + "" + ] } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{serverURL}}/api/v1/site/switch/48190c8c-42c4-46af-8d1a-0cd5db894797", - "host": [ - "{{serverURL}}" - ], - "path": [ - "api", - "v1", - "site", - "switch", - "48190c8c-42c4-46af-8d1a-0cd5db894797" - ] } - }, - "response": [] + ] }, { "name": "RenderDestinationsCostaRicaPage", @@ -774,8 +1522,7 @@ "header": [ { "key": "User-Agent", - "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36", - "type": "text" + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], "url": { @@ -903,8 +1650,7 @@ "header": [ { "key": "User-Agent", - "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36", - "type": "text" + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], "body": { @@ -1008,8 +1754,7 @@ "header": [ { "key": "User-Agent", - "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36", - "type": "text" + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], "body": { @@ -1120,8 +1865,7 @@ "header": [ { "key": "User-Agent", - "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36", - "type": "text" + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], "body": { @@ -1276,13 +2020,11 @@ { "key": "Cookie", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", - "type": "text", "disabled": true }, { "key": "User-Agent", - "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36", - "type": "text" + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], "body": { @@ -1360,13 +2102,11 @@ { "key": "Cookie", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", - "type": "text", "disabled": true }, { "key": "User-Agent", - "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36", - "type": "text" + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], "body": { @@ -1431,12 +2171,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -1451,16 +2189,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -1538,13 +2279,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -1610,12 +2349,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -1630,16 +2367,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -1745,13 +2485,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -1866,13 +2604,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -1941,13 +2677,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -2062,13 +2796,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -2176,13 +2908,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -2296,13 +3026,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -2371,12 +3099,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -2391,16 +3117,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -2527,13 +3256,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -2599,12 +3326,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -2619,16 +3344,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -2689,13 +3417,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -2771,13 +3497,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -2844,12 +3568,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -2864,16 +3586,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -2936,13 +3661,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -3014,12 +3737,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -3034,16 +3755,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -3096,12 +3820,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -3116,16 +3838,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -3178,12 +3903,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -3198,16 +3921,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -3260,12 +3986,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -3280,16 +4004,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -3342,12 +4069,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -3362,16 +4087,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -3424,12 +4152,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -3444,16 +4170,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -3506,12 +4235,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -3526,16 +4253,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -3961,8 +4691,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4023,8 +4751,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4065,9 +4791,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -4202,8 +4926,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4268,8 +4990,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4317,8 +5037,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4391,8 +5109,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4456,8 +5172,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4517,7 +5231,7 @@ " pm.expect(imageFieldJson.fileAsset.mime).to.eql(\"image/jpeg\");", " ", " // metaData", - " pm.expect(imageFieldJson.metaData.length).to.eql(13, \"Returned Metadata attributes is \" + imageFieldJson.metaData.length);", + " pm.expect(imageFieldJson.metaData.length).to.eql(13);", " pm.expect(hasProperty(imageFieldJson.metaData, \"fileSize\", \"5494\"), 'FAILED:[fileSize]').to.be.true;", " pm.expect(hasProperty(imageFieldJson.metaData, \"length\", \"5494\"), 'FAILED:[length]').to.be.true;", " pm.expect(hasProperty(imageFieldJson.metaData, \"width\", \"139\"), 'FAILED:[width]').to.be.true;", @@ -4527,6 +5241,9 @@ " pm.expect(hasProperty(imageFieldJson.metaData, \"sha256\", \"d6b09b7a7d42e6a84e455e7257faf32c4351aa9bb491ceb939f7f3443c2150ae\"), 'FAILED:[sha256]').to.be.true;", " pm.expect(hasProperty(imageFieldJson.metaData, \"title\", \"tommylee18005.jpeg\"), 'FAILED:[title]').to.be.true;", " pm.expect(hasProperty(imageFieldJson.metaData, \"isImage\", \"true\"), 'FAILED:[isImage]').to.be.true;", + " pm.expect(hasProperty(imageFieldJson.metaData, \"editableAsText\", \"false\"), 'FAILED:[editableAsText]').to.be.true;", + " pm.expect(hasProperty(imageFieldJson.metaData, \"name\", \"tommylee18005.jpeg\"), 'FAILED:[name]').to.be.true;", + " pm.expect(imageFieldJson.metaData.version).to.be.not.null;", " pm.expect(imageFieldJson.metaData.modDate).to.be.not.null; ", "});", "", @@ -4573,7 +5290,8 @@ "}", "" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], @@ -4642,12 +5360,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -4662,16 +5378,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -4840,8 +5559,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4902,8 +5619,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -4960,8 +5675,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -5002,8 +5715,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -5060,8 +5771,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -5201,8 +5910,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -5309,12 +6016,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -5329,16 +6034,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -5391,12 +6099,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -5411,16 +6117,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -5532,12 +6241,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -5552,16 +6259,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -5672,8 +6382,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -5818,12 +6526,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -5838,16 +6544,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -5958,12 +6667,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -5978,16 +6685,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -6099,12 +6809,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -6119,16 +6827,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -6456,13 +7167,11 @@ "header": [ { "key": "Cookie", - "type": "text", "value": "JSESSIONID=1DF38761AD8B360EF1AD42C4AF07EC35", "disabled": true }, { "key": "User-Agent", - "type": "text", "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" } ], @@ -6537,12 +7246,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -6557,16 +7264,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -6679,12 +7389,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -6699,16 +7407,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -6817,8 +7528,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -6864,9 +7573,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -6975,9 +7682,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -7224,9 +7929,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -7353,8 +8056,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -7400,9 +8101,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -7461,8 +8160,7 @@ "header": [ { "key": "dotcachettl", - "value": "30", - "type": "text" + "value": "30" } ], "body": { @@ -7511,9 +8209,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -7572,8 +8268,7 @@ "header": [ { "key": "dotcachettl", - "value": "0", - "type": "text" + "value": "0" } ], "body": { @@ -7662,8 +8357,7 @@ "header": [ { "key": "dotcachettl", - "value": "-1", - "type": "text" + "value": "-1" } ], "body": { @@ -7710,8 +8404,7 @@ "header": [ { "key": "dotcachettl", - "value": "30", - "type": "text" + "value": "30" } ], "body": { @@ -7760,9 +8453,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -7897,8 +8588,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -7944,9 +8633,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -8059,9 +8746,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -8329,8 +9014,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -8376,9 +9059,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -8438,13 +9119,11 @@ "header": [ { "key": "dotcachettl", - "value": "30", - "type": "text" + "value": "30" }, { "key": "dotcachekey", - "value": "mykeyRH", - "type": "text" + "value": "mykeyRH" } ], "body": { @@ -8493,9 +9172,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -8596,8 +9273,7 @@ "header": [ { "key": "dotcachekey", - "value": "mykeyRH", - "type": "text" + "value": "mykeyRH" } ], "body": { @@ -8644,13 +9320,11 @@ "header": [ { "key": "dotcachettl", - "value": "-1", - "type": "text" + "value": "-1" }, { "key": "dotcachekey", - "value": "mykeyRH", - "type": "text" + "value": "mykeyRH" } ], "body": { @@ -8697,8 +9371,7 @@ "header": [ { "key": "dotcachekey", - "value": "mykeyRH", - "type": "text" + "value": "mykeyRH" } ], "body": { @@ -8767,8 +9440,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -8814,9 +9485,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -8925,9 +9594,7 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" + "value": "application/json" } ], "body": { @@ -9652,12 +10319,10 @@ "header": [ { "key": "Content-Type", - "type": "text", "value": "application/octet-stream" }, { "key": "Content-Disposition", - "type": "text", "value": "attachment" } ], @@ -9672,16 +10337,19 @@ ] }, "url": { - "raw": "{{serverURL}}/api/bundle/sync", + "raw": "{{serverURL}}/api/bundle?sync=true", "host": [ "{{serverURL}}" ], "path": [ "api", - "bundle", - "sync" + "bundle" ], "query": [ + { + "key": "sync", + "value": "true" + }, { "key": "AUTH_TOKEN", "value": "", @@ -9793,8 +10461,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], @@ -9842,8 +10508,6 @@ "header": [ { "key": "Content-Type", - "name": "Content-Type", - "type": "text", "value": "application/json" } ], diff --git a/dotcms-postman/src/main/resources/postman/PagesResourceTests.json b/dotcms-postman/src/main/resources/postman/PagesResourceTests.json index 5e59333628d7..f92272955abf 100644 --- a/dotcms-postman/src/main/resources/postman/PagesResourceTests.json +++ b/dotcms-postman/src/main/resources/postman/PagesResourceTests.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "fec7e83b-7dfc-4ec1-bcca-b4af2cc0072a", + "_postman_id": "553f0974-ec29-4c85-9d73-57478a3f39bc", "name": "Page API - [api/v1/page]", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "5403727" @@ -6599,6 +6599,126 @@ ], "description": "These requests are aimed to test the REST Endpoint that takes a Page ID, returns all Languages in the current instance and, for each of them, includes an additional attribute that indicates whether such a page is available in that specific language or not." }, + { + "name": "Checking JSON Attributes", + "item": [ + { + "name": "Checking Page Audit Attributes", + "item": [ + { + "name": "Retrieving HTML Page Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Checking that audit properties are present\", function () {", + " var entity = pm.response.json().entity.page;", + " ", + " pm.expect(entity.creationDate).to.not.equal(undefined, \"The 'creationDate' attribute must be present\");", + " pm.expect(entity.owner).to.not.equal(undefined, \"The 'owner' attribute must be present\");", + " pm.expect(entity.ownerName).to.not.equal(undefined, \"The 'ownerName' attribute must be present\");", + " pm.expect(entity.modDate).to.not.equal(undefined, \"The 'modDate' attribute must be present\");", + " pm.expect(entity.modUser).to.not.equal(undefined, \"The 'modUser' attribute must be present\");", + " pm.expect(entity.modUserName).to.not.equal(undefined, \"The 'modUserName' attribute must be present\");", + " pm.expect(entity.publishDate).to.not.equal(undefined, \"The 'publishDate' attribute must be present\");", + " pm.expect(entity.publishUser).to.not.equal(undefined, \"The 'publishUser' attribute must be present\");", + " pm.expect(entity.publishUserName).to.not.equal(undefined, \"The 'publishUserName' attribute must be present\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "admin", + "type": "string" + }, + { + "key": "username", + "value": "admin@dotcms.com", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{serverURL}}/api/v1/page/json/destinations/costa-rica", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "page", + "json", + "destinations", + "costa-rica" + ] + }, + "description": "http://localhost:8080/api/v1/page/json/{page-url}" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "pm.test(\"HTTP Status code must be 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "" + ] + } + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ] + }, { "name": "Put Create Page With CacheTTL 100", "event": [