@@ -248,6 +248,19 @@ private Mono<Void> checkApplicationStatus(Application application, ApplicationSt
248248 return Mono .error (new BizException (BizError .UNSUPPORTED_OPERATION , "BAD_REQUEST" ));
249249 }
250250
251+ private Mono <Void > checkApplicationViewRequest (Application application , ApplicationEndpoints .ApplicationRequestType expected ) {
252+ if (expected == ApplicationEndpoints .ApplicationRequestType .PUBLIC_TO_ALL && application .isPublicToAll ()) {
253+ return Mono .empty ();
254+ }
255+ if (expected == ApplicationEndpoints .ApplicationRequestType .PUBLIC_TO_MARKETPLACE && application .isPublicToMarketplace ()) {
256+ return Mono .empty ();
257+ }
258+ if (expected == ApplicationEndpoints .ApplicationRequestType .AGENCY_PROFILE && application .agencyProfile ()) {
259+ return Mono .empty ();
260+ }
261+ return Mono .error (new BizException (BizError .UNSUPPORTED_OPERATION , "BAD_REQUEST" ));
262+ }
263+
251264 private Mono <Boolean > updateApplicationStatus (String applicationId , ApplicationStatus applicationStatus ) {
252265 return checkCurrentUserApplicationPermission (applicationId , MANAGE_APPLICATIONS )
253266 .then (Mono .defer (() -> {
@@ -280,10 +293,11 @@ public Mono<ApplicationView> getEditingApplication(String applicationId) {
280293 });
281294 }
282295
283- public Mono <ApplicationView > getPublishedApplication (String applicationId ) {
296+ public Mono <ApplicationView > getPublishedApplication (String applicationId , ApplicationEndpoints . ApplicationRequestType requestType ) {
284297 return checkPermissionWithReadableErrorMsg (applicationId , READ_APPLICATIONS )
285298 .zipWhen (permission -> applicationService .findById (applicationId )
286- .delayUntil (application -> checkApplicationStatus (application , NORMAL )))
299+ .delayUntil (application -> checkApplicationStatus (application , NORMAL ))
300+ .delayUntil (application -> checkApplicationViewRequest (application , requestType )))
287301 .zipWhen (tuple -> applicationService .getAllDependentModulesFromApplication (tuple .getT2 (), true ), TupleUtils ::merge )
288302 .zipWhen (tuple -> organizationService .getOrgCommonSettings (tuple .getT2 ().getOrganizationId ()), TupleUtils ::merge )
289303 .zipWith (getTemplateIdFromApplicationId (applicationId ), TupleUtils ::merge )
0 commit comments