/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
import java.util.Date;
import java.util.Map;
import javax.management.openmbean.SimpleType;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
+import org.opendaylight.controller.config.facade.xml.util.Util;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
@Override
- public Optional<Object> parseAttribute(String attrName, Object value) throws NetconfDocumentedException {
+ public Optional<Object> parseAttribute(String attrName, Object value) throws DocumentedException {
if (value == null) {
return Optional.absent();
}
}
static interface Resolver {
- Object resolveObject(Class<?> type, String attrName, String value) throws NetconfDocumentedException;
+ Object resolveObject(Class<?> type, String attrName, String value) throws DocumentedException;
}
static class DefaultResolver implements Resolver {
@Override
- public Object resolveObject(Class<?> type, String attrName, String value) throws NetconfDocumentedException {
+ public Object resolveObject(Class<?> type, String attrName, String value) throws DocumentedException {
try {
return parseObject(type, value);
} catch (Exception e) {
- throw new NetconfDocumentedException("Unable to resolve attribute " + attrName + " from " + value,
- NetconfDocumentedException.ErrorType.application,
- NetconfDocumentedException.ErrorTag.operation_failed,
- NetconfDocumentedException.ErrorSeverity.error);
+ throw new DocumentedException("Unable to resolve attribute " + attrName + " from " + value,
+ DocumentedException.ErrorType.application,
+ DocumentedException.ErrorTag.operation_failed,
+ DocumentedException.ErrorSeverity.error);
}
}
- protected Object parseObject(Class<?> type, String value) throws NetconfDocumentedException {
+ protected Object parseObject(Class<?> type, String value) throws DocumentedException {
Method method = null;
try {
method = type.getMethod("valueOf", String.class);
return method.invoke(null, value);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
LOG.trace("Error parsing object ",e);
- throw new NetconfDocumentedException("Error parsing object.",
- NetconfDocumentedException.ErrorType.application,
- NetconfDocumentedException.ErrorTag.operation_failed,
- NetconfDocumentedException.ErrorSeverity.error);
+ throw new DocumentedException("Error parsing object.",
+ DocumentedException.ErrorType.application,
+ DocumentedException.ErrorTag.operation_failed,
+ DocumentedException.ErrorSeverity.error);
}
}
}
static class DateResolver extends DefaultResolver {
@Override
- protected Object parseObject(Class<?> type, String value) throws NetconfDocumentedException {
+ protected Object parseObject(Class<?> type, String value) throws DocumentedException {
try {
return Util.readDate(value);
} catch (ParseException e) {
LOG.trace("Unable parse value {} due to ",value, e);
- throw new NetconfDocumentedException("Unable to parse value "+value+" as date.",
- NetconfDocumentedException.ErrorType.application,
- NetconfDocumentedException.ErrorTag.operation_failed,
- NetconfDocumentedException.ErrorSeverity.error);
+ throw new DocumentedException("Unable to parse value "+value+" as date.",
+ DocumentedException.ErrorType.application,
+ DocumentedException.ErrorTag.operation_failed,
+ DocumentedException.ErrorSeverity.error);
}
}
}