diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-07-05 10:22:37 -0400 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-07-10 14:23:18 -0500 |
commit | f65eae145ca6720fab774600ddda2b04f364dda0 (patch) | |
tree | 05b90f929c4a1b8193a64a3c79cbda09e1b85492 /base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java | |
parent | a3c83b5f63c9ced5c527cb3b9306d390c3d192ec (diff) | |
download | pki-f65eae145ca6720fab774600ddda2b04f364dda0.tar.gz pki-f65eae145ca6720fab774600ddda2b04f364dda0.tar.xz pki-f65eae145ca6720fab774600ddda2b04f364dda0.zip |
Refactored RequestStatus.
The RequestStatus has been modified to use a map to convert string
into RequestStatus instance. The string constants in RequestStatus
are no longer needed because instances can be compared using
equal sign directly or equals().
Ticket #161
Diffstat (limited to 'base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java')
-rw-r--r-- | base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java b/base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java new file mode 100644 index 000000000..06b3605bb --- /dev/null +++ b/base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.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) 2012 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.request; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import org.apache.commons.lang.StringUtils; + +/** + * The RevocationReasonAdapter class provides custom marshaling for RevocationReason. + * + * @author Endi S. Dewata + */ +public class RequestStatusAdapter extends XmlAdapter<String, RequestStatus> { + + public RequestStatus unmarshal(String value) throws Exception { + return StringUtils.isEmpty(value) ? null : RequestStatus.valueOf(value); + } + + public String marshal(RequestStatus value) throws Exception { + return value == null ? null : value.toString(); + } +}
\ No newline at end of file |