* Added xml annotations to Policy and Profile

* Added methods to Policy Administrator Point
revert-70aa11f8
Dulitha Wijewantha 10 years ago
parent a4485af0c9
commit 89a12a5660

@ -56,7 +56,8 @@
<Import-Package> <Import-Package>
org.apache.commons.logging, org.apache.commons.logging,
org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.device.mgt.core.dto.* org.wso2.carbon.device.mgt.core.dto.*,
javax.xml.bind.*,
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
org.wso2.carbon.policy.mgt.common.* org.wso2.carbon.policy.mgt.common.*

@ -21,6 +21,8 @@ package org.wso2.carbon.policy.mgt.common;
import org.wso2.carbon.device.mgt.core.dto.Device; import org.wso2.carbon.device.mgt.core.dto.Device;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Date; import java.sql.Date;
import java.util.List; import java.util.List;
@ -29,6 +31,7 @@ import java.util.Map;
/** /**
* This class will be the used to create policy object with relevant information for evaluating. * This class will be the used to create policy object with relevant information for evaluating.
*/ */
@XmlRootElement
public class Policy implements Comparable<Policy>, Serializable { public class Policy implements Comparable<Policy>, Serializable {
private int id; // Identifier of the policy. private int id; // Identifier of the policy.
@ -63,6 +66,7 @@ public class Policy implements Comparable<Policy>, Serializable {
private Map<String, Object> attributes; private Map<String, Object> attributes;
@XmlElement
public int getId() { public int getId() {
return id; return id;
} }
@ -71,6 +75,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.id = id; this.id = id;
} }
@XmlElement
public int getPriorityId() { public int getPriorityId() {
return priorityId; return priorityId;
} }
@ -79,6 +84,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.priorityId = priorityId; this.priorityId = priorityId;
} }
@XmlElement
public Profile getProfile() { public Profile getProfile() {
return profile; return profile;
} }
@ -87,6 +93,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.profile = profile; this.profile = profile;
} }
@XmlElement
public int getProfileId() { public int getProfileId() {
return profileId; return profileId;
} }
@ -95,6 +102,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.profileId = profileId; this.profileId = profileId;
} }
@XmlElement
public String getPolicyName() { public String getPolicyName() {
return policyName; return policyName;
} }
@ -103,6 +111,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.policyName = policyName; this.policyName = policyName;
} }
@XmlElement
public boolean isGeneric() { public boolean isGeneric() {
return generic; return generic;
} }
@ -111,6 +120,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.generic = generic; this.generic = generic;
} }
@XmlElement
public List<String> getRoleList() { public List<String> getRoleList() {
return roleList; return roleList;
} }
@ -119,6 +129,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.roleList = roleList; this.roleList = roleList;
} }
@XmlElement
public String getOwnershipType() { public String getOwnershipType() {
return ownershipType; return ownershipType;
} }
@ -127,6 +138,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.ownershipType = ownershipType; this.ownershipType = ownershipType;
} }
@XmlElement
public List<Device> getDeviceList() { public List<Device> getDeviceList() {
return DeviceList; return DeviceList;
} }
@ -135,6 +147,7 @@ public class Policy implements Comparable<Policy>, Serializable {
DeviceList = deviceList; DeviceList = deviceList;
} }
@XmlElement
public List<String> getUsers() { public List<String> getUsers() {
return users; return users;
} }
@ -143,6 +156,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.users = users; this.users = users;
} }
@XmlElement
public int getStartTime() { public int getStartTime() {
return startTime; return startTime;
} }
@ -151,6 +165,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.startTime = startTime; this.startTime = startTime;
} }
@XmlElement
public int getEndTime() { public int getEndTime() {
return endTime; return endTime;
} }
@ -159,6 +174,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.endTime = endTime; this.endTime = endTime;
} }
@XmlElement
public Date getStartDate() { public Date getStartDate() {
return startDate; return startDate;
} }
@ -167,6 +183,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.startDate = startDate; this.startDate = startDate;
} }
@XmlElement
public Date getEndDate() { public Date getEndDate() {
return endDate; return endDate;
} }
@ -175,6 +192,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.endDate = endDate; this.endDate = endDate;
} }
@XmlElement
public String getLatitude() { public String getLatitude() {
return latitude; return latitude;
} }
@ -183,6 +201,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.latitude = latitude; this.latitude = latitude;
} }
@XmlElement
public String getLongitude() { public String getLongitude() {
return longitude; return longitude;
} }
@ -191,6 +210,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.longitude = longitude; this.longitude = longitude;
} }
@XmlElement
public Map<String, Object> getAttributes() { public Map<String, Object> getAttributes() {
return attributes; return attributes;
} }
@ -199,6 +219,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.attributes = attributes; this.attributes = attributes;
} }
@XmlElement
public int getTenantId() { public int getTenantId() {
return tenantId; return tenantId;
} }

