diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-08-11 10:32:01 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-08-15 12:07:39 -0500 |
commit | 3c9b8e787ccf066c38469e1fe2c119d5c410bb5e (patch) | |
tree | 88fdd1b9674f7a350ca56add03a99af13c58189f /base/common/src/com/netscape/cms/servlet/profile/ProfileInputFactory.java | |
parent | 108bd269ab0eb512c334939fabde68eeab5b0b67 (diff) | |
download | pki-3c9b8e787ccf066c38469e1fe2c119d5c410bb5e.tar.gz pki-3c9b8e787ccf066c38469e1fe2c119d5c410bb5e.tar.xz pki-3c9b8e787ccf066c38469e1fe2c119d5c410bb5e.zip |
Reorganized REST server classes.
The factory and DAO classes used by REST services have been moved
into the com.netscape.cms.servlet.<component> packages.
Ticket #215
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/profile/ProfileInputFactory.java')
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/profile/ProfileInputFactory.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfileInputFactory.java b/base/common/src/com/netscape/cms/servlet/profile/ProfileInputFactory.java new file mode 100644 index 000000000..1e9f4598c --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/profile/ProfileInputFactory.java @@ -0,0 +1,41 @@ +package com.netscape.cms.servlet.profile; + +import java.util.Enumeration; +import java.util.Locale; + +import com.netscape.certsrv.base.IArgBlock; +import com.netscape.certsrv.profile.EProfileException; +import com.netscape.certsrv.profile.IProfileInput; +import com.netscape.certsrv.request.IRequest; +import com.netscape.cms.servlet.profile.model.ProfileInput; + +public class ProfileInputFactory { + + public static ProfileInput create(IProfileInput input, IRequest request, Locale locale) throws EProfileException { + ProfileInput ret = new ProfileInput(); + ret.setInputId(input.getName(locale)); + Enumeration<String> names = input.getValueNames(); + while (names.hasMoreElements()) { + String name = names.nextElement(); + String value = input.getValue(name, locale, request); + if (value != null) { + ret.setInputAttr(name, value); + } + } + return ret; + } + + public static ProfileInput create(IProfileInput input, IArgBlock params, Locale locale) throws EProfileException { + ProfileInput ret = new ProfileInput(); + ret.setInputId(input.getName(locale)); + Enumeration<String> names = input.getValueNames(); + while (names.hasMoreElements()) { + String name = names.nextElement(); + String value = params.getValueAsString(name, null); + if (value != null) { + ret.setInputAttr(name, value); + } + } + return ret; + } +} |