Add javadoc comments and improve logic

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent 26568273e5
commit 4316cb0ef4

@ -30,58 +30,97 @@ public class ApplicationRelease {
@Exclude @Exclude
private int id; private int id;
/**
* Version of the application release
*/
private String version; private String version;
/**
* UUID of the application release
*/
private String uuid; private String uuid;
/**
* Application storing location
*/
private String appStoredLoc; private String appStoredLoc;
/**
* Banner file storing location
*/
private String bannerLoc; private String bannerLoc;
/**
* Screenshot storing location
*/
private String screenshotLoc1; private String screenshotLoc1;
/**
* Screenshot storing location
*/
private String screenshotLoc2; private String screenshotLoc2;
/**
* Screenshot storing location
*/
private String screenshotLoc3; private String screenshotLoc3;
/**
* Application release creator
*/
private String applicationCreator; private String applicationCreator;
/**
* Release type of the application release
* e.g: alpha, beta etc
*/
private String releaseType; private String releaseType;
/**
* Price of the application release
*/
private Double price; private Double price;
private Timestamp createdAt; /**
* icon file storing location
private String publishedBy; */
private Timestamp publishedAt;
private String modifiedBy;
private Timestamp modifiedAt;
private String iconLoc; private String iconLoc;
private String currentState; /**
* Hash value of the application release
private String previousState; */
private String stateModifiedBy;
private Timestamp stateModifiedAt;
private String appHashValue; private String appHashValue;
/**
* If application release is shared with all tenants it is eqal to 1 otherwise 0
*/
private int isSharedWithAllTenants; private int isSharedWithAllTenants;
/**
* MEta data of the application release
*/
private String metaData; private String metaData;
/**
* Number of users who has rated the application release
*/
private int ratedUsers; private int ratedUsers;
/**
* Rating value of the application release
*/
private Double rating; private Double rating;
/**
* URL which is used for WEB-CLIP
*/
private String url; private String url;
/**
* Latest Lifecycle state of the application release
*/
private LifecycleState lifecycleState;
public int getRatedUsers() { public int getRatedUsers() {
return ratedUsers; return ratedUsers;
} }
@ -150,37 +189,6 @@ public class ApplicationRelease {
this.price = price; this.price = price;
} }
public String getCurrentState() {
return currentState;
}
public void setCurrentState(String currentState) {
this.currentState = currentState;
}
public String getPreviousState() {
return previousState;
}
public void setPreviousState(String previousState) {
this.previousState = previousState;
}
public String getStateModifiedBy() {
return stateModifiedBy;
}
public void setStateModifiedBy(String stateModifiedBy) {
this.stateModifiedBy = stateModifiedBy;
}
public Timestamp getStateModifiedAt() {
return stateModifiedAt;
}
public void setStateModifiedAt(Timestamp stateModifiedAt) {
this.stateModifiedAt = stateModifiedAt;
}
public String getAppHashValue() { public String getAppHashValue() {
return appHashValue; return appHashValue;
@ -242,46 +250,6 @@ public class ApplicationRelease {
this.applicationCreator = applicationCreator; this.applicationCreator = applicationCreator;
} }
public Timestamp getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Timestamp createdAt) {
this.createdAt = createdAt;
}
public String getPublishedBy() {
return publishedBy;
}
public void setPublishedBy(String publishedBy) {
this.publishedBy = publishedBy;
}
public Timestamp getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Timestamp publishedAt) {
this.publishedAt = publishedAt;
}
public String getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Timestamp getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(Timestamp modifiedAt) {
this.modifiedAt = modifiedAt;
}
public String getIconLoc() { public String getIconLoc() {
return iconLoc; return iconLoc;
} }
@ -298,4 +266,11 @@ public class ApplicationRelease {
this.url = url; this.url = url;
} }
public LifecycleState getLifecycleState() {
return lifecycleState;
}
public void setLifecycleState(LifecycleState lifecycleState) {
this.lifecycleState = lifecycleState;
}
} }

@ -168,9 +168,6 @@ public class Util {
appRelease.setAppStoredLoc(rs.getString("STORED_LOCATION")); appRelease.setAppStoredLoc(rs.getString("STORED_LOCATION"));
appRelease.setBannerLoc(rs.getString("BANNER_LOCATION")); appRelease.setBannerLoc(rs.getString("BANNER_LOCATION"));
appRelease.setApplicationCreator(rs.getString("CREATED_BY")); appRelease.setApplicationCreator(rs.getString("CREATED_BY"));
appRelease.setCreatedAt(rs.getTimestamp("CREATED_AT"));
appRelease.setPublishedBy(rs.getString("PUBLISHED_BY"));
appRelease.setPublishedAt(rs.getTimestamp("PUBLISHED_AT"));
appRelease.setRating(rs.getDouble("RATING")); appRelease.setRating(rs.getDouble("RATING"));
appRelease.setIsSharedWithAllTenants(rs.getInt("SHARED_WITH_ALL_TENANTS")); appRelease.setIsSharedWithAllTenants(rs.getInt("SHARED_WITH_ALL_TENANTS"));
appRelease.setMetaData(rs.getString("APP_META_INFO")); appRelease.setMetaData(rs.getString("APP_META_INFO"));

@ -247,9 +247,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED")); applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO")); applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY")); applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
applicationRelease.setCreatedAt(resultSet.getTimestamp("CREATED_AT"));
applicationRelease.setPublishedBy(resultSet.getString("PUBLISHED_BY"));
applicationRelease.setPublishedAt(resultSet.getTimestamp("PUBLISHED_AT"));
applicationRelease.setRating(resultSet.getDouble("RATING")); applicationRelease.setRating(resultSet.getDouble("RATING"));
applicationReleases.add(applicationRelease); applicationReleases.add(applicationRelease);
@ -392,14 +389,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED")); applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO")); applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY")); applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
applicationRelease.setCreatedAt(resultSet.getTimestamp("CREATED_AT"));
applicationRelease.setPublishedBy(resultSet.getString("PUBLISHED_BY"));
applicationRelease.setPublishedAt(resultSet.getTimestamp("PUBLISHED_AT"));
applicationRelease.setRating(resultSet.getDouble("RATING")); applicationRelease.setRating(resultSet.getDouble("RATING"));
applicationRelease.setCurrentState(resultSet.getString("CURRENT_STATE"));
applicationRelease.setPreviousState(resultSet.getString("PREVIOUS_STATE"));
applicationRelease.setStateModifiedBy(resultSet.getString("UPDATED_BY"));
applicationRelease.setStateModifiedAt(resultSet.getTimestamp("UPDATED_AT"));
return applicationRelease; return applicationRelease;
} }

