Skip to content

Commit

Permalink
Publisher fixes/tweaks (#3668)
Browse files Browse the repository at this point in the history
* Fixing missing securityService reference

* Add item metadata to publish items in '/api/2/publish/:siteId/package/:packageId' API

* Add itemCount to PublishPackage

* Remove approve and reject from available actions
  • Loading branch information
jmendeza authored Dec 5, 2024
1 parent c3baf4f commit 91fcc46
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 115 deletions.
61 changes: 42 additions & 19 deletions src/main/api/studio-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6584,18 +6584,13 @@ paths:
content:
application/json:
schema:
type: object
properties:
response:
$ref: '#/components/schemas/ApiResponse'
allOf:
- $ref: '#/components/schemas/PaginatedResponse'
- type: object
properties:
response:
$ref: '#/components/schemas/ApiResponse'
package:
$ref: '#/components/schemas/PublishPackage'
items:
type: array
items:
$ref: '#/components/schemas/PublishItem'
- $ref: '#/components/schemas/PublishPackageDetails'
'400':
$ref: '#/components/responses/BadRequest'
'401':
Expand Down Expand Up @@ -9469,6 +9464,9 @@ components:
publishedLiveCommitId:
type: string
description: commit ID published to live
itemCount:
type: integer
description: number of items in the package
required:
- id
- siteId
Expand All @@ -9478,15 +9476,15 @@ components:
- publishingTarget

PublishPackageDetails:
allOf:
- $ref: '#/components/schemas/PublishPackage'
- type: object
properties:
items:
type: array
description: list of items to be published
items:
$ref: '#/components/schemas/PublishItem'
type: object
properties:
package:
$ref: '#/components/schemas/PublishPackage'
items:
type: array
description: list of items to be published
items:
$ref: '#/components/schemas/PublishItem'

PublishItem:
type: object
Expand Down Expand Up @@ -9530,6 +9528,31 @@ components:
stagingError:
type: integer
description: ApiResponse code
itemMetadata:
type: object
description: metadata of the content item
properties:
label:
type: string
description: content item label (internal-name)
systemType:
type: string
description: system type of the content item
enum:
- asset
- page
- component
- levelDescriptor
- document
- renderingTemplate
- content type
- file
- folder
- script
- taxonomy
mimeType:
type: string
description: mime-type of content item file

PublishTaskProgress:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,27 @@ Collection<PublishItem> getPublishItems(@Param(SITE_ID) String siteId, @Param(PA
@Param(OFFSET) Integer offset, @Param(LIMIT) Integer limit);

/**
* Get the total number of items in a package
* Get the publish items (with metadata) for the given package
*
* @param siteId the site id
* @param packageId the package id
* @return the total number of items in the package
* @return PublishItemWithMetadata records for the package
*/
int getPublishItemsCount(@Param(SITE_ID) String siteId, @Param(PACKAGE_ID) long packageId);
default Collection<PublishItemWithMetadata> getPublishItemsWithMetadata(@Param(SITE_ID) String siteId, @Param(PACKAGE_ID) long packageId) {
return getPublishItemsWithMetadata(siteId, packageId, null, null);
}

/**
* Get the paginated list of publish items (with metadata) for the given package
*
* @param siteId the site id
* @param packageId the package id
* @param offset the offset to start from
* @param limit the max number of items to return
* @return PublishItemWithMetadata paginated records for the package
*/
Collection<PublishItemWithMetadata> getPublishItemsWithMetadata(@Param(SITE_ID) String siteId, @Param(PACKAGE_ID) long packageId,
@Param(OFFSET) Integer offset, @Param(LIMIT) Integer limit);

/**
* Update the state for all publish items in the package
Expand Down Expand Up @@ -503,6 +517,7 @@ default Collection<PublishPackage> getPublishPackages(@Param(SITE_ID) String sit
approvalStates, submitter, reviewer,
isScheduled, mapSortFields(sortFields, SORT_FIELD_MAP), offset, limit);
}

/**
* Internal method so we can map the sort fields to the actual columns for getPublishPackages
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2007-2024 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.craftercms.studio.api.v2.dal.publish;

/**
* Additional metadata for a publish item
*
* @param label The label of the item
* @param systemType The system type of the item
* @param mimeType The mime type of the item
*/
public record PublishItemMetadata(String label, String systemType, String mimeType) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2007-2024 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.craftercms.studio.api.v2.dal.publish;

/**
* {@link PublishItem} extension with additional {@link PublishItemMetadata}
*/
public class PublishItemWithMetadata extends PublishItem {

private PublishItemMetadata itemMetadata;

public PublishItemMetadata getItemMetadata() {
return itemMetadata;
}

public void setItemMetadata(PublishItemMetadata itemMetadata) {
this.itemMetadata = itemMetadata;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class PublishPackage {
protected String commitId;
protected String publishedStagingCommitId;
protected String publishedLiveCommitId;
protected int itemCount;

protected Person submitter;
protected Person reviewer;
Expand Down Expand Up @@ -244,6 +245,14 @@ public void setReviewer(final Person reviewer) {
this.reviewer = reviewer;
}

public int getItemCount() {
return itemCount;
}

public void setItemCount(int itemCount) {
this.itemCount = itemCount;
}

/**
* Possible values for the package approval state
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public final class ContentItemAvailableActionsConstants {
0b0000000000000000000000000000000000000000000010000000000000000000L;
public static final long PUBLISH =
0b0000000000000000000000000000000000000000000100000000000000000000L;
public static final long PUBLISH_APPROVE =
public static final long RETIRED_PUBLISH_APPROVED =
0b0000000000000000000000000000000000000000001000000000000000000000L;
public static final long PUBLISH_SCHEDULE =
0b0000000000000000000000000000000000000000010000000000000000000000L;
public static final long PUBLISH_REJECT =
public static final long RETIRED_PUBLISH_REJECT =
0b0000000000000000000000000000000000000000100000000000000000000000L;
public static final long ITEM_UNLOCK =
0b0000000000000000000000000000000000000001000000000000000000000000L;
Expand Down Expand Up @@ -186,7 +186,7 @@ public final class ContentItemAvailableActionsConstants {
CONTENT_DELETE + CONTENT_DELETE_CONTROLLER + CONTENT_DELETE_TEMPLATE;
// publish
public static final long BITMAP_PUBLISH =
PUBLISH + PUBLISH_APPROVE + PUBLISH_SCHEDULE + PUBLISH_REJECT;
PUBLISH + PUBLISH_SCHEDULE;
// item_unlock
public static final long BITMAP_ITEM_UNLOCK =
ITEM_UNLOCK;
Expand Down
Loading

0 comments on commit 91fcc46

Please sign in to comment.