Resolve merge conflict

temp
Mohamed Rashd 2 years ago
parent aa2fa45a5f
commit 9df320dd3b

@ -50,10 +50,11 @@ public interface ApplicationManager {
* *
* @param appId application id of the application to which the release should be created * @param appId application id of the application to which the release should be created
* @param releaseWrapper {@link EntAppReleaseWrapper} of the release to be created * @param releaseWrapper {@link EntAppReleaseWrapper} of the release to be created
* @param isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Created application release bean * @return Created application release bean
* @throws ApplicationManagementException if any error occurred while creating the application * @throws ApplicationManagementException if any error occurred while creating the application
*/ */
ApplicationRelease createEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper) ApplicationRelease createEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper, boolean isPublished)
throws ApplicationManagementException; throws ApplicationManagementException;
/** /**
@ -61,10 +62,11 @@ public interface ApplicationManager {
* *
* @param appId application id of the application to which the release should be created * @param appId application id of the application to which the release should be created
* @param releaseWrapper {@link WebAppReleaseWrapper} of the release to be created * @param releaseWrapper {@link WebAppReleaseWrapper} of the release to be created
* @param isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Created application release bean * @return Created application release bean
* @throws ApplicationManagementException if any error occurred while creating the application * @throws ApplicationManagementException if any error occurred while creating the application
*/ */
ApplicationRelease createWebAppRelease(int appId, WebAppReleaseWrapper releaseWrapper) ApplicationRelease createWebAppRelease(int appId, WebAppReleaseWrapper releaseWrapper, boolean isPublished)
throws ApplicationManagementException, ResourceManagementException; throws ApplicationManagementException, ResourceManagementException;
/** /**
@ -72,10 +74,11 @@ public interface ApplicationManager {
* *
* @param appId application id of the application to which the release should be created * @param appId application id of the application to which the release should be created
* @param releaseWrapper {@link PublicAppReleaseWrapper} of the release to be created * @param releaseWrapper {@link PublicAppReleaseWrapper} of the release to be created
* @param isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Created application release bean * @return Created application release bean
* @throws ApplicationManagementException if any error occurred while creating the application * @throws ApplicationManagementException if any error occurred while creating the application
*/ */
ApplicationRelease createPubAppRelease(int appId, PublicAppReleaseWrapper releaseWrapper) ApplicationRelease createPubAppRelease(int appId, PublicAppReleaseWrapper releaseWrapper, boolean isPublished)
throws ApplicationManagementException, ResourceManagementException; throws ApplicationManagementException, ResourceManagementException;
/** /**
@ -83,10 +86,11 @@ public interface ApplicationManager {
* *
* @param appId application id of the application to which the release should be created * @param appId application id of the application to which the release should be created
* @param releaseWrapper {@link CustomAppReleaseWrapper} of the release to be created * @param releaseWrapper {@link CustomAppReleaseWrapper} of the release to be created
* @param isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Created application release bean * @return Created application release bean
* @throws ApplicationManagementException if any error occurred while creating the application * @throws ApplicationManagementException if any error occurred while creating the application
*/ */
ApplicationRelease createCustomAppRelease(int appId, CustomAppReleaseWrapper releaseWrapper) ApplicationRelease createCustomAppRelease(int appId, CustomAppReleaseWrapper releaseWrapper, boolean isPublished)
throws ResourceManagementException, ApplicationManagementException; throws ResourceManagementException, ApplicationManagementException;
/** /**
@ -113,21 +117,23 @@ public interface ApplicationManager {
* required to do the validation of request and check the existence of application releaseDTO. * required to do the validation of request and check the existence of application releaseDTO.
* *
* @param applicationDTO Application DTO object. * @param applicationDTO Application DTO object.
* @param isPublished Wether the app should be added in PUBLISHED state instead of initial state
* @return {@link Application} * @return {@link Application}
* @throws ApplicationManagementException which throws if error occurs while during application management. * @throws ApplicationManagementException which throws if error occurs while during application management.
*/ */
Application addAppDataIntoDB(ApplicationDTO applicationDTO) throws Application addAppDataIntoDB(ApplicationDTO applicationDTO, boolean isPublished) throws
ApplicationManagementException; ApplicationManagementException;
/** /**
* This method is responsible for handling application creation * This method is responsible for handling application creation
* *
* @param app Application wrapper object which depends on the application type * @param app Application wrapper object which depends on the application type
* @param isPublished If the app should be created in PUBLISHED state
* @param <T> Application wrapper class which depends on the application type * @param <T> Application wrapper class which depends on the application type
* @return Created application bean * @return Created application bean
* @throws ApplicationManagementException if any error occurred while creating the application * @throws ApplicationManagementException if any error occurred while creating the application
*/ */
<T> Application createApplication(T app) throws ApplicationManagementException; <T> Application createApplication(T app, boolean isPublished) throws ApplicationManagementException;
/** /**
* Add an application to favourites * Add an application to favourites
* @param appId id of the application * @param appId id of the application
@ -249,10 +255,11 @@ public interface ApplicationManager {
* @param applicationDTO ApplicationDTO of the release * @param applicationDTO ApplicationDTO of the release
* @param applicationReleaseDTO ApplicatonRelease that need to be be created. * @param applicationReleaseDTO ApplicatonRelease that need to be be created.
* @param type {@link ApplicationType} * @param type {@link ApplicationType}
* @param isPublished if the app should be added in PUBLISHED state instead of initial state
* @return the unique id of the application release, if the application release succeeded else -1 * @return the unique id of the application release, if the application release succeeded else -1
*/ */
<T> ApplicationRelease createRelease(ApplicationDTO applicationDTO, ApplicationReleaseDTO applicationReleaseDTO, <T> ApplicationRelease createRelease(ApplicationDTO applicationDTO, ApplicationReleaseDTO applicationReleaseDTO,
ApplicationType type) ApplicationType type, boolean isPublished)
throws ApplicationManagementException; throws ApplicationManagementException;
/** /**

@ -131,11 +131,12 @@ public interface SPApplicationManager {
* @param identityServerId id of the identity server to which the created application should be mapped * @param identityServerId id of the identity server to which the created application should be mapped
* @param spId uid of the service provder to which the created application should be mapped * @param spId uid of the service provder to which the created application should be mapped
* @param <T> Application wrapper class which depends on application type (PUBLIC, ENTERPRISE & etc) * @param <T> Application wrapper class which depends on application type (PUBLIC, ENTERPRISE & etc)
* @param isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Application bean of the created application * @return Application bean of the created application
* @throws ApplicationManagementException if errors while creating and mapping the application * @throws ApplicationManagementException if errors while creating and mapping the application
* @throws RequestValidatingException if app contains any invalid payload * @throws RequestValidatingException if app contains any invalid payload
*/ */
<T> Application createSPApplication(T app, int identityServerId, String spId) throws ApplicationManagementException, RequestValidatingException; <T> Application createSPApplication(T app, int identityServerId, String spId, boolean isPublished) throws ApplicationManagementException, RequestValidatingException;
/** /**
* Validates application ids of the applications that should be attached * Validates application ids of the applications that should be attached

@ -138,11 +138,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
@Override @Override
public <T> Application createApplication(T app) throws ApplicationManagementException { public <T> Application createApplication(T app, boolean isPublished) throws ApplicationManagementException {
ApplicationDTO applicationDTO = uploadReleaseArtifactIfExist(app); ApplicationDTO applicationDTO = uploadReleaseArtifactIfExist(app);
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
Application application = addAppDataIntoDB(applicationDTO); Application application = addAppDataIntoDB(applicationDTO, isPublished);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
return application; return application;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
@ -167,7 +167,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
@Override @Override
public ApplicationRelease createEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper) public ApplicationRelease createEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper, boolean isPublished)
throws ApplicationManagementException { throws ApplicationManagementException {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(), releaseWrapper.getScreenshots(), ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(), releaseWrapper.getScreenshots(),
@ -177,7 +177,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper); ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
releaseDTO = uploadEntAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName(), true); releaseDTO = uploadEntAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName(), true);
try { try {
return createRelease(applicationDTO, releaseDTO, ApplicationType.ENTERPRISE); return createRelease(applicationDTO, releaseDTO, ApplicationType.ENTERPRISE, isPublished);
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating ent app release for application with the name: " + applicationDTO.getName(); String msg = "Error occurred while creating ent app release for application with the name: " + applicationDTO.getName();
log.error(msg, e); log.error(msg, e);
@ -187,7 +187,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
@Override @Override
public ApplicationRelease createWebAppRelease(int appId, WebAppReleaseWrapper releaseWrapper) public ApplicationRelease createWebAppRelease(int appId, WebAppReleaseWrapper releaseWrapper, boolean isPublished)
throws ApplicationManagementException, ResourceManagementException { throws ApplicationManagementException, ResourceManagementException {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
ApplicationDTO applicationDTO = applicationManager.getApplication(appId); ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
@ -196,7 +196,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper); ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
releaseDTO = uploadWebAppReleaseArtifacts(releaseDTO, artifact); releaseDTO = uploadWebAppReleaseArtifacts(releaseDTO, artifact);
try { try {
return createRelease(applicationDTO, releaseDTO, ApplicationType.WEB_CLIP); return createRelease(applicationDTO, releaseDTO, ApplicationType.WEB_CLIP, isPublished);
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating web app release for application with the name: " + applicationDTO.getName(); String msg = "Error occurred while creating web app release for application with the name: " + applicationDTO.getName();
log.error(msg, e); log.error(msg, e);
@ -206,7 +206,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
@Override @Override
public ApplicationRelease createPubAppRelease(int appId, PublicAppReleaseWrapper releaseWrapper) throws public ApplicationRelease createPubAppRelease(int appId, PublicAppReleaseWrapper releaseWrapper, boolean isPublished) throws
ResourceManagementException, ApplicationManagementException { ResourceManagementException, ApplicationManagementException {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
ApplicationDTO applicationDTO = applicationManager.getApplication(appId); ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
@ -216,7 +216,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper); ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
releaseDTO = uploadPubAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName()); releaseDTO = uploadPubAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
try { try {
return createRelease(applicationDTO, releaseDTO, ApplicationType.PUBLIC); return createRelease(applicationDTO, releaseDTO, ApplicationType.PUBLIC, isPublished);
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating ent public release for application with the name: " + applicationDTO.getName(); String msg = "Error occurred while creating ent public release for application with the name: " + applicationDTO.getName();
log.error(msg, e); log.error(msg, e);
@ -226,7 +226,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
@Override @Override
public ApplicationRelease createCustomAppRelease(int appId, CustomAppReleaseWrapper releaseWrapper) public ApplicationRelease createCustomAppRelease(int appId, CustomAppReleaseWrapper releaseWrapper, boolean isPublished)
throws ResourceManagementException, ApplicationManagementException { throws ResourceManagementException, ApplicationManagementException {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
ApplicationDTO applicationDTO = applicationManager.getApplication(appId); ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
@ -236,7 +236,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper); ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
releaseDTO = uploadCustomAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName()); releaseDTO = uploadCustomAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
try { try {
return createRelease(applicationDTO, releaseDTO, ApplicationType.CUSTOM); return createRelease(applicationDTO, releaseDTO, ApplicationType.CUSTOM, isPublished);
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating custom app release for application with the name: " + applicationDTO.getName(); String msg = "Error occurred while creating custom app release for application with the name: " + applicationDTO.getName();
log.error(msg, e); log.error(msg, e);
@ -1192,7 +1192,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
@Override @Override
public Application addAppDataIntoDB(ApplicationDTO applicationDTO) throws public Application addAppDataIntoDB(ApplicationDTO applicationDTO, boolean isPublished) throws
ApplicationManagementException { ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationReleaseDTO applicationReleaseDTO = null; ApplicationReleaseDTO applicationReleaseDTO = null;
@ -1258,12 +1258,21 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
List<ApplicationReleaseDTO> applicationReleaseEntities = new ArrayList<>(); List<ApplicationReleaseDTO> applicationReleaseEntities = new ArrayList<>();
if (applicationReleaseDTO != null) { if (applicationReleaseDTO != null) {
String initialLifecycleState = lifecycleStateManager.getInitialState(); String lifeCycleState = lifecycleStateManager.getInitialState();
applicationReleaseDTO.setCurrentState(initialLifecycleState); String[] publishStates= {"IN-REVIEW", "APPROVED", "PUBLISHED"};
applicationReleaseDTO = this.applicationReleaseDAO
.createRelease(applicationReleaseDTO, appId, tenantId); applicationReleaseDTO.setCurrentState(lifeCycleState);
LifecycleState lifecycleState = getLifecycleStateInstance(initialLifecycleState, initialLifecycleState); applicationReleaseDTO = this.applicationReleaseDAO.createRelease(applicationReleaseDTO, appId, tenantId);
LifecycleState lifecycleState = getLifecycleStateInstance(lifeCycleState, lifeCycleState);
this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId); this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
if(isPublished){
for (String state: publishStates) {
LifecycleChanger lifecycleChanger = new LifecycleChanger();
lifecycleChanger.setAction(state);
lifecycleChanger.setReason("Updated to " + state);
this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger);
}
}
applicationReleaseEntities.add(applicationReleaseDTO); applicationReleaseEntities.add(applicationReleaseDTO);
} }
applicationDTO.setId(appId); applicationDTO.setId(appId);
@ -1296,7 +1305,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
@Override @Override
public <T> ApplicationRelease createRelease(ApplicationDTO applicationDTO, ApplicationReleaseDTO applicationReleaseDTO, public <T> ApplicationRelease createRelease(ApplicationDTO applicationDTO, ApplicationReleaseDTO applicationReleaseDTO,
ApplicationType type) ApplicationType type, boolean isPublished)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -1322,13 +1331,23 @@ public class ApplicationManagerImpl implements ApplicationManager {
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
String initialState = lifecycleStateManager.getInitialState(); String lifeCycleState = lifecycleStateManager.getInitialState();
applicationReleaseDTO.setCurrentState(initialState); String[] publishStates = {"IN-REVIEW", "APPROVED", "PUBLISHED"};
LifecycleState lifecycleState = getLifecycleStateInstance(initialState, initialState);
applicationReleaseDTO.setCurrentState(lifeCycleState);
LifecycleState lifecycleState = getLifecycleStateInstance(lifeCycleState, lifeCycleState);
applicationReleaseDTO = this.applicationReleaseDAO applicationReleaseDTO = this.applicationReleaseDAO
.createRelease(applicationReleaseDTO, applicationDTO.getId(), tenantId); .createRelease(applicationReleaseDTO, applicationDTO.getId(), tenantId);
this.lifecycleStateDAO this.lifecycleStateDAO
.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId); .addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
if(isPublished){
for (String state: publishStates) {
LifecycleChanger lifecycleChanger = new LifecycleChanger();
lifecycleChanger.setAction(state);
lifecycleChanger.setReason("Updated to " + state);
this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger);
}
}
ApplicationRelease applicationRelease = APIUtil.releaseDtoToRelease(applicationReleaseDTO); ApplicationRelease applicationRelease = APIUtil.releaseDtoToRelease(applicationReleaseDTO);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
return applicationRelease; return applicationRelease;

@ -650,7 +650,7 @@ public class SPApplicationManagerImpl implements SPApplicationManager {
} }
@Override @Override
public <T> Application createSPApplication(T app, int identityServerId, String spId) throws ApplicationManagementException { public <T> Application createSPApplication(T app, int identityServerId, String spId, boolean isPublished) throws ApplicationManagementException {
validateServiceProviderUID(identityServerId, spId); validateServiceProviderUID(identityServerId, spId);
ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance();
ApplicationDTO applicationDTO = applicationManager.uploadReleaseArtifactIfExist(app); ApplicationDTO applicationDTO = applicationManager.uploadReleaseArtifactIfExist(app);
@ -660,7 +660,7 @@ public class SPApplicationManagerImpl implements SPApplicationManager {
} }
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
Application createdApp = applicationManager.addAppDataIntoDB(applicationDTO); Application createdApp = applicationManager.addAppDataIntoDB(applicationDTO, isPublished);
attachCreatedSPApplication(createdApp, identityServerId, spId); attachCreatedSPApplication(createdApp, identityServerId, spId);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
return createdApp; return createdApp;

@ -121,7 +121,7 @@ public class ApplicationManagementTest extends BaseTestCase {
applicationArtifact.setScreenshots(screenshots); applicationArtifact.setScreenshots(screenshots);
ApplicationManager manager = new ApplicationManagerImpl(); ApplicationManager manager = new ApplicationManagerImpl();
manager.createApplication(applicationWrapper); manager.createApplication(applicationWrapper, false);
} }
@DataProvider(name = "applicationIdDataProvider") @DataProvider(name = "applicationIdDataProvider")

@ -317,7 +317,12 @@ public interface ApplicationManagementPublisherAPI {
name = "application", name = "application",
value = "The application that need to be created.", value = "The application that need to be created.",
required = true) required = true)
ApplicationWrapper application); ApplicationWrapper application,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished);
@POST @POST
@Path("/web-app") @Path("/web-app")
@ -356,7 +361,12 @@ public interface ApplicationManagementPublisherAPI {
name = "webapp", name = "webapp",
value = "The web app that need to be created.", value = "The web app that need to be created.",
required = true) required = true)
WebAppWrapper webAppWrapper WebAppWrapper webAppWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished
); );
@POST @POST
@ -396,7 +406,12 @@ public interface ApplicationManagementPublisherAPI {
name = "public-app", name = "public-app",
value = "The public app that need to be created.", value = "The public app that need to be created.",
required = true) required = true)
PublicAppWrapper publicAppWrapper PublicAppWrapper publicAppWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished
); );
@POST @POST
@ -436,7 +451,12 @@ public interface ApplicationManagementPublisherAPI {
name = "application", name = "application",
value = "The application that need to be created.", value = "The application that need to be created.",
required = true) required = true)
CustomAppWrapper customAppWrapper CustomAppWrapper customAppWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished
); );
@POST @POST
@ -486,7 +506,12 @@ public interface ApplicationManagementPublisherAPI {
name = "applicationRelease", name = "applicationRelease",
value = "The application release that need to be created.", value = "The application release that need to be created.",
required = true) required = true)
EntAppReleaseWrapper entAppReleaseWrapper EntAppReleaseWrapper entAppReleaseWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished
); );
@POST @POST
@ -536,7 +561,12 @@ public interface ApplicationManagementPublisherAPI {
name = "applicationRelease", name = "applicationRelease",
value = "The application release that need to be created.", value = "The application release that need to be created.",
required = true) required = true)
PublicAppReleaseWrapper publicAppReleaseWrapper PublicAppReleaseWrapper publicAppReleaseWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished
); );
@POST @POST
@ -581,7 +611,12 @@ public interface ApplicationManagementPublisherAPI {
name = "applicationRelease", name = "applicationRelease",
value = "The application release that need to be created.", value = "The application release that need to be created.",
required = true) required = true)
WebAppReleaseWrapper webAppReleaseWrapper WebAppReleaseWrapper webAppReleaseWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished
); );
@POST @POST
@ -631,7 +666,12 @@ public interface ApplicationManagementPublisherAPI {
name = "applicationRelease", name = "applicationRelease",
value = "The application release that need to be created.", value = "The application release that need to be created.",
required = true) required = true)
CustomAppReleaseWrapper customAppReleaseWrapper CustomAppReleaseWrapper customAppReleaseWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished
); );
@PUT @PUT

@ -24,6 +24,7 @@ import io.entgra.application.mgt.common.wrapper.PublicAppWrapper;
import io.entgra.application.mgt.common.wrapper.WebAppWrapper; import io.entgra.application.mgt.common.wrapper.WebAppWrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty; import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info; import io.swagger.annotations.Info;
@ -311,7 +312,12 @@ public interface SPApplicationService {
} }
) )
Response createEntApp(@PathParam("identity-server-id") int identityServerId, Response createEntApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app); @PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished);
/** /**
* This method is used to register an APIM application for tenant domain. * This method is used to register an APIM application for tenant domain.
@ -332,7 +338,12 @@ public interface SPApplicationService {
} }
) )
Response createPubApp(@PathParam("identity-server-id") int identityServerId, Response createPubApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app); @PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished);
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app") @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app")
@POST @POST
@ -350,7 +361,12 @@ public interface SPApplicationService {
} }
) )
Response createWebApp(@PathParam("identity-server-id") int identityServerId, Response createWebApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app); @PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished);
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app") @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app")
@POST @POST
@ -368,5 +384,10 @@ public interface SPApplicationService {
} }
) )
Response createCustomApp(@PathParam("identity-server-id") int identityServerId, Response createCustomApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app); @PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("isPublished") boolean isPublished);
} }

@ -169,9 +169,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/ent-app") @Path("/ent-app")
public Response createEntApp( public Response createEntApp(
ApplicationWrapper applicationWrapper) { ApplicationWrapper applicationWrapper, @QueryParam("is-published") boolean isPublished) {
try { try {
return createApplication(applicationWrapper); return createApplication(applicationWrapper, isPublished);
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Found incompatible payload with ent. app creating request."; String msg = "Found incompatible payload with ent. app creating request.";
log.error(msg, e); log.error(msg, e);
@ -191,9 +191,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/web-app") @Path("/web-app")
public Response createWebApp( public Response createWebApp(
WebAppWrapper webAppWrapper) { WebAppWrapper webAppWrapper, @QueryParam("is-published") boolean isPublished) {
try { try {
return createApplication(webAppWrapper); return createApplication(webAppWrapper, isPublished);
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Found incompatible payload with web app creating request."; String msg = "Found incompatible payload with web app creating request.";
log.error(msg, e); log.error(msg, e);
@ -213,9 +213,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/public-app") @Path("/public-app")
public Response createPubApp( public Response createPubApp(
PublicAppWrapper publicAppWrapper) { PublicAppWrapper publicAppWrapper, @QueryParam("is-published") boolean isPublished) {
try { try {
return createApplication(publicAppWrapper); return createApplication(publicAppWrapper, isPublished);
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Found incompatible payload with pub app creating request."; String msg = "Found incompatible payload with pub app creating request.";
log.error(msg, e); log.error(msg, e);
@ -235,9 +235,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/custom-app") @Path("/custom-app")
public Response createCustomApp( public Response createCustomApp(
CustomAppWrapper customAppWrapper) { CustomAppWrapper customAppWrapper, @QueryParam("is-published") boolean isPublished) {
try { try {
return createApplication(customAppWrapper); return createApplication(customAppWrapper, isPublished);
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Found incompatible payload with custom app creating request."; String msg = "Found incompatible payload with custom app creating request.";
log.error(msg, e); log.error(msg, e);
@ -259,11 +259,12 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
public Response createEntAppRelease( public Response createEntAppRelease(
@PathParam("deviceType") String deviceTypeName, @PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId, @PathParam("appId") int appId,
EntAppReleaseWrapper entAppReleaseWrapper) { EntAppReleaseWrapper entAppReleaseWrapper,
@QueryParam("isPublished") boolean isPublished) {
try { try {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
applicationManager.validateEntAppReleaseCreatingRequest(entAppReleaseWrapper, deviceTypeName); applicationManager.validateEntAppReleaseCreatingRequest(entAppReleaseWrapper, deviceTypeName);
ApplicationRelease release = applicationManager.createEntAppRelease(appId, entAppReleaseWrapper); ApplicationRelease release = applicationManager.createEntAppRelease(appId, entAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(release).build(); return Response.status(Response.Status.CREATED).entity(release).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Error occurred while validating binaryArtifact"; String msg = "Error occurred while validating binaryArtifact";
@ -283,12 +284,12 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
public Response createPubAppRelease( public Response createPubAppRelease(
@PathParam("deviceType") String deviceTypeName, @PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId, @PathParam("appId") int appId,
PublicAppReleaseWrapper publicAppReleaseWrapper) { PublicAppReleaseWrapper publicAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) {
try { try {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
applicationManager.validatePublicAppReleaseCreatingRequest(publicAppReleaseWrapper, deviceTypeName); applicationManager.validatePublicAppReleaseCreatingRequest(publicAppReleaseWrapper, deviceTypeName);
ApplicationRelease applicationRelease = applicationManager.createPubAppRelease(appId, publicAppReleaseWrapper); ApplicationRelease applicationRelease = applicationManager.createPubAppRelease(appId, publicAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build(); return Response.status(Response.Status.CREATED).entity(applicationRelease).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating application release for the application with the id " + appId; String msg = "Error occurred while creating application release for the application with the id " + appId;
@ -311,11 +312,11 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Override @Override
public Response createWebAppRelease( public Response createWebAppRelease(
@PathParam("appId") int appId, @PathParam("appId") int appId,
WebAppReleaseWrapper webAppReleaseWrapper) { WebAppReleaseWrapper webAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) {
try { try {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
applicationManager.validateWebAppReleaseCreatingRequest(webAppReleaseWrapper); applicationManager.validateWebAppReleaseCreatingRequest(webAppReleaseWrapper);
ApplicationRelease applicationRelease= applicationManager.createWebAppRelease(appId, webAppReleaseWrapper); ApplicationRelease applicationRelease= applicationManager.createWebAppRelease(appId, webAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build(); return Response.status(Response.Status.CREATED).entity(applicationRelease).build();
} catch (ResourceManagementException e) { } catch (ResourceManagementException e) {
String msg = "Error occurred while uploading application release artifacts"; String msg = "Error occurred while uploading application release artifacts";
@ -339,11 +340,11 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
public Response createCustomAppRelease( public Response createCustomAppRelease(
@PathParam("deviceType") String deviceTypeName, @PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId, @PathParam("appId") int appId,
CustomAppReleaseWrapper customAppReleaseWrapper) { CustomAppReleaseWrapper customAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) {
try { try {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
applicationManager.validateCustomAppReleaseCreatingRequest(customAppReleaseWrapper, deviceTypeName); applicationManager.validateCustomAppReleaseCreatingRequest(customAppReleaseWrapper, deviceTypeName);
ApplicationRelease release = applicationManager.createCustomAppRelease(appId, customAppReleaseWrapper); ApplicationRelease release = applicationManager.createCustomAppRelease(appId, customAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(release).build(); return Response.status(Response.Status.CREATED).entity(release).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Error occurred while validating binaryArtifact"; String msg = "Error occurred while validating binaryArtifact";
@ -864,10 +865,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
} }
} }
public <T> Response createApplication(T appWrapper) throws ApplicationManagementException, RequestValidatingException { public <T> Response createApplication(T appWrapper, boolean isPublished) throws ApplicationManagementException, RequestValidatingException {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
applicationManager.validateAppCreatingRequest(appWrapper); applicationManager.validateAppCreatingRequest(appWrapper);
Application application = applicationManager.createApplication(appWrapper); Application application = applicationManager.createApplication(appWrapper, isPublished);
if (application != null) { if (application != null) {
return Response.status(Response.Status.CREATED).entity(application).build(); return Response.status(Response.Status.CREATED).entity(application).build();
} else { } else {

@ -294,32 +294,36 @@ public class SPApplicationServiceImpl implements SPApplicationService {
@POST @POST
@Override @Override
public Response createEntApp(@PathParam("identity-server-id") int identityServerId, public Response createEntApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app) { @PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app,
return createSPApplication(identityServerId, serviceProviderId, app); @QueryParam("isPublished") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
} }
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/public-app") @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/public-app")
@POST @POST
@Override @Override
public Response createPubApp(@PathParam("identity-server-id") int identityServerId, public Response createPubApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app) { @PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app,
return createSPApplication(identityServerId, serviceProviderId, app); @QueryParam("isPublished") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
} }
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app") @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app")
@POST @POST
@Override @Override
public Response createWebApp(@PathParam("identity-server-id") int identityServerId, public Response createWebApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app) { @PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app,
return createSPApplication(identityServerId, serviceProviderId, app); @QueryParam("isPublished") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
} }
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app") @Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app")
@POST @POST
@Override @Override
public Response createCustomApp(@PathParam("identity-server-id") int identityServerId, public Response createCustomApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app) { @PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app,
return createSPApplication(identityServerId, serviceProviderId, app); @QueryParam("isPublished") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
} }
/** /**
@ -331,10 +335,10 @@ public class SPApplicationServiceImpl implements SPApplicationService {
* @param <T> application wrapper class * @param <T> application wrapper class
* @return Response * @return Response
*/ */
private <T> Response createSPApplication(int identityServerId, String spUID, T appWrapper) { private <T> Response createSPApplication(int identityServerId, String spUID, T appWrapper, boolean isPublished) {
try { try {
SPApplicationManager spApplicationManager = APIUtil.getSPApplicationManager(); SPApplicationManager spApplicationManager = APIUtil.getSPApplicationManager();
Application createdApp = spApplicationManager.createSPApplication(appWrapper, identityServerId, spUID); Application createdApp = spApplicationManager.createSPApplication(appWrapper, identityServerId, spUID, isPublished);
return Response.status(Response.Status.CREATED).entity(createdApp).build(); return Response.status(Response.Status.CREATED).entity(createdApp).build();
} catch (NotFoundException e) { } catch (NotFoundException e) {
String msg = "No identity server exist with the id " + identityServerId; String msg = "No identity server exist with the id " + identityServerId;

Loading…
Cancel
Save