@ -131,6 +131,10 @@ public interface PolicyAdministratorPoint {
Profile updateProfile(Profile profile) throws PolicyManagementException; Profile updateProfile(Profile profile) throws PolicyManagementException;
Profile getProfile(int profileId) throws PolicyManagementException;
List<Profile> getProfiles() throws PolicyManagementException;
Feature addFeature(Feature feature) throws FeatureManagementException; Feature addFeature(Feature feature) throws FeatureManagementException;
Feature updateFeature(Feature feature) throws FeatureManagementException; Feature updateFeature(Feature feature) throws FeatureManagementException;

@ -22,9 +22,11 @@ package org.wso2.carbon.policy.mgt.common;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
@XmlRootElement
public class Profile { public class Profile {
private int profileId; private int profileId;
@ -43,7 +45,7 @@ public class Profile {
public void setDeviceType(DeviceType deviceType) { public void setDeviceType(DeviceType deviceType) {
this.deviceType = deviceType; this.deviceType = deviceType;
} }
@XmlElement
public int getTenantId() { public int getTenantId() {
return tenantId; return tenantId;
} }
@ -59,7 +61,7 @@ public class Profile {
public void setFeaturesList(List<Feature> featuresList) { public void setFeaturesList(List<Feature> featuresList) {
this.featuresList = featuresList; this.featuresList = featuresList;
}*/ }*/
@XmlElement
public int getProfileId() { public int getProfileId() {
return profileId; return profileId;
} }
@ -68,6 +70,7 @@ public class Profile {
this.profileId = profileId; this.profileId = profileId;
} }
@XmlElement
public String getProfileName() { public String getProfileName() {
return profileName; return profileName;
} }
@ -76,6 +79,7 @@ public class Profile {
this.profileName = profileName; this.profileName = profileName;
} }
@XmlElement
public Timestamp getCreatedDate() { public Timestamp getCreatedDate() {
return createdDate; return createdDate;
} }
@ -84,6 +88,7 @@ public class Profile {
this.createdDate = createdDate; this.createdDate = createdDate;
} }
@XmlElement
public Timestamp getUpdatedDate() { public Timestamp getUpdatedDate() {
return updatedDate; return updatedDate;
} }
@ -92,6 +97,7 @@ public class Profile {
this.updatedDate = updatedDate; this.updatedDate = updatedDate;
} }
@XmlElement
public List<ProfileFeature> getProfileFeaturesList() { public List<ProfileFeature> getProfileFeaturesList() {
return profileFeaturesList; return profileFeaturesList;
} }

@ -145,6 +145,28 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
} }
} }
@Override
public Profile getProfile(int profileId) throws PolicyManagementException {
try {
return profileManager.getProfile(profileId);
} catch (ProfileManagementException e) {
String msg = "Error occurred while retriving profile";
log.error(msg, e);
throw new PolicyManagementException(msg, e);
}
}
@Override
public List<Profile> getProfiles() throws PolicyManagementException {
try {
return profileManager.getAllProfiles();
} catch (ProfileManagementException e) {
String msg = "Error occurred while obtaining list of profiles.";
log.error(msg, e);
throw new PolicyManagementException(msg, e);
}
}
@Override @Override
public Feature addFeature(Feature feature) throws FeatureManagementException { public Feature addFeature(Feature feature) throws FeatureManagementException {
try { try {

@ -32,7 +32,7 @@ public interface ProfileManager {
boolean deleteProfile(Profile profile) throws ProfileManagementException; boolean deleteProfile(Profile profile) throws ProfileManagementException;
Profile getProfiles(int profileId) throws ProfileManagementException; Profile getProfile(int profileId) throws ProfileManagementException;
List<Profile> getAllProfiles() throws ProfileManagementException; List<Profile> getAllProfiles() throws ProfileManagementException;

@ -178,7 +178,7 @@ public class ProfileManagerImpl implements ProfileManager {
} }
@Override @Override
public Profile getProfiles(int profileId) throws ProfileManagementException { public Profile getProfile(int profileId) throws ProfileManagementException {
Profile profile; Profile profile;
List<ProfileFeature> featureList; List<ProfileFeature> featureList;
DeviceType deviceType; DeviceType deviceType;

Loading…
Cancel
Save