|
|
@ -31,8 +31,8 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorage
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.PlatformStorageManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.PlatformStorageManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Holds util methods required for Application-Mgt API component.
|
|
|
|
* Holds util methods required for Application-Mgt API component.
|
|
|
@ -41,68 +41,37 @@ public class APIUtil {
|
|
|
|
|
|
|
|
|
|
|
|
private static Log log = LogFactory.getLog(APIUtil.class);
|
|
|
|
private static Log log = LogFactory.getLog(APIUtil.class);
|
|
|
|
|
|
|
|
|
|
|
|
private static ApplicationManager applicationManager;
|
|
|
|
|
|
|
|
private static PlatformManager platformManager;
|
|
|
|
|
|
|
|
private static LifecycleStateManager lifecycleStateManager;
|
|
|
|
|
|
|
|
private static ApplicationReleaseManager applicationReleaseManager;
|
|
|
|
|
|
|
|
private static ApplicationStorageManager applicationStorageManager;
|
|
|
|
|
|
|
|
private static SubscriptionManager subscriptionManager;
|
|
|
|
|
|
|
|
private static PlatformStorageManager platformStorageManager;
|
|
|
|
|
|
|
|
private static CategoryManager categoryManager;
|
|
|
|
|
|
|
|
private static CommentsManager commentsManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static ApplicationManager getApplicationManager() {
|
|
|
|
public static ApplicationManager getApplicationManager() {
|
|
|
|
if (applicationManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (applicationManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
applicationManager =
|
|
|
|
ApplicationManager applicationManager = (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null);
|
|
|
|
(ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null);
|
|
|
|
|
|
|
|
if (applicationManager == null) {
|
|
|
|
if (applicationManager == null) {
|
|
|
|
String msg = "Application Manager service has not initialized.";
|
|
|
|
String msg = "Application Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return applicationManager;
|
|
|
|
return applicationManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static PlatformManager getPlatformManager() {
|
|
|
|
public static PlatformManager getPlatformManager() {
|
|
|
|
if (platformManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (platformManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
platformManager =
|
|
|
|
PlatformManager platformManager = (PlatformManager) ctx.getOSGiService(PlatformManager.class, null);
|
|
|
|
(PlatformManager) ctx.getOSGiService(PlatformManager.class, null);
|
|
|
|
|
|
|
|
if (platformManager == null) {
|
|
|
|
if (platformManager == null) {
|
|
|
|
String msg = "Platform Manager service has not initialized.";
|
|
|
|
String msg = "Platform Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return platformManager;
|
|
|
|
return platformManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static LifecycleStateManager getLifecycleStateManager() {
|
|
|
|
public static LifecycleStateManager getLifecycleStateManager() {
|
|
|
|
if (lifecycleStateManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (lifecycleStateManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
lifecycleStateManager =
|
|
|
|
LifecycleStateManager lifecycleStateManager = (LifecycleStateManager) ctx
|
|
|
|
(LifecycleStateManager) ctx.getOSGiService(LifecycleStateManager.class, null);
|
|
|
|
.getOSGiService(LifecycleStateManager.class, null);
|
|
|
|
if (lifecycleStateManager == null) {
|
|
|
|
if (lifecycleStateManager == null) {
|
|
|
|
String msg = "Lifecycle Manager service has not initialized.";
|
|
|
|
String msg = "Lifecycle Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return lifecycleStateManager;
|
|
|
|
return lifecycleStateManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -112,42 +81,31 @@ public class APIUtil {
|
|
|
|
* @return ApplicationRelease Manager instance in the current osgi context.
|
|
|
|
* @return ApplicationRelease Manager instance in the current osgi context.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static ApplicationReleaseManager getApplicationReleaseManager() {
|
|
|
|
public static ApplicationReleaseManager getApplicationReleaseManager() {
|
|
|
|
if (applicationReleaseManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (applicationReleaseManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
applicationReleaseManager = (ApplicationReleaseManager) ctx
|
|
|
|
ApplicationReleaseManager applicationReleaseManager = (ApplicationReleaseManager) ctx
|
|
|
|
.getOSGiService(ApplicationReleaseManager.class, null);
|
|
|
|
.getOSGiService(ApplicationReleaseManager.class, null);
|
|
|
|
if (applicationReleaseManager == null) {
|
|
|
|
if (applicationReleaseManager == null) {
|
|
|
|
String msg = "Application Release Manager service has not initialized.";
|
|
|
|
String msg = "Application Release Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return applicationReleaseManager;
|
|
|
|
return applicationReleaseManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To get the Application Storage Manager from the osgi context.
|
|
|
|
* To get the Application Storage Manager from the osgi context.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @return ApplicationStoreManager instance in the current osgi context.
|
|
|
|
* @return ApplicationStoreManager instance in the current osgi context.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static ApplicationStorageManager getApplicationStorageManager() {
|
|
|
|
public static ApplicationStorageManager getApplicationStorageManager() {
|
|
|
|
if (applicationStorageManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (applicationStorageManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
applicationStorageManager = (ApplicationStorageManager) ctx
|
|
|
|
ApplicationStorageManager applicationStorageManager = (ApplicationStorageManager) ctx
|
|
|
|
.getOSGiService(ApplicationStorageManager.class, null);
|
|
|
|
.getOSGiService(ApplicationStorageManager.class, null);
|
|
|
|
if (applicationStorageManager == null) {
|
|
|
|
if (applicationStorageManager == null) {
|
|
|
|
String msg = "Application Storage Manager service has not initialized.";
|
|
|
|
String msg = "Application Storage Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return applicationStorageManager;
|
|
|
|
return applicationStorageManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -157,43 +115,30 @@ public class APIUtil {
|
|
|
|
* @return PlatformStoreManager instance in the current osgi context.
|
|
|
|
* @return PlatformStoreManager instance in the current osgi context.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static PlatformStorageManager getPlatformStorageManager() {
|
|
|
|
public static PlatformStorageManager getPlatformStorageManager() {
|
|
|
|
if (platformStorageManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (platformStorageManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
platformStorageManager = (PlatformStorageManager) ctx
|
|
|
|
PlatformStorageManager platformStorageManager = (PlatformStorageManager) ctx
|
|
|
|
.getOSGiService(PlatformStorageManager.class, null);
|
|
|
|
.getOSGiService(PlatformStorageManager.class, null);
|
|
|
|
if (platformStorageManager == null) {
|
|
|
|
if (platformStorageManager == null) {
|
|
|
|
String msg = "Platform Storage Manager service has not initialized.";
|
|
|
|
String msg = "Platform Storage Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return platformStorageManager;
|
|
|
|
return platformStorageManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To get the Category Manager from the osgi context.
|
|
|
|
* To get the Category Manager from the osgi context.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return CategoryManager instance in the current osgi context.
|
|
|
|
* @return CategoryManager instance in the current osgi context.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static CategoryManager getCategoryManager() {
|
|
|
|
public static CategoryManager getCategoryManager() {
|
|
|
|
if (categoryManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (categoryManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
categoryManager = (CategoryManager) ctx.getOSGiService(CategoryManager.class, null);
|
|
|
|
CategoryManager categoryManager = (CategoryManager) ctx.getOSGiService(CategoryManager.class, null);
|
|
|
|
if (categoryManager == null) {
|
|
|
|
if (categoryManager == null) {
|
|
|
|
String msg = "Category Manager service has not initialized.";
|
|
|
|
String msg = "Category Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return categoryManager;
|
|
|
|
return categoryManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -213,41 +158,35 @@ public class APIUtil {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To get the Subscription Manager from the osgi context.
|
|
|
|
* To get the Subscription Manager from the osgi context.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @return SubscriptionManager instance in the current osgi context.
|
|
|
|
* @return SubscriptionManager instance in the current osgi context.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static SubscriptionManager getSubscriptionManager() {
|
|
|
|
public static SubscriptionManager getSubscriptionManager() {
|
|
|
|
if (subscriptionManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (subscriptionManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
subscriptionManager =
|
|
|
|
SubscriptionManager subscriptionManager = (SubscriptionManager) ctx
|
|
|
|
(SubscriptionManager) ctx.getOSGiService(SubscriptionManager.class, null);
|
|
|
|
.getOSGiService(SubscriptionManager.class, null);
|
|
|
|
if (subscriptionManager == null) {
|
|
|
|
if (subscriptionManager == null) {
|
|
|
|
String msg = "Subscription Manager service has not initialized.";
|
|
|
|
String msg = "Subscription Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return subscriptionManager;
|
|
|
|
return subscriptionManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* To get the Comment Manager from the osgi context.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return CommentsManager instance in the current osgi context.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
public static CommentsManager getCommentsManager() {
|
|
|
|
public static CommentsManager getCommentsManager() {
|
|
|
|
if (commentsManager == null) {
|
|
|
|
|
|
|
|
synchronized (APIUtil.class) {
|
|
|
|
|
|
|
|
if (commentsManager == null) {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
commentsManager = (CommentsManager) ctx.getOSGiService(CommentsManager.class, null);
|
|
|
|
CommentsManager commentsManager = (CommentsManager) ctx.getOSGiService(CommentsManager.class, null);
|
|
|
|
if (commentsManager == null) {
|
|
|
|
if (commentsManager == null) {
|
|
|
|
String msg = "Comments Manager service has not initialized.";
|
|
|
|
String msg = "Comments Manager service has not initialized.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return commentsManager;
|
|
|
|
return commentsManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|