management: FaceUpdateCommand

Change-Id: I5e3955ef3e15dff2e662786816cea7cb8e1a9bb8
refs: #3232
diff --git a/src/management/nfd-control-command.cpp b/src/management/nfd-control-command.cpp
index 7863ad4..307810d 100644
--- a/src/management/nfd-control-command.cpp
+++ b/src/management/nfd-control-command.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -121,6 +121,34 @@
   }
 }
 
+FaceUpdateCommand::FaceUpdateCommand()
+  : ControlCommand("faces", "update")
+{
+  m_requestValidator
+    .required(CONTROL_PARAMETER_FACE_ID)
+    .optional(CONTROL_PARAMETER_FACE_PERSISTENCY);
+  m_responseValidator
+    .required(CONTROL_PARAMETER_FACE_ID)
+    .optional(CONTROL_PARAMETER_FACE_PERSISTENCY);
+  m_responseValidator = m_requestValidator;
+}
+
+void
+FaceUpdateCommand::validateRequest(const ControlParameters& parameters) const
+{
+  this->ControlCommand::validateRequest(parameters);
+
+  if (parameters.getFaceId() == 0) {
+    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
+  }
+}
+
+void
+FaceUpdateCommand::validateResponse(const ControlParameters& parameters) const
+{
+  this->validateRequest(parameters);
+}
+
 FaceDestroyCommand::FaceDestroyCommand()
   : ControlCommand("faces", "destroy")
 {
diff --git a/src/management/nfd-control-command.hpp b/src/management/nfd-control-command.hpp
index b9ad533..48a05ee 100644
--- a/src/management/nfd-control-command.hpp
+++ b/src/management/nfd-control-command.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -148,6 +148,22 @@
   validateResponse(const ControlParameters& parameters) const;
 };
 
+/**
+ * \ingroup management
+ * \brief represents a faces/update command
+ * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Update-a-face
+ */
+class FaceUpdateCommand : public ControlCommand
+{
+public:
+  FaceUpdateCommand();
+
+  virtual void
+  validateRequest(const ControlParameters& parameters) const;
+
+  virtual void
+  validateResponse(const ControlParameters& parameters) const;
+};
 
 /**
  * \ingroup management
diff --git a/src/management/nfd-control-parameters.cpp b/src/management/nfd-control-parameters.cpp
index d0a663e..f94148b 100644
--- a/src/management/nfd-control-parameters.cpp
+++ b/src/management/nfd-control-parameters.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -233,6 +233,10 @@
     os << "ExpirationPeriod: " << parameters.getExpirationPeriod() << ", ";
   }
 
+  if (parameters.hasFacePersistency()) {
+    os << "FacePersistency: " << parameters.getFacePersistency() << ", ";
+  }
+
   os << ")";
   return os;
 }
diff --git a/src/management/nfd-control-parameters.hpp b/src/management/nfd-control-parameters.hpp
index c5f26d3..ed077a7 100644
--- a/src/management/nfd-control-parameters.hpp
+++ b/src/management/nfd-control-parameters.hpp
@@ -57,7 +57,7 @@
   "Flags",
   "Strategy",
   "ExpirationPeriod",
-  "FacePersistency",
+  "FacePersistency"
 };
 
 /**