* 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>
org.apache.commons.logging,
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>
<Export-Package>
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 javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.sql.Date;
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.
*/
@XmlRootElement
public class Policy implements Comparable<Policy>, Serializable {
private int id; // Identifier of the policy.
@ -63,6 +66,7 @@ public class Policy implements Comparable<Policy>, Serializable {
private Map<String, Object> attributes;
@XmlElement
public int getId() {
return id;
}
@ -71,6 +75,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.id = id;
}
@XmlElement
public int getPriorityId() {
return priorityId;
}
@ -79,6 +84,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.priorityId = priorityId;
}
@XmlElement
public Profile getProfile() {
return profile;
}
@ -87,6 +93,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.profile = profile;
}
@XmlElement
public int getProfileId() {
return profileId;
}
@ -95,6 +102,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.profileId = profileId;
}
@XmlElement
public String getPolicyName() {
return policyName;
}
@ -103,6 +111,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.policyName = policyName;
}
@XmlElement
public boolean isGeneric() {
return generic;
}
@ -111,6 +120,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.generic = generic;
}
@XmlElement
public List<String> getRoleList() {
return roleList;
}
@ -119,6 +129,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.roleList = roleList;
}
@XmlElement
public String getOwnershipType() {
return ownershipType;
}
@ -127,6 +138,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.ownershipType = ownershipType;
}
@XmlElement
public List<Device> getDeviceList() {
return DeviceList;
}
@ -135,6 +147,7 @@ public class Policy implements Comparable<Policy>, Serializable {
DeviceList = deviceList;
}
@XmlElement
public List<String> getUsers() {
return users;
}
@ -143,6 +156,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.users = users;
}
@XmlElement
public int getStartTime() {
return startTime;
}
@ -151,6 +165,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.startTime = startTime;
}
@XmlElement
public int getEndTime() {
return endTime;
}
@ -159,6 +174,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.endTime = endTime;
}
@XmlElement
public Date getStartDate() {
return startDate;
}
@ -167,6 +183,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.startDate = startDate;
}
@XmlElement
public Date getEndDate() {
return endDate;
}
@ -175,6 +192,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.endDate = endDate;
}
@XmlElement
public String getLatitude() {
return latitude;
}
@ -183,6 +201,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.latitude = latitude;
}
@XmlElement
public String getLongitude() {
return longitude;
}
@ -191,6 +210,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.longitude = longitude;
}
@XmlElement
public Map<String, Object> getAttributes() {
return attributes;
}
@ -199,6 +219,7 @@ public class Policy implements Comparable<Policy>, Serializable {
this.attributes = attributes;
}
@XmlElement
public int getTenantId() {
return tenantId;
}

@ -131,6 +131,10 @@ public interface PolicyAdministratorPoint {
Profile updateProfile(Profile profile) throws PolicyManagementException;
Profile getProfile(int profileId) throws PolicyManagementException;
List<Profile> getProfiles() throws PolicyManagementException;
Feature addFeature(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 javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.sql.Timestamp;
import java.util.List;
@XmlRootElement
public class Profile {
private int profileId;
@ -43,7 +45,7 @@ public class Profile {
public void setDeviceType(DeviceType deviceType) {
this.deviceType = deviceType;
}
@XmlElement
public int getTenantId() {
return tenantId;
}
@ -59,7 +61,7 @@ public class Profile {
public void setFeaturesList(List<Feature> featuresList) {
this.featuresList = featuresList;
}*/
@XmlElement
public int getProfileId() {
return profileId;
}
@ -68,6 +70,7 @@ public class Profile {
this.profileId = profileId;
}
@XmlElement
public String getProfileName() {
return profileName;
}
@ -76,6 +79,7 @@ public class Profile {
this.profileName = profileName;
}
@XmlElement
public Timestamp getCreatedDate() {
return createdDate;
}
@ -84,6 +88,7 @@ public class Profile {
this.createdDate = createdDate;
}
@XmlElement
public Timestamp getUpdatedDate() {
return updatedDate;
}
@ -92,6 +97,7 @@ public class Profile {
this.updatedDate = updatedDate;
}
@XmlElement
public List<ProfileFeature> getProfileFeaturesList() {
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
public Feature addFeature(Feature feature) throws FeatureManagementException {
try {

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

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

Loading…
Cancel
Save