Resolve merge conflict

feature/traccar-sync
Mohamed Rashd 3 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 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
* @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;
/**
@ -61,10 +62,11 @@ public interface ApplicationManager {
*
* @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 isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Created application release bean
* @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;
/**
@ -72,10 +74,11 @@ public interface ApplicationManager {
*
* @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 isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Created application release bean
* @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;
/**
@ -83,10 +86,11 @@ public interface ApplicationManager {
*
* @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 isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Created application release bean
* @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;
/**
@ -113,21 +117,23 @@ public interface ApplicationManager {
* required to do the validation of request and check the existence of application releaseDTO.
*
* @param applicationDTO Application DTO object.
* @param isPublished Wether the app should be added in PUBLISHED state instead of initial state
* @return {@link Application}
* @throws ApplicationManagementException which throws if error occurs while during application management.
*/
Application addAppDataIntoDB(ApplicationDTO applicationDTO) throws
Application addAppDataIntoDB(ApplicationDTO applicationDTO, boolean isPublished) throws
ApplicationManagementException;
/**
* This method is responsible for handling application creation
*
* @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
* @return Created application bean
* @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
* @param appId id of the application
@ -249,10 +255,11 @@ public interface ApplicationManager {
* @param applicationDTO ApplicationDTO of the release
* @param applicationReleaseDTO ApplicatonRelease that need to be be created.
* @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
*/
<T> ApplicationRelease createRelease(ApplicationDTO applicationDTO, ApplicationReleaseDTO applicationReleaseDTO,
ApplicationType type)
ApplicationType type, boolean isPublished)
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 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 isPublished If the app should be added in PUBLISHED state instead of initial state
* @return Application bean of the created application
* @throws ApplicationManagementException if errors while creating and mapping the application
* @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

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