@ -97,6 +97,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
validateReleaseCreatingRequest(application.getApplicationReleases().get(0)); validateReleaseCreatingRequest(application.getApplicationReleases().get(0));
DeviceType deviceType; DeviceType deviceType;
ApplicationRelease applicationRelease; ApplicationRelease applicationRelease;
List<ApplicationRelease> applicationReleases = new ArrayList<>();
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
deviceType = this.deviceTypeDAO.getDeviceType(application.getDeviceType(), tenantId); deviceType = this.deviceTypeDAO.getDeviceType(application.getDeviceType(), tenantId);
@ -121,9 +122,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
} else { } else {
application.setIsRestricted(0); application.setIsRestricted(0);
} }
if (application.getApplicationReleases().size() > 1 ){
throw new ApplicationManagementException(
"Invalid payload. Application creating payload should contains one application release, but "
+ "the payload contains more than one");
}
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
applicationRelease = application.getApplicationReleases().get(0); applicationRelease = application.getApplicationReleases().get(0);
applicationRelease.setCreatedAt((Timestamp) new Date());
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO(). applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
createRelease(applicationRelease, application.getId(), tenantId); createRelease(applicationRelease, application.getId(), tenantId);
LifecycleState lifecycleState = new LifecycleState(); LifecycleState lifecycleState = new LifecycleState();
@ -134,6 +139,9 @@ public class ApplicationManagerImpl implements ApplicationManager {
lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString()); lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString());
lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString()); lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString());
addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState); addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState);
applicationRelease.setLifecycleState(lifecycleState);
applicationReleases.add(applicationRelease);
application.setApplicationReleases(applicationReleases);
} }
return application; return application;
@ -200,9 +208,9 @@ public class ApplicationManagerImpl implements ApplicationManager {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Application release request is received for the application " + application.toString()); log.debug("Application release request is received for the application " + application.toString());
} }
applicationRelease.setCreatedAt((Timestamp) new Date());
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
// todo consider about lifecycle adding
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO(). applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
createRelease(applicationRelease, application.getId(), tenantId); createRelease(applicationRelease, application.getId(), tenantId);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
@ -353,10 +361,10 @@ public class ApplicationManagerImpl implements ApplicationManager {
for (ApplicationRelease applicationRelease : applicationReleases) { for (ApplicationRelease applicationRelease : applicationReleases) {
LifecycleState lifecycleState = ApplicationManagementDAOFactory.getLifecycleStateDAO(). LifecycleState lifecycleState = ApplicationManagementDAOFactory.getLifecycleStateDAO().
getLatestLifeCycleStateByReleaseID(applicationRelease.getId()); getLatestLifeCycleStateByReleaseID(applicationRelease.getId());
applicationRelease.setCurrentState(lifecycleState.getCurrentState()); applicationRelease.setLifecycleState(lifecycleState);
applicationRelease.setPreviousState(lifecycleState.getPreviousState());
if (!AppLifecycleState.REMOVED.toString().equals(applicationRelease.getCurrentState())) { if (!AppLifecycleState.REMOVED.toString()
.equals(applicationRelease.getLifecycleState().getCurrentState())) {
filteredApplicationReleases.add(applicationRelease); filteredApplicationReleases.add(applicationRelease);
} }
} }
@ -613,7 +621,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
applicationRelease.setModifiedBy(userName); // todo consider about lifecycle
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO() applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO()
.updateRelease(appId, applicationRelease, tenantId); .updateRelease(appId, applicationRelease, tenantId);

@ -328,8 +328,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
if (!applicationManager.isApplicationReleaseUpdateAcceptable(application.getId(), if (!applicationManager.isApplicationReleaseUpdateAcceptable(application.getId(),
applicationRelease.getUuid())) { applicationRelease.getUuid())) {
String msg = "Application release is in the " + applicationRelease.getCurrentState() + " state. Hence" + String msg = "Application release is in the " + applicationRelease.getLifecycleState().getCurrentState()
" updating is not acceptable when application in this state"; + " state. Hence updating is not acceptable when application in this state";
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }

@ -70,7 +70,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
for (Application application : applications.getApplications()) { for (Application application : applications.getApplications()) {
for (ApplicationRelease appRelease: application.getApplicationReleases()){ for (ApplicationRelease appRelease: application.getApplicationReleases()){
if (AppLifecycleState.PUBLISHED.toString().equals(appRelease.getCurrentState())){ if (AppLifecycleState.PUBLISHED.toString()
.equals(appRelease.getLifecycleState().getCurrentState())) {
publishedApplicationRelease.add(appRelease); publishedApplicationRelease.add(appRelease);
} }
} }
@ -110,7 +111,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
} }
for (ApplicationRelease appRelease : application.getApplicationReleases()) { for (ApplicationRelease appRelease : application.getApplicationReleases()) {
if (AppLifecycleState.PUBLISHED.toString().equals(appRelease.getCurrentState())){ if (AppLifecycleState.PUBLISHED.toString().equals(appRelease.getLifecycleState().getCurrentState())){
publishedApplicationRelease.add(appRelease); publishedApplicationRelease.add(appRelease);
} }
} }

Loading…
Cancel
Save