/root/projects/alfresco-jlan/source/java/org/alfresco/jlan/smb/dcerpc/info/ServiceStatusInfo.java

https://github.com/alfresco-mirror/alfresco-mirror · Java · 264 lines · 98 code · 36 blank · 130 comment · 0 complexity · a8922d2d524471835d2005070ad932fa MD5 · raw file

  1. /*
  2. * Copyright (C) 2006-2010 Alfresco Software Limited.
  3. *
  4. * This file is part of Alfresco
  5. *
  6. * Alfresco is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Alfresco is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package org.alfresco.jlan.smb.dcerpc.info;
  20. import org.alfresco.jlan.smb.dcerpc.DCEBuffer;
  21. import org.alfresco.jlan.smb.dcerpc.DCEBufferException;
  22. import org.alfresco.jlan.smb.dcerpc.DCEReadable;
  23. /**
  24. * Service Status Information Class
  25. *
  26. * <p>
  27. * Contains the status details of a remote NT service.
  28. *
  29. * @author gkspencer
  30. */
  31. public class ServiceStatusInfo implements DCEReadable {
  32. // Service name and display name
  33. private String m_srvName;
  34. private String m_dispName;
  35. // Service status values
  36. private int m_srvType;
  37. private int m_currentState;
  38. private int m_ctrlAccepted;
  39. private int m_win32ExitCode;
  40. private int m_srvExitCode;
  41. private int m_checkPoint;
  42. private int m_waitHint;
  43. /**
  44. * Default constructor
  45. */
  46. public ServiceStatusInfo() {
  47. }
  48. /**
  49. * Class constructor
  50. *
  51. * @param name String
  52. * @param dispname String
  53. */
  54. public ServiceStatusInfo(String name, String dispname) {
  55. m_srvName = name;
  56. m_dispName = dispname;
  57. }
  58. /**
  59. * Class constructor
  60. *
  61. * @param name String
  62. * @param dispname String
  63. * @param typ int
  64. * @param state int
  65. * @param ctrl int
  66. * @param win32code int
  67. * @param srvexit int
  68. * @param chkpoint int
  69. * @param waithint int
  70. */
  71. public ServiceStatusInfo(String name, String dispname, int typ, int state, int ctrl, int win32code, int srvexit,
  72. int chkpoint, int waithint) {
  73. m_srvName = name;
  74. m_dispName = dispname;
  75. m_srvType = typ;
  76. m_currentState = state;
  77. m_ctrlAccepted = ctrl;
  78. m_win32ExitCode = win32code;
  79. m_srvExitCode = srvexit;
  80. m_checkPoint = chkpoint;
  81. m_waitHint = waithint;
  82. }
  83. /**
  84. * Return the service name
  85. *
  86. * @return String
  87. */
  88. public final String getName() {
  89. return m_srvName;
  90. }
  91. /**
  92. * Return the service display name
  93. *
  94. * @return String
  95. */
  96. public final String getDisplayName() {
  97. return m_dispName;
  98. }
  99. /**
  100. * Return the service type
  101. *
  102. * @return int
  103. */
  104. public final int getType() {
  105. return m_srvType;
  106. }
  107. /**
  108. * Return the current service state
  109. *
  110. * @return int
  111. */
  112. public final int getCurrentState() {
  113. return m_currentState;
  114. }
  115. /**
  116. * Return the service control functions accepted by this service
  117. *
  118. * @return int
  119. */
  120. public final int getControlsAccepted() {
  121. return m_ctrlAccepted;
  122. }
  123. /**
  124. * Return the service start/stop Win32 error code
  125. *
  126. * @return int
  127. */
  128. public final int getWin32ErrorCode() {
  129. return m_win32ExitCode;
  130. }
  131. /**
  132. * Return the service specific error code
  133. *
  134. * @return int
  135. */
  136. public final int getServiceErrorCode() {
  137. return m_srvExitCode;
  138. }
  139. /**
  140. * Return the checkpoint value, updated by the service during lengthy start/stop/pause
  141. * opertions.
  142. *
  143. * @return int
  144. */
  145. public final int getCheckpoint() {
  146. return m_checkPoint;
  147. }
  148. /**
  149. * Return the wait hint for the service
  150. *
  151. * @return int
  152. */
  153. public final int getWaitHint() {
  154. return m_waitHint;
  155. }
  156. /**
  157. * Set the service name
  158. *
  159. * @param name String
  160. */
  161. public final void setName(String name) {
  162. m_srvName = name;
  163. }
  164. /**
  165. * Set the service display name
  166. *
  167. * @param dispname String
  168. */
  169. public final void setDisplayName(String dispname) {
  170. m_dispName = dispname;
  171. }
  172. /**
  173. * Clear the string values
  174. */
  175. protected final void clearStrings() {
  176. // Clear the string values
  177. m_srvName = null;
  178. m_dispName = null;
  179. }
  180. /**
  181. * Read the service status information from the DCE buffer
  182. *
  183. * @param buf DCEBuffer
  184. * @exception DCEBufferException
  185. * @see DCESerializable#readObject(DCEBuffer)
  186. */
  187. public void readObject(DCEBuffer buf)
  188. throws DCEBufferException {
  189. // Read the status values
  190. m_srvType = buf.getInt();
  191. m_currentState = buf.getInt();
  192. m_ctrlAccepted = buf.getInt();
  193. m_win32ExitCode = buf.getInt();
  194. m_srvExitCode = buf.getInt();
  195. m_checkPoint = buf.getInt();
  196. m_waitHint = buf.getInt();
  197. }
  198. /**
  199. * Read the strings for this object from the DCE/RPC buffer
  200. *
  201. * @param buf DCEBuffer
  202. * @exception DCEBufferException
  203. */
  204. public void readStrings(DCEBuffer buf)
  205. throws DCEBufferException {
  206. // Not required
  207. }
  208. /**
  209. * Return the service status information as a string
  210. *
  211. * @return String
  212. */
  213. public String toString() {
  214. StringBuffer str = new StringBuffer();
  215. str.append("[");
  216. str.append(getDisplayName());
  217. str.append(",");
  218. str.append(getName());
  219. str.append(",");
  220. str.append(NTService.getTypeAsString(getType()));
  221. str.append(":");
  222. str.append(NTService.getStateAsString(getCurrentState()));
  223. str.append(":");
  224. str.append(NTService.getControlsAcceptedAsString(getControlsAccepted()));
  225. str.append("]");
  226. return str.toString();
  227. }
  228. }