4.x.x
Chatura Dilan 8 years ago
parent f09905a2ec
commit 5d8b8ab697

@ -20,7 +20,7 @@ package org.wso2.carbon.device.application.mgt.api.services;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse; import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse;
import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;

@ -21,7 +21,7 @@ package org.wso2.carbon.device.application.mgt.api.services.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager; import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager;
import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList;
import org.wso2.carbon.device.application.mgt.core.dto.Filter; import org.wso2.carbon.device.application.mgt.core.dto.Filter;
import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil; import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil;

@ -19,12 +19,10 @@
package org.wso2.carbon.device.application.mgt.core.components; package org.wso2.carbon.device.application.mgt.core.components;
import org.wso2.carbon.device.application.mgt.core.dto.Application; import org.wso2.carbon.device.application.mgt.core.dto.Application;
import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList;
import org.wso2.carbon.device.application.mgt.core.dto.Filter; import org.wso2.carbon.device.application.mgt.core.dto.Filter;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException;
import java.util.List;
public interface ApplicationManager { public interface ApplicationManager {
public void createApplication(Application application) throws ApplicationManagerException; public void createApplication(Application application) throws ApplicationManagerException;

@ -21,16 +21,14 @@ package org.wso2.carbon.device.application.mgt.core.components.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager; import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAO;
import org.wso2.carbon.device.application.mgt.core.dto.Application; import org.wso2.carbon.device.application.mgt.core.dto.Application;
import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList;
import org.wso2.carbon.device.application.mgt.core.dto.Filter; import org.wso2.carbon.device.application.mgt.core.dto.Filter;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException;
import org.wso2.carbon.device.application.mgt.core.internal.ApplicationManagementDataHolder; import org.wso2.carbon.device.application.mgt.core.internal.ApplicationManagementDataHolder;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import java.util.List;
public class ApplicationManagerImpl implements ApplicationManager { public class ApplicationManagerImpl implements ApplicationManager {
private static final Log log = LogFactory.getLog(ApplicationManagerImpl.class); private static final Log log = LogFactory.getLog(ApplicationManagerImpl.class);

@ -1,65 +0,0 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
import org.wso2.carbon.device.application.mgt.core.dto.Application;
import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList;
import org.wso2.carbon.device.application.mgt.core.dto.Filter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public interface ApplicationManagementDAO {
public enum DatabaseType {
H2("H2"),
MYSQL("MySQL"),
ORACLE("Oracle"),
POSTGRESQL("PostgreSQL"),
MSSQL("Microsoft SQL Server");
private final String value;
private static final Map<String, DatabaseType> lookup = new HashMap<String, DatabaseType>();
static {
for (DatabaseType databaseType : DatabaseType.values()) {
lookup.put(databaseType.getValue(), databaseType);
}
}
DatabaseType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public static DatabaseType lookup(String value) {
return lookup.get(value);
}
}
public void createApplication(Application application) throws ApplicationManagementDAOException;
public ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException;
}

@ -0,0 +1,23 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
public interface ApplicationReleasesDAO {
}

@ -0,0 +1,36 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.dto.Application;
import org.wso2.carbon.device.application.mgt.core.dto.Filter;
import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList;
public interface ApplicationsDAO {
Application createApplication(Application application) throws ApplicationManagementDAOException;
ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException;
Application editApplication(Application application) throws ApplicationManagementDAOException;
void deleteApplication (Application application)throws ApplicationManagementDAOException;
}

@ -0,0 +1,22 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
public interface CategoriesDAO {
}

@ -0,0 +1,22 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
public interface CommentsDAO {
}

@ -0,0 +1,23 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
public interface LifecycleStatesDAO {
}

@ -0,0 +1,23 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
public interface PlatformsDAO {
}

@ -0,0 +1,22 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
public interface ResourceTypesDAO {
}

@ -0,0 +1,22 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
public interface SubscriptionsDAO {
}

@ -0,0 +1,22 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao;
public interface VisibilitiesDAO {
}

@ -0,0 +1,28 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao.common;
import org.apache.abdera.model.Categories;
import org.wso2.carbon.device.application.mgt.core.dao.*;
import org.wso2.carbon.device.application.mgt.core.dto.LifecycleState;
public interface ApplicationManagementDAO extends ApplicationReleasesDAO, ApplicationsDAO, CategoriesDAO, CommentsDAO,
LifecycleStatesDAO, PlatformsDAO, ResourceTypesDAO, SubscriptionsDAO, VisibilitiesDAO {
}

@ -16,7 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.device.application.mgt.core.dao; package org.wso2.carbon.device.application.mgt.core.dao.common;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException;

@ -16,23 +16,22 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.device.application.mgt.core.dao; package org.wso2.carbon.device.application.mgt.core.dao.common;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.application.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.device.application.mgt.core.dao.impl.GenericAppManagementDAO; import org.wso2.carbon.device.application.mgt.core.dao.impl.GenericAppManagementDAO;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil.DatabaseType;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
public class ApplicationManagementDAOFactory { public class ApplicationManagementDAOFactory {
public static final String H2 = "H2"; public static final String H2 = "H2";
private ApplicationManagementDAO.DatabaseType databaseType; private DatabaseType databaseType;
private static DataSource dataSource; private static DataSource dataSource;
private static final Log log = LogFactory.getLog(ApplicationManagementDAOFactory.class); private static final Log log = LogFactory.getLog(ApplicationManagementDAOFactory.class);
@ -46,7 +45,7 @@ public class ApplicationManagementDAOFactory {
} catch (SQLException e) { } catch (SQLException e) {
log.error("Error occurred while retrieving config.datasource connection", e); log.error("Error occurred while retrieving config.datasource connection", e);
} }
this.databaseType = ApplicationManagementDAO.DatabaseType.lookup(databaseEngine); this.databaseType = DatabaseType.lookup(databaseEngine);
} }
public ApplicationManagementDAO getApplicationManagementDAO(){ public ApplicationManagementDAO getApplicationManagementDAO(){

@ -16,7 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.device.application.mgt.core.dao; package org.wso2.carbon.device.application.mgt.core.dao.common;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -38,7 +38,8 @@ public class ApplicationManagementDAOUtil {
private static final Log log = LogFactory.getLog(ApplicationManagementDAOUtil.class); private static final Log log = LogFactory.getLog(ApplicationManagementDAOUtil.class);
public static Application loadApplication(ResultSet rs , ResultSet rsProperties) throws SQLException, JSONException { public static Application loadApplication(ResultSet rs, ResultSet rsProperties, ResultSet rsTags)
throws SQLException, JSONException {
Application application = new Application(); Application application = new Application();
application.setId(rs.getInt("ID")); application.setId(rs.getInt("ID"));
@ -52,17 +53,23 @@ public class ApplicationManagementDAOUtil {
application.setCreatedAt(rs.getDate("CREATED_AT")); application.setCreatedAt(rs.getDate("CREATED_AT"));
application.setModifiedAt(rs.getDate("MODIFIED_AT")); application.setModifiedAt(rs.getDate("MODIFIED_AT"));
Platform applicationType = new Platform(); Platform platform = new Platform();
applicationType.setName(rs.getString("APL_NAME")); platform.setName(rs.getString("APL_NAME"));
applicationType.setCode(rs.getString("APL_CODE")); platform.setCode(rs.getString("APL_CODE"));
application.setApplicationType(applicationType); application.setPlatform(platform);
Map<String, String> properties = new HashMap<>(); Map<String, String> properties = new HashMap<>();
while (rsProperties.next()){ while (rsProperties.next()) {
properties.put(rsProperties.getString("PROP_KEY"), rsProperties.getString("PROP_VAL")); properties.put(rsProperties.getString("PROP_KEY"), rsProperties.getString("PROP_VAL"));
} }
application.setProperties(properties); application.setProperties(properties);
List<String> tags = new ArrayList<>();
while ((rsTags.next())){
tags.add(rsTags.getString("NAME"));
}
application.setTags(tags);
Category category = new Category(); Category category = new Category();
category.setName(rs.getString("CAT_NAME")); category.setName(rs.getString("CAT_NAME"));
application.setCategory(category); application.setCategory(category);

@ -18,12 +18,14 @@
*/ */
package org.wso2.carbon.device.application.mgt.core.dao.impl; package org.wso2.carbon.device.application.mgt.core.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException; import org.json.JSONException;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAO;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAOUtil; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOUtil;
import org.wso2.carbon.device.application.mgt.core.dto.Application; import org.wso2.carbon.device.application.mgt.core.dto.Application;
import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList;
import org.wso2.carbon.device.application.mgt.core.dto.Filter; import org.wso2.carbon.device.application.mgt.core.dto.Filter;
import org.wso2.carbon.device.application.mgt.core.dto.Pagination; import org.wso2.carbon.device.application.mgt.core.dto.Pagination;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
@ -37,14 +39,21 @@ import java.util.List;
public class GenericAppManagementDAO implements ApplicationManagementDAO { public class GenericAppManagementDAO implements ApplicationManagementDAO {
@Override private static final Log log = LogFactory.getLog(ApplicationManagementDAO.class);
public void createApplication(Application application) throws ApplicationManagementDAOException {
@Override
public Application createApplication(Application application) throws ApplicationManagementDAOException {
return null;
} }
@Override @Override
public ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException { public ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException {
if(log.isDebugEnabled()){
log.debug("Getting application data from the database");
log.debug(String.format("Filter: limit=%s, offset=%", filter.getLimit(), filter.getOffset()));
}
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
@ -101,7 +110,13 @@ public class GenericAppManagementDAO implements ApplicationManagementDAO {
stmt.setInt(1, rs.getInt("ID")); stmt.setInt(1, rs.getInt("ID"));
ResultSet rsProperties = stmt.executeQuery(); ResultSet rsProperties = stmt.executeQuery();
applications.add(ApplicationManagementDAOUtil.loadApplication(rs, rsProperties)); //Getting tags
sql = "SELECT * FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID=?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, rs.getInt("ID"));
ResultSet rsTags = stmt.executeQuery();
applications.add(ApplicationManagementDAOUtil.loadApplication(rs, rsProperties, rsTags));
length++; length++;
} }
@ -120,4 +135,14 @@ public class GenericAppManagementDAO implements ApplicationManagementDAO {
return applicationList; return applicationList;
} }
@Override
public Application editApplication(Application application) throws ApplicationManagementDAOException {
return null;
}
@Override
public void deleteApplication(Application application) throws ApplicationManagementDAOException {
}
} }

@ -30,9 +30,11 @@ public class Application {
@Exclude @Exclude
private int id; private int id;
private String uuid;
private String name; private String name;
private String uuid; private String shortDescription;
private String description; private String description;
@ -46,9 +48,7 @@ public class Application {
private List<String> tags; private List<String> tags;
private Date createdAt; private List<Subscription> subscriptions;
private Date modifiedAt;
private Platform platform; private Platform platform;
@ -56,8 +56,14 @@ public class Application {
private Map<String, String> properties; private Map<String, String> properties;
public Application() { private String createdBy;
}
private Date createdAt;
private Date modifiedAt;
private boolean published;
public int getId() { public int getId() {
return id; return id;
@ -67,6 +73,14 @@ public class Application {
this.id = id; this.id = id;
} }
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -75,12 +89,12 @@ public class Application {
this.name = name; this.name = name;
} }
public String getUuid() { public String getShortDescription() {
return uuid; return shortDescription;
} }
public void setUuid(String uuid) { public void setShortDescription(String shortDescription) {
this.uuid = uuid; this.shortDescription = shortDescription;
} }
public String getDescription() { public String getDescription() {
@ -131,20 +145,12 @@ public class Application {
this.tags = tags; this.tags = tags;
} }
public Date getCreatedAt() { public List<Subscription> getSubscriptions() {
return createdAt; return subscriptions;
} }
public void setCreatedAt(Date createdAt) { public void setSubscriptions(List<Subscription> subscriptions) {
this.createdAt = createdAt; this.subscriptions = subscriptions;
}
public Date getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(Date modifiedAt) {
this.modifiedAt = modifiedAt;
} }
public Platform getPlatform() { public Platform getPlatform() {
@ -170,4 +176,36 @@ public class Application {
public void setProperties(Map<String, String> properties) { public void setProperties(Map<String, String> properties) {
this.properties = properties; this.properties = properties;
} }
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(Date modifiedAt) {
this.modifiedAt = modifiedAt;
}
public boolean isPublished() {
return published;
}
public void setPublished(boolean published) {
this.published = published;
}
} }

@ -0,0 +1,149 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dto;
import java.util.Date;
import java.util.Map;
public class ApplicationRelease {
private enum ReleaseChannel {
PRODUCTION, ALPHA, BETA
}
private int id;
private int versionId;
private String versionName;
private String resource;
private ReleaseChannel releaseChannel;
private String releaseDetails;
private Date createdAt;
private Application application;
private LifecycleState lifecycleState;
private Date lifecycleStateModifiedAt;
private String lifecycleStateModifiedBy;
private Map<String, String> properties;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getVersionId() {
return versionId;
}
public void setVersionId(int versionId) {
this.versionId = versionId;
}
public String getVersionName() {
return versionName;
}
public void setVersionName(String versionName) {
this.versionName = versionName;
}
public String getResource() {
return resource;
}
public void setResource(String resource) {
this.resource = resource;
}
public ReleaseChannel getReleaseChannel() {
return releaseChannel;
}
public void setReleaseChannel(ReleaseChannel releaseChannel) {
this.releaseChannel = releaseChannel;
}
public String getReleaseDetails() {
return releaseDetails;
}
public void setReleaseDetails(String releaseDetails) {
this.releaseDetails = releaseDetails;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Application getApplication() {
return application;
}
public void setApplication(Application application) {
this.application = application;
}
public LifecycleState getLifecycleState() {
return lifecycleState;
}
public void setLifecycleState(LifecycleState lifecycleState) {
this.lifecycleState = lifecycleState;
}
public Date getLifecycleStateModifiedAt() {
return lifecycleStateModifiedAt;
}
public void setLifecycleStateModifiedAt(Date lifecycleStateModifiedAt) {
this.lifecycleStateModifiedAt = lifecycleStateModifiedAt;
}
public String getLifecycleStateModifiedBy() {
return lifecycleStateModifiedBy;
}
public void setLifecycleStateModifiedBy(String lifecycleStateModifiedBy) {
this.lifecycleStateModifiedBy = lifecycleStateModifiedBy;
}
public Map<String, String> getProperties() {
return properties;
}
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
}

@ -0,0 +1,102 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dto;
public class Comment {
private String id;
private String comment;
private int rating;
private Comment parent;
private String createdBy;
private String createdAt;
private String modifiedAt;
private Application application;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public int getRating() {
return rating;
}
public void setRating(int rating) {
this.rating = rating;
}
public Comment getParent() {
return parent;
}
public void setParent(Comment parent) {
this.parent = parent;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public String getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(String modifiedAt) {
this.modifiedAt = modifiedAt;
}
public Application getApplication() {
return application;
}
public void setApplication(Application application) {
this.application = application;
}
}

@ -22,6 +22,10 @@ import java.util.Map;
public class Filter { public class Filter {
public enum SortingOrder {
ASC, DESC
}
private int limit; private int limit;
private int offset; private int offset;
@ -32,6 +36,10 @@ public class Filter {
private String searchQuery; private String searchQuery;
private SortingOrder sortingOrder;
private String sortBy;
public int getLimit() { public int getLimit() {
return limit; return limit;
} }
@ -72,10 +80,28 @@ public class Filter {
this.searchQuery = searchQuery; this.searchQuery = searchQuery;
} }
public SortingOrder getSortingOrder() {
return sortingOrder;
}
public void setSortingOrder(SortingOrder sortingOrder) {
this.sortingOrder = sortingOrder;
}
public String getSortBy() {
return sortBy;
}
public void setSortBy(String sortBy) {
this.sortBy = sortBy;
}
public boolean hasCondition() { public boolean hasCondition() {
if (filterProperties != null || searchQuery != null || filter != null) { if (filterProperties != null || searchQuery != null || filter != null) {
return true; return true;
} }
return false; return false;
} }
} }

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dto;
public class LifecycleState {
private String id;
private String name;
private String description;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

@ -35,6 +35,8 @@ public class Platform {
private String iconName; private String iconName;
private List<String> tags;
private String properties; private String properties;
private List<Application> applications; private List<Application> applications;
@ -87,6 +89,14 @@ public class Platform {
this.properties = properties; this.properties = properties;
} }
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
public List<Application> getApplications() { public List<Application> getApplications() {
return applications; return applications;
} }

@ -0,0 +1,52 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dto;
public class ResourceType {
private String id;
private String name;
private String description;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

@ -0,0 +1,74 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dto;
import java.util.Date;
public class Subscription {
private ResourceType type;
private String value;
private Date createdAt;
private Application application;
private ApplicationRelease applicationRelease;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public ResourceType getType() {
return type;
}
public void setType(ResourceType type) {
this.type = type;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Application getApplication() {
return application;
}
public void setApplication(Application application) {
this.application = application;
}
public ApplicationRelease getApplicationRelease() {
return applicationRelease;
}
public void setApplicationRelease(ApplicationRelease applicationRelease) {
this.applicationRelease = applicationRelease;
}
}

@ -0,0 +1,64 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dto;
import java.util.Date;
public class Visibility {
private ResourceType type;
private String value;
private Application application;
private ApplicationRelease applicationRelease;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public ResourceType getType() {
return type;
}
public void setType(ResourceType type) {
this.type = type;
}
public Application getApplication() {
return application;
}
public void setApplication(Application application) {
this.application = application;
}
public ApplicationRelease getApplicationRelease() {
return applicationRelease;
}
public void setApplicationRelease(ApplicationRelease applicationRelease) {
this.applicationRelease = applicationRelease;
}
}

@ -16,7 +16,10 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.device.application.mgt.core.dto; package org.wso2.carbon.device.application.mgt.core.dto.lists;
import org.wso2.carbon.device.application.mgt.core.dto.Application;
import org.wso2.carbon.device.application.mgt.core.dto.Pagination;
import java.util.List; import java.util.List;

@ -18,7 +18,7 @@
*/ */
package org.wso2.carbon.device.application.mgt.core.internal; package org.wso2.carbon.device.application.mgt.core.internal;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAO;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
public class ApplicationManagementDataHolder { public class ApplicationManagementDataHolder {

@ -26,8 +26,8 @@ import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager
import org.wso2.carbon.device.application.mgt.core.components.impl.ApplicationManagerImpl; import org.wso2.carbon.device.application.mgt.core.components.impl.ApplicationManagerImpl;
import org.wso2.carbon.device.application.mgt.core.config.ApplicationConfigurationManager; import org.wso2.carbon.device.application.mgt.core.config.ApplicationConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.application.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAO;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAOFactory; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import javax.naming.NamingException; import javax.naming.NamingException;

@ -29,8 +29,10 @@ import javax.naming.InitialContext;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Map;
public class ConnectionManagerUtil { public class ConnectionManagerUtil {
@ -40,6 +42,36 @@ public class ConnectionManagerUtil {
CONNECTION_NOT_BORROWED, CONNECTION_BORROWED, CONNECTION_CLOSED CONNECTION_NOT_BORROWED, CONNECTION_BORROWED, CONNECTION_CLOSED
} }
public enum DatabaseType {
H2("H2"),
MYSQL("MySQL"),
ORACLE("Oracle"),
POSTGRESQL("PostgreSQL"),
MSSQL("Microsoft SQL Server");
private final String value;
private static final Map<String, DatabaseType> lookup = new HashMap<String, DatabaseType>();
static {
for (DatabaseType databaseType : DatabaseType.values()) {
lookup.put(databaseType.getValue(), databaseType);
}
}
DatabaseType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public static DatabaseType lookup(String value) {
return lookup.get(value);
}
}
private static final ThreadLocal<Connection> currentConnection = new ThreadLocal<>(); private static final ThreadLocal<Connection> currentConnection = new ThreadLocal<>();
private static ThreadLocal<TxState> currentTxState = new ThreadLocal<>(); private static ThreadLocal<TxState> currentTxState = new ThreadLocal<>();
private static DataSource dataSource; private static DataSource dataSource;

Loading…
Cancel
Save