parent
5a253b286e
commit
d7abfbc19b
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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.policy.mgt.core;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.policy.mgt.common.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PolicyManager {
|
||||
|
||||
Feature addFeature(Feature feature) throws FeatureManagementException;
|
||||
|
||||
Feature updateFeature(Feature feature) throws FeatureManagementException;
|
||||
|
||||
Profile addProfile(Profile profile) throws PolicyManagementException;
|
||||
|
||||
Profile updateProfile(Profile profile) throws PolicyManagementException;
|
||||
|
||||
Policy addPolicy(Policy policy) throws PolicyManagementException;
|
||||
|
||||
Policy updatePolicy(Policy policy) throws PolicyManagementException;
|
||||
|
||||
Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException;
|
||||
|
||||
Policy getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws FeatureManagementException;
|
||||
|
||||
List<Policy> getPolicies(String deviceType) throws PolicyManagementException;
|
||||
|
||||
List<Feature> getFeatures() throws FeatureManagementException;
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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.policy.mgt.core;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
import org.wso2.carbon.policy.mgt.common.Profile;
|
||||
import org.wso2.carbon.policy.mgt.core.impl.PolicyAdministratorPointImpl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PolicyManagerImpl implements PolicyManager {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PolicyManagerImpl.class);
|
||||
|
||||
PolicyAdministratorPointImpl policyAdministratorPoint;
|
||||
|
||||
public PolicyManagerImpl() {
|
||||
policyAdministratorPoint = new PolicyAdministratorPointImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature addFeature(Feature feature) throws FeatureManagementException {
|
||||
return policyAdministratorPoint.addFeature(feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature updateFeature(Feature feature) throws FeatureManagementException {
|
||||
return policyAdministratorPoint.updateFeature(feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile addProfile(Profile profile) throws PolicyManagementException {
|
||||
return policyAdministratorPoint.addProfile(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile updateProfile(Profile profile) throws PolicyManagementException {
|
||||
return policyAdministratorPoint.updateProfile(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
||||
return policyAdministratorPoint.addPolicy(policy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy updatePolicy(Policy policy) throws PolicyManagementException {
|
||||
return policyAdministratorPoint.updatePolicy(policy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws FeatureManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Policy> getPolicies(String deviceType) throws PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Feature> getFeatures() throws FeatureManagementException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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.policy.mgt.core.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
import org.wso2.carbon.policy.mgt.common.Profile;
|
||||
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagerDAOException;
|
||||
import org.wso2.carbon.policy.mgt.core.dao.impl.PolicyDAOImpl;
|
||||
|
||||
public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PolicyAdministratorPointImpl.class);
|
||||
PolicyDAOImpl policyDAO;
|
||||
|
||||
public PolicyAdministratorPointImpl() {
|
||||
policyDAO = new PolicyDAOImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
||||
try {
|
||||
policy = policyDAO.addPolicy(policy);
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
String msg = "Error occurred while persisting the policy.";
|
||||
log.error(msg, e);
|
||||
throw new PolicyManagementException(msg, e);
|
||||
}
|
||||
return policy;
|
||||
}
|
||||
|
||||
public Policy updatePolicy(Policy policy) throws PolicyManagementException {
|
||||
try {
|
||||
policy = policyDAO.updatePolicy(policy);
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
String msg = "Error occurred while updating the policy.";
|
||||
log.error(msg, e);
|
||||
throw new PolicyManagementException(msg, e);
|
||||
}
|
||||
return policy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy addPolicyToDevice(String deviceId, String deviceType, Policy policy)
|
||||
throws FeatureManagementException, PolicyManagementException {
|
||||
|
||||
try {
|
||||
policy = policyDAO.addPolicy(deviceId, deviceType, policy);
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
String msg = "Error occurred while persisting the policy.";
|
||||
log.error(msg, e);
|
||||
throw new PolicyManagementException(msg, e);
|
||||
}
|
||||
return policy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy addPolicyToRole(String roleName, Policy policy)
|
||||
throws FeatureManagementException, PolicyManagementException {
|
||||
try {
|
||||
policy = policyDAO.addPolicyToRole(roleName, policy);
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
String msg = "Error occurred while persisting the policy.";
|
||||
log.error(msg, e);
|
||||
throw new PolicyManagementException(msg, e);
|
||||
}
|
||||
return policy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getPolicy() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getPolicyOfDevice(String deviceId, String deviceType)
|
||||
throws FeatureManagementException, PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getPolicyOfDeviceType(String deviceType)
|
||||
throws FeatureManagementException, PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getPolicyOfRole(String roleName) throws FeatureManagementException, PolicyManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPolicyAvailableForDevice(String deviceId, String deviceType) throws PolicyManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPolicyApplied(String deviceId, String deviceType) throws PolicyManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPolicyUsed(String deviceId, String deviceType, Policy policy) throws PolicyManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile addProfile(Profile profile) throws PolicyManagementException {
|
||||
try {
|
||||
profile = policyDAO.addProfile(profile);
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
String msg = "Error occurred while persisting the policy.";
|
||||
log.error(msg, e);
|
||||
throw new PolicyManagementException(msg, e);
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteProfile(int profileId) throws PolicyManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile updateProfile(Profile profile) throws PolicyManagementException {
|
||||
try {
|
||||
profile = policyDAO.updateProfile(profile);
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
String msg = "Error occurred while persisting the profile.";
|
||||
log.error(msg, e);
|
||||
throw new PolicyManagementException(msg, e);
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature addFeature(Feature feature) throws FeatureManagementException {
|
||||
try {
|
||||
feature = policyDAO.addFeature(feature);
|
||||
} catch (FeatureManagementException e) {
|
||||
String msg = "Error occurred while persisting the feature.";
|
||||
log.error(msg, e);
|
||||
throw new FeatureManagementException(msg, e);
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
String msg = "Error occurred while persisting the feature.";
|
||||
log.error(msg, e);
|
||||
throw new FeatureManagementException(msg, e);
|
||||
}
|
||||
|
||||
return feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature updateFeature(Feature feature) throws FeatureManagementException {
|
||||
try {
|
||||
feature = policyDAO.updateFeature(feature);
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
String msg = "Error occurred while persisting the feature.";
|
||||
log.error(msg, e);
|
||||
throw new FeatureManagementException(msg, e);
|
||||
} catch (FeatureManagementException e) {
|
||||
String msg = "Error occurred while persisting the feature.";
|
||||
log.error(msg, e);
|
||||
throw new FeatureManagementException(msg, e);
|
||||
}
|
||||
return feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFeature(int featureId) throws FeatureManagementException {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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.policy.mgt.core.service;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.policy.mgt.common.*;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManager;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerImpl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PolicyManagementService implements PolicyManager {
|
||||
|
||||
|
||||
PolicyManager policyManager;
|
||||
|
||||
public PolicyManagementService() {
|
||||
policyManager = new PolicyManagerImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature addFeature(Feature feature) throws FeatureManagementException {
|
||||
return policyManager.addFeature(feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature updateFeature(Feature feature) throws FeatureManagementException {
|
||||
return policyManager.updateFeature(feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile addProfile(Profile profile) throws PolicyManagementException {
|
||||
return policyManager.addProfile(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile updateProfile(Profile profile) throws PolicyManagementException {
|
||||
return policyManager.updateProfile(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
||||
return policyManager.addPolicy(policy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy updatePolicy(Policy policy) throws PolicyManagementException {
|
||||
return policyManager.updatePolicy(policy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
|
||||
return policyManager.getEffectivePolicy(deviceIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Policy getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws FeatureManagementException {
|
||||
return policyManager.getEffectiveFeatures(deviceIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Policy> getPolicies(String deviceType) throws PolicyManagementException {
|
||||
return policyManager.getPolicies(deviceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Feature> getFeatures() throws FeatureManagementException {
|
||||
return policyManager.getFeatures();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue