added market repository class
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 22 Apr 2016 11:34:47 +0000 (14:34 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 22 Apr 2016 11:34:47 +0000 (14:34 +0300)
src/java/client/netxms-client/src/main/java/org/netxms/client/market/Repository.java [new file with mode: 0644]

diff --git a/src/java/client/netxms-client/src/main/java/org/netxms/client/market/Repository.java b/src/java/client/netxms-client/src/main/java/org/netxms/client/market/Repository.java
new file mode 100644 (file)
index 0000000..aa1d8dc
--- /dev/null
@@ -0,0 +1,119 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.client.market;
+
+import org.netxms.base.NXCPCodes;
+import org.netxms.base.NXCPMessage;
+
+/**
+ * NetXMS configuration repository information
+ */
+public class Repository
+{
+   private String url;
+   private String authToken;
+   private String description;
+   
+   /**
+    * Create new repository object
+    * 
+    * @param url
+    * @param authToken
+    * @param description
+    */
+   public Repository(String url, String authToken, String description)
+   {
+      this.url = url;
+      this.authToken = authToken;
+      this.description = description;
+   }
+   
+   /**
+    * Create repository object from NXCP message
+    * 
+    * @param msg
+    * @param baseId
+    */
+   public Repository(NXCPMessage msg, long baseId)
+   {
+      url = msg.getFieldAsString(baseId);
+      authToken = msg.getFieldAsString(baseId + 1);
+      description = msg.getFieldAsString(baseId + 2);
+   }
+   
+   /**
+    * Fill NXCP message with repository data
+    * 
+    * @param msg NXCP message
+    */
+   public void fillMessage(NXCPMessage msg)
+   {
+      msg.setField(NXCPCodes.VID_URL, url);
+      msg.setField(NXCPCodes.VID_AUTH_TOKEN, authToken);
+      msg.setField(NXCPCodes.VID_DESCRIPTION, description);
+   }
+
+   /**
+    * @return the url
+    */
+   public String getUrl()
+   {
+      return url;
+   }
+
+   /**
+    * @param url the url to set
+    */
+   public void setUrl(String url)
+   {
+      this.url = url;
+   }
+
+   /**
+    * @return the authToken
+    */
+   public String getAuthToken()
+   {
+      return authToken;
+   }
+
+   /**
+    * @param authToken the authToken to set
+    */
+   public void setAuthToken(String authToken)
+   {
+      this.authToken = authToken;
+   }
+
+   /**
+    * @return the description
+    */
+   public String getDescription()
+   {
+      return description;
+   }
+
+   /**
+    * @param description the description to set
+    */
+   public void setDescription(String description)
+   {
+      this.description = description;
+   }
+}