@ -650,7 +650,7 @@ public class SPApplicationManagerImpl implements SPApplicationManager {
}
@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);
ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance();
ApplicationDTO applicationDTO = applicationManager.uploadReleaseArtifactIfExist(app);
@ -660,7 +660,7 @@ public class SPApplicationManagerImpl implements SPApplicationManager {
}
try {
ConnectionManagerUtil.beginDBTransaction();
Application createdApp = applicationManager.addAppDataIntoDB(applicationDTO);
Application createdApp = applicationManager.addAppDataIntoDB(applicationDTO, isPublished);
attachCreatedSPApplication(createdApp, identityServerId, spId);
ConnectionManagerUtil.commitDBTransaction();
return createdApp;

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

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

@ -24,6 +24,7 @@ import io.entgra.application.mgt.common.wrapper.PublicAppWrapper;
import io.entgra.application.mgt.common.wrapper.WebAppWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
@ -311,7 +312,12 @@ public interface SPApplicationService {
}
)
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.
@ -332,7 +338,12 @@ public interface SPApplicationService {
}
)
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")
@POST
@ -350,7 +361,12 @@ public interface SPApplicationService {
}
)
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")
@POST
@ -368,5 +384,10 @@ public interface SPApplicationService {
}
)
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)
@Path("/ent-app")
public Response createEntApp(
ApplicationWrapper applicationWrapper) {
ApplicationWrapper applicationWrapper, @QueryParam("is-published") boolean isPublished) {
try {
return createApplication(applicationWrapper);
return createApplication(applicationWrapper, isPublished);
} catch (BadRequestException e) {
String msg = "Found incompatible payload with ent. app creating request.";
log.error(msg, e);
@ -191,9 +191,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Consumes(MediaType.APPLICATION_JSON)
@Path("/web-app")
public Response createWebApp(
WebAppWrapper webAppWrapper) {
WebAppWrapper webAppWrapper, @QueryParam("is-published") boolean isPublished) {
try {
return createApplication(webAppWrapper);
return createApplication(webAppWrapper, isPublished);
} catch (BadRequestException e) {
String msg = "Found incompatible payload with web app creating request.";
log.error(msg, e);
@ -213,9 +213,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Consumes(MediaType.APPLICATION_JSON)
@Path("/public-app")
public Response createPubApp(
PublicAppWrapper publicAppWrapper) {
PublicAppWrapper publicAppWrapper, @QueryParam("is-published") boolean isPublished) {
try {
return createApplication(publicAppWrapper);
return createApplication(publicAppWrapper, isPublished);
} catch (BadRequestException e) {
String msg = "Found incompatible payload with pub app creating request.";
log.error(msg, e);
@ -235,9 +235,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Consumes(MediaType.APPLICATION_JSON)
@Path("/custom-app")
public Response createCustomApp(
CustomAppWrapper customAppWrapper) {
CustomAppWrapper customAppWrapper, @QueryParam("is-published") boolean isPublished) {
try {
return createApplication(customAppWrapper);
return createApplication(customAppWrapper, isPublished);
} catch (BadRequestException e) {
String msg = "Found incompatible payload with custom app creating request.";
log.error(msg, e);
@ -259,11 +259,12 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
public Response createEntAppRelease(
@PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId,
EntAppReleaseWrapper entAppReleaseWrapper) {
EntAppReleaseWrapper entAppReleaseWrapper,
@QueryParam("isPublished") boolean isPublished) {
try {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
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();
} catch (RequestValidatingException e) {
String msg = "Error occurred while validating binaryArtifact";
@ -283,12 +284,12 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
public Response createPubAppRelease(
@PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId,
PublicAppReleaseWrapper publicAppReleaseWrapper) {
PublicAppReleaseWrapper publicAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) {
try {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
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();
} catch (ApplicationManagementException e) {
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
public Response createWebAppRelease(
@PathParam("appId") int appId,
WebAppReleaseWrapper webAppReleaseWrapper) {
WebAppReleaseWrapper webAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) {
try {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
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();
} catch (ResourceManagementException e) {
String msg = "Error occurred while uploading application release artifacts";
@ -339,11 +340,11 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
public Response createCustomAppRelease(
@PathParam("deviceType") String deviceTypeName,
@PathParam("appId") int appId,
CustomAppReleaseWrapper customAppReleaseWrapper) {
CustomAppReleaseWrapper customAppReleaseWrapper, @QueryParam("isPublished") boolean isPublished) {
try {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
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();
} catch (RequestValidatingException e) {
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.validateAppCreatingRequest(appWrapper);
Application application = applicationManager.createApplication(appWrapper);
Application application = applicationManager.createApplication(appWrapper, isPublished);
if (application != null) {
return Response.status(Response.Status.CREATED).entity(application).build();
} else {

@ -294,32 +294,36 @@ public class SPApplicationServiceImpl implements SPApplicationService {
@POST
@Override
public Response createEntApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app) {
return createSPApplication(identityServerId, serviceProviderId, app);
@PathParam("service-provider-id") String serviceProviderId, ApplicationWrapper app,
@QueryParam("isPublished") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
}
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/public-app")
@POST
@Override
public Response createPubApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app) {
return createSPApplication(identityServerId, serviceProviderId, app);
@PathParam("service-provider-id") String serviceProviderId, PublicAppWrapper app,
@QueryParam("isPublished") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
}
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/web-app")
@POST
@Override
public Response createWebApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app) {
return createSPApplication(identityServerId, serviceProviderId, app);
@PathParam("service-provider-id") String serviceProviderId, WebAppWrapper app,
@QueryParam("isPublished") boolean isPublished) {
return createSPApplication(identityServerId, serviceProviderId, app, isPublished);
}
@Path("/{identity-server-id}/service-provider/{service-provider-id}/create/custom-app")
@POST
@Override
public Response createCustomApp(@PathParam("identity-server-id") int identityServerId,
@PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper app) {
return createSPApplication(identityServerId, serviceProviderId, app);
@PathParam("service-provider-id") String serviceProviderId, CustomAppWrapper 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
* @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 {
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();
} catch (NotFoundException e) {
String msg = "No identity server exist with the id " + identityServerId;

Loading…
Cancel
Save