diff options
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/profile')
10 files changed, 825 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfileNotFoundException.java b/base/common/src/com/netscape/cms/servlet/profile/ProfileNotFoundException.java new file mode 100644 index 000000000..30a1a5852 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/ProfileNotFoundException.java @@ -0,0 +1,62 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.profile; + +import javax.ws.rs.core.Response; + +import com.netscape.cms.servlet.base.CMSException; + +public class ProfileNotFoundException extends CMSException { + + private static final long serialVersionUID = -4784839378360933483L; + + public String profileId; + + public ProfileNotFoundException(String profileId) { + this(profileId, "Profile ID " + profileId + " not found"); + } + + public ProfileNotFoundException(String profileId, String message) { + super(Response.Status.NOT_FOUND, message); + this.profileId = profileId; + } + + public ProfileNotFoundException(String profileId, String message, Throwable cause) { + super(Response.Status.NOT_FOUND, message, cause); + this.profileId = profileId; + } + + public ProfileNotFoundException(Data data) { + super(data); + profileId = data.getAttribute("profileId"); + } + + public Data getData() { + Data data = super.getData(); + data.setAttribute("profileId", profileId); + return data; + } + + public String getProfileId() { + return profileId; + } + + public void setRequestId(String profileId) { + this.profileId = profileId; + } +} diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfileResource.java b/base/common/src/com/netscape/cms/servlet/profile/ProfileResource.java new file mode 100644 index 000000000..38f7ee038 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/ProfileResource.java @@ -0,0 +1,40 @@ +package com.netscape.cms.servlet.profile; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import com.netscape.cms.servlet.profile.model.ProfileData; + +@Path("/profile") +public interface ProfileResource { + + @GET + @Path("{id}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML }) + public ProfileData retrieveProfile(@PathParam("id") String id); + + /** + * Used to retrieve a key + * + * @param data + * @return + */ + + /* + @POST + @Path("retrieve") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML }) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public ProfileData retrieveProfile(ProfileRetrievalRequestData request); + + // retrieval - used to test integration with a browser + @POST + @Path("retrieve") + @Produces(MediaType.TEXT_XML) + @Consumes({ MediaType.APPLICATION_FORM_URLENCODED }) + public ProfileData retrievProfile(MultivaluedMap<String, String> form); + */ +}
\ No newline at end of file diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfileResourceService.java b/base/common/src/com/netscape/cms/servlet/profile/ProfileResourceService.java new file mode 100644 index 000000000..a9af6278f --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/ProfileResourceService.java @@ -0,0 +1,40 @@ +//--- BEGIN COPYRIGHT BLOCK --- +//This program is free software; you can redistribute it and/or modify +//it under the terms of the GNU General Public License as published by +//the Free Software Foundation; version 2 of the License. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. +// +//You should have received a copy of the GNU General Public License along +//with this program; if not, write to the Free Software Foundation, Inc., +//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +//(C) 2011 Red Hat, Inc. +//All rights reserved. +//--- END COPYRIGHT BLOCK --- + +package com.netscape.cms.servlet.profile; + +import com.netscape.cms.servlet.base.CMSResourceService; +import com.netscape.cms.servlet.profile.model.ProfileDAO; +import com.netscape.cms.servlet.profile.model.ProfileData; + +/** + * @author alee + * + */ +public class ProfileResourceService extends CMSResourceService implements ProfileResource { + @Override + public ProfileData retrieveProfile(String id) { + + ProfileData data = null; + ProfileDAO dao = new ProfileDAO(); + + data = dao.getProfile(id); + + return data; + } +} diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfilesResource.java b/base/common/src/com/netscape/cms/servlet/profile/ProfilesResource.java new file mode 100644 index 000000000..68868ebe8 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/ProfilesResource.java @@ -0,0 +1,34 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.profile; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import com.netscape.cms.servlet.profile.model.ProfileDataInfos; + +@Path("/profiles") +public interface ProfilesResource { + + @GET + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML }) + public ProfileDataInfos listProfiles(); + +} diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfilesResourceService.java b/base/common/src/com/netscape/cms/servlet/profile/ProfilesResourceService.java new file mode 100644 index 000000000..f07fbdcc2 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/ProfilesResourceService.java @@ -0,0 +1,38 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +/** + * + */ +package com.netscape.cms.servlet.profile; + +import com.netscape.cms.servlet.base.CMSResourceService; +import com.netscape.cms.servlet.profile.model.ProfileDAO; +import com.netscape.cms.servlet.profile.model.ProfileDataInfos; + +/** + * @author alee + * + */ +public class ProfilesResourceService extends CMSResourceService implements ProfilesResource { + + public ProfileDataInfos listProfiles() + { + ProfileDAO dao = new ProfileDAO(); + return dao.listProfiles(uriInfo); + } +} diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDAO.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDAO.java new file mode 100644 index 000000000..372570a53 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDAO.java @@ -0,0 +1,214 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.profile.model; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Locale; + +import javax.ws.rs.Path; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; + +import com.netscape.certsrv.apps.CMS; +import com.netscape.certsrv.base.EBaseException; +import com.netscape.certsrv.profile.EProfileException; +import com.netscape.certsrv.profile.IProfile; +import com.netscape.certsrv.profile.IProfileInput; +import com.netscape.certsrv.profile.IProfileSubsystem; +import com.netscape.cms.servlet.profile.ProfileNotFoundException; +import com.netscape.cms.servlet.profile.ProfileResource; + +/** + * @author alee + * + */ +public class ProfileDAO { + + private IProfileSubsystem ps; + + public ProfileDAO() { + ps = (IProfileSubsystem) CMS.getSubsystem(IProfileSubsystem.ID); + } + + /** + * Returns list of profiles + */ + + public ProfileDataInfos listProfiles(UriInfo uriInfo) + { + + List<ProfileDataInfo> list = new ArrayList<ProfileDataInfo>(); + ProfileDataInfos infos = new ProfileDataInfos(); + + if (ps == null) { + return null; + } + + Enumeration<String> profileIds = ps.getProfileIds(); + + if (profileIds != null) { + while (profileIds.hasMoreElements()) { + String id = profileIds.nextElement(); + ProfileDataInfo info = null; + try { + info = createProfileDataInfo(id, uriInfo); + } catch (EBaseException e) { + continue; + } + + if (info != null) { + list.add(info); + } + } + } + + infos.setProfileInfos(list); + + return infos; + } + + public ProfileData getProfile(String profileId) throws ProfileNotFoundException { + ProfileData data = null; + + if (ps == null) { + return null; + } + + Enumeration<String> profileIds = ps.getProfileIds(); + + IProfile profile = null; + if (profileIds != null) { + while (profileIds.hasMoreElements()) { + String id = profileIds.nextElement(); + + if (id.equals(profileId)) { + + try { + profile = ps.getProfile(profileId); + } catch (EProfileException e) { + e.printStackTrace(); + throw new ProfileNotFoundException(profileId); + } + break; + } + } + } + + if (profile == null) { + throw new ProfileNotFoundException(profileId); + } + + try { + data = createProfileData(profileId); + } catch (EBaseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new ProfileNotFoundException(profileId); + } + + return data; + } + + public ProfileData createProfileData(String profileId) throws EBaseException { + + IProfile profile; + + try { + profile = ps.getProfile(profileId); + } catch (EProfileException e) { + e.printStackTrace(); + throw new ProfileNotFoundException(profileId); + } + + ProfileData data = new ProfileData(); + + Locale locale = Locale.getDefault(); + String name = profile.getName(locale); + String desc = profile.getDescription(locale); + + data.setName(name); + data.setDescription(desc); + data.setIsEnabled(ps.isProfileEnable(profileId)); + data.setIsVisible(profile.isVisible()); + data.setEnabledBy(ps.getProfileEnableBy(profileId)); + data.setId(profileId); + + Enumeration<String> inputIds = profile.getProfileInputIds(); + + String inputName = null; + + if (inputIds != null) { + while (inputIds.hasMoreElements()) { + String inputId = inputIds.nextElement(); + IProfileInput profileInput = profile.getProfileInput(inputId); + + if (profileInput == null) { + continue; + } + inputName = profileInput.getName(locale); + + Enumeration<String> inputNames = profileInput.getValueNames(); + + ProfileInput input = data.addProfileInput(inputName); + + String curInputName = null; + while (inputNames.hasMoreElements()) { + curInputName = inputNames.nextElement(); + + if (curInputName != null && !curInputName.equals("")) { + input.setInputAttr(curInputName, ""); + } + + } + } + } + + return data; + + } + + public ProfileDataInfo createProfileDataInfo(String profileId, UriInfo uriInfo) throws EBaseException { + + if (profileId == null) { + throw new EBaseException("Error creating ProfileDataInfo."); + } + ProfileDataInfo ret = null; + + IProfile profile = null; + + profile = ps.getProfile(profileId); + if (profile == null) { + return null; + } + + ret = new ProfileDataInfo(); + + ret.setProfileId(profileId); + + Path profilePath = ProfileResource.class.getAnnotation(Path.class); + + UriBuilder profileBuilder = uriInfo.getBaseUriBuilder(); + profileBuilder.path(profilePath.value() + "/" + profileId); + ret.setProfileURL(profileBuilder.build().toString()); + + return ret; + } + +}
\ No newline at end of file diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileData.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileData.java new file mode 100644 index 000000000..22a59c470 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileData.java @@ -0,0 +1,146 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +/** + * + */ +package com.netscape.cms.servlet.profile.model; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * @author jmagne + * + */ + +@XmlRootElement(name = "ProfileData") +@XmlAccessorType(XmlAccessType.FIELD) +public class ProfileData { + + @XmlElement + protected String id; + @XmlElement + protected String name; + + @XmlElement + protected String description; + + @XmlElement + protected boolean isEnabled; + + @XmlElement + protected boolean isVisible; + + @XmlElement + protected String enabledBy; + + @XmlElement(name = "Input") + protected List<ProfileInput> inputs = new ArrayList<ProfileInput>(); + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setIsEnabled(boolean isEnabled) { + this.isEnabled = isEnabled; + } + + public boolean getIsEnabled() { + return isEnabled; + } + + public void setIsVisible(boolean isVisible) { + this.isVisible = isVisible; + } + + public boolean getIsVisible() { + return isVisible; + } + + public void setEnabledBy(String enabledBy) { + this.enabledBy = enabledBy; + } + + public String getEnabledBy() { + return enabledBy; + } + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public ProfileInput addProfileInput(String name) { + + ProfileInput oldInput = getProfileInput(name); + + if (oldInput != null) + return oldInput; + + ProfileInput newInput = new ProfileInput(); + newInput.setInputId(name); + + inputs.add(newInput); + + return newInput; + } + + public ProfileInput getProfileInput(String name) { + + ProfileInput input = null; + + Iterator<ProfileInput> it = inputs.iterator(); + + ProfileInput curInput = null; + while (it.hasNext()) { + curInput = it.next(); + + if (curInput != null && curInput.getInputId().equals(name)) + break; + } + + return input; + } + + public List<ProfileInput> getProfileInputsList() { + return inputs; + } + +}
\ No newline at end of file diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfo.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfo.java new file mode 100644 index 000000000..63f005b54 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfo.java @@ -0,0 +1,72 @@ +package com.netscape.cms.servlet.profile.model; + +//--- BEGIN COPYRIGHT BLOCK --- +//This program is free software; you can redistribute it and/or modify +//it under the terms of the GNU General Public License as published by +//the Free Software Foundation; version 2 of the License. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. +// +//You should have received a copy of the GNU General Public License along +//with this program; if not, write to the Free Software Foundation, Inc., +//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +//(C) 2011 Red Hat, Inc. +//All rights reserved. +//--- END COPYRIGHT BLOCK --- +/** + * + */ + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessorType; + +/** + * @author alee + * + */ +@XmlRootElement(name = "ProfileDataInfo") +@XmlAccessorType(XmlAccessType.FIELD) +public class ProfileDataInfo { + + @XmlElement + protected String profileURL; + + @XmlElement + protected String profileId; + + public ProfileDataInfo() { + // required for JAXB (defaults) + } + + /** + * @return the profileURL + */ + public String getProfileURL() { + return profileURL; + } + + /** + * @param keyURL the profileURL to set + */ + public void setProfileURL(String profileURL) { + this.profileURL = profileURL; + } + + public void setProfileId(String profileId) { + this.profileId = profileId; + } + + /** + * @return the profile ID in the profileURL + */ + public String getProfileId() { + return profileId; + } + +} diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfos.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfos.java new file mode 100644 index 000000000..e14ac6641 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileDataInfos.java @@ -0,0 +1,90 @@ +//--- BEGIN COPYRIGHT BLOCK --- +//This program is free software; you can redistribute it and/or modify +//it under the terms of the GNU General Public License as published by +//the Free Software Foundation; version 2 of the License. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. +// +//You should have received a copy of the GNU General Public License along +//with this program; if not, write to the Free Software Foundation, Inc., +//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +//(C) 2012 Red Hat, Inc. +//All rights reserved. +//--- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.profile.model; + +import java.util.Collection; +import java.util.List; + +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import com.netscape.cms.servlet.base.model.Link; + +@XmlRootElement(name = "ProfileDataInfos") +public class ProfileDataInfos { + + protected Collection<ProfileDataInfo> profileInfos; + protected List<Link> links; + + /** + * @return the ProfileInfos + */ + @XmlElementRef + public Collection<ProfileDataInfo> getProfileInfos() { + return profileInfos; + } + + /** + * @param ProfileInfos theProfileInfos to set + */ + public void setProfileInfos(Collection<ProfileDataInfo> profileInfos) { + this.profileInfos = profileInfos; + } + + /** + * @return the links + */ + @XmlElementRef + public List<Link> getLinks() { + return links; + } + + /** + * @param links the links to set + */ + public void setLinks(List<Link> links) { + this.links = links; + } + + @XmlTransient + public String getNext() { + if (links == null) { + return null; + } + for (Link link : links) { + if ("next".equals(link.getRelationship())) { + return link.getHref(); + } + } + return null; + } + + @XmlTransient + public String getPrevious() { + if (links == null) { + return null; + } + for (Link link : links) { + if ("previous".equals(link.getRelationship())) { + return link.getHref(); + } + } + return null; + } +} diff --git a/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInput.java b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInput.java new file mode 100644 index 000000000..a0aea9fd4 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/model/ProfileInput.java @@ -0,0 +1,89 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.profile.model; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.XmlAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +public class ProfileInput { + + @XmlElement + public String getInputId() { + return inputId; + } + + private String inputId; + @XmlJavaTypeAdapter(InputAttrsAdapter.class) + public Map<String, String> InputAttrs = new LinkedHashMap<String, String>(); + + public void setInputAttr(String name, String value) { + InputAttrs.put(name, value); + } + + public void setInputId(String inputId) { + this.inputId = inputId; + } + + public static class InputAttrsAdapter extends XmlAdapter<InputAttrList, Map<String, String>> { + + public InputAttrList marshal(Map<String, String> map) { + InputAttrList list = new InputAttrList(); + for (Map.Entry<String, String> entry : map.entrySet()) { + Attribute attribute = new Attribute(); + attribute.name = entry.getKey(); + attribute.value = entry.getValue(); + list.attributes.add(attribute); + } + return list; + } + + public Map<String, String> unmarshal(InputAttrList list) { + Map<String, String> map = new LinkedHashMap<String, String>(); + for (Attribute attribute : list.attributes) { + map.put(attribute.name, attribute.value); + } + return map; + } + } + + public static class InputAttrList { + @XmlElement(name = "InputAttr") + public List<Attribute> attributes = new ArrayList<Attribute>(); + } + + public static class Attribute { + + @XmlAttribute + public String name; + + @XmlValue + public String value; + } + + public Map<String, String> getAttributes() { + return InputAttrs; + } +} |