diff --git a/base/ca/src/main/java/org/dogtagpki/server/ca/rest/ProfileService.java b/base/ca/src/main/java/org/dogtagpki/server/ca/rest/ProfileService.java index 1928b6a8a00..ca1ed289989 100644 --- a/base/ca/src/main/java/org/dogtagpki/server/ca/rest/ProfileService.java +++ b/base/ca/src/main/java/org/dogtagpki/server/ca/rest/ProfileService.java @@ -110,7 +110,7 @@ public ProfileService() { } @Override - public Response listProfiles(Integer start, Integer size) { + public Response listProfiles(Integer start, Integer size, Boolean visible, Boolean enable) { start = start == null ? 0 : start; size = size == null ? DEFAULT_SIZE : size; @@ -136,6 +136,10 @@ public Response listProfiles(Integer start, Integer size) { Enumeration e = ps.getProfileIds(); if (e == null) return createOKResponse(infos); + if (visibleOnly && visible != null && !visible.booleanValue()) { + return createOKResponse(infos); + } + // store non-null results in a list List results = new ArrayList<>(); while (e.hasMoreElements()) { @@ -143,6 +147,10 @@ public Response listProfiles(Integer start, Integer size) { String id = e.nextElement(); ProfileDataInfo info = createProfileDataInfo(id, visibleOnly, uriInfo, getLocale(headers)); if (info == null) continue; + if (visible != null && info.getProfileVisible() != null && !info.getProfileVisible().equals(visible)) + continue; + if (enable != null && info.getProfileEnable() != null && !info.getProfileEnable().equals(enable)) + continue; results.add(info); } catch (EBaseException ex) { continue; @@ -383,6 +391,11 @@ public static ProfileDataInfo createProfileDataInfo(String profileId, boolean vi ret.setProfileName(profile.getName(locale)); ret.setProfileDescription(profile.getDescription(locale)); + if (!visibleOnly) { + ret.setProfileVisible(Boolean.valueOf(profile.isVisible())); + ret.setProfileEnable(Boolean.valueOf(profile.isEnable())); + ret.setProfileEnableBy(profile.getApprovedBy()); + } UriBuilder profileBuilder = uriInfo.getBaseUriBuilder(); URI uri = profileBuilder.path(ProfileResource.class).path("{id}"). build(profileId); diff --git a/base/common/src/main/java/com/netscape/certsrv/profile/ProfileDataInfo.java b/base/common/src/main/java/com/netscape/certsrv/profile/ProfileDataInfo.java index a67d6972429..0d97d27813b 100644 --- a/base/common/src/main/java/com/netscape/certsrv/profile/ProfileDataInfo.java +++ b/base/common/src/main/java/com/netscape/certsrv/profile/ProfileDataInfo.java @@ -56,6 +56,12 @@ public class ProfileDataInfo implements JSONSerializer { protected String profileDescription; + protected Boolean profileVisible; + + protected Boolean profileEnable; + + protected String profileEnableBy; + public ProfileDataInfo() { } @@ -100,6 +106,31 @@ public void setProfileDescription(String profileDescription) { this.profileDescription = profileDescription; } + + public Boolean getProfileVisible() { + return profileVisible; + } + + public void setProfileVisible(Boolean profileVisible) { + this.profileVisible = profileVisible; + } + + public Boolean getProfileEnable() { + return profileEnable; + } + + public void setProfileEnable(Boolean profileEnable) { + this.profileEnable = profileEnable; + } + + public String getProfileEnableBy() { + return profileEnableBy; + } + + public void setProfileEnableBy(String profileEnableBy) { + this.profileEnableBy = profileEnableBy; + } + @Override public int hashCode() { return Objects.hash(profileDescription, profileId, profileName, profileURL); @@ -143,6 +174,21 @@ public Element toDOM(Document document) { profileDescriptionElement.appendChild(document.createTextNode(profileDescription)); profileDataInfoElement.appendChild(profileDescriptionElement); } + if (profileVisible != null) { + Element profileVisibleElement = document.createElement("profileVisible"); + profileVisibleElement.appendChild(document.createTextNode(profileVisible.toString())); + profileDataInfoElement.appendChild(profileVisibleElement); + } + if (profileEnable != null) { + Element profileEnableElement = document.createElement("profileEnable"); + profileEnableElement.appendChild(document.createTextNode(profileEnable.toString())); + profileDataInfoElement.appendChild(profileEnableElement); + } + if (profileEnableBy != null) { + Element profileEnableByElement = document.createElement("profileEnableBy"); + profileEnableByElement.appendChild(document.createTextNode(profileEnableBy)); + profileDataInfoElement.appendChild(profileEnableByElement); + } return profileDataInfoElement; } @@ -166,6 +212,18 @@ public static ProfileDataInfo fromDOM(Element profileDataInfoElement) { if (profileDescriptionList.getLength() > 0) { profileDataInfo.setProfileDescription(profileDescriptionList.item(0).getTextContent()); } + NodeList profileVisibleList = profileDataInfoElement.getElementsByTagName("profileVisible"); + if (profileVisibleList.getLength() > 0) { + profileDataInfo.setProfileVisible(Boolean.valueOf(profileVisibleList.item(0).getTextContent())); + } + NodeList profileEnableList = profileDataInfoElement.getElementsByTagName("profileEnable"); + if (profileEnableList.getLength() > 0) { + profileDataInfo.setProfileEnable(Boolean.valueOf(profileEnableList.item(0).getTextContent())); + } + NodeList profileEnableByList = profileDataInfoElement.getElementsByTagName("profileEnableBy"); + if (profileEnableByList.getLength() > 0) { + profileDataInfo.setProfileEnableBy(profileEnableByList.item(0).getTextContent()); + } return profileDataInfo; } diff --git a/base/common/src/main/java/com/netscape/certsrv/profile/ProfileResource.java b/base/common/src/main/java/com/netscape/certsrv/profile/ProfileResource.java index edeb5cebd53..33f5d42bf81 100644 --- a/base/common/src/main/java/com/netscape/certsrv/profile/ProfileResource.java +++ b/base/common/src/main/java/com/netscape/certsrv/profile/ProfileResource.java @@ -20,7 +20,9 @@ public interface ProfileResource { @ACLMapping("profiles.list") public Response listProfiles( @QueryParam("start") Integer start, - @QueryParam("size") Integer size); + @QueryParam("size") Integer size, + @QueryParam("visible") Boolean visible, + @QueryParam("enable") Boolean enable); @GET @Path("{id}")