All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lrgs.ldds.CmdGetStatus Maven / Gradle / Ivy

Go to download

A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.

The newest version!
/*
*  $Id$
*
*  $Log$
*  Revision 1.1.1.1  2014/05/19 15:28:59  mmaloney
*  OPENDCS 6.0 Initial Checkin
*
*  Revision 1.1  2008/04/04 18:21:14  cvs
*  Added legacy code to repository
*
*  Revision 1.6  2005/07/20 20:18:56  mjmaloney
*  LRGS 5.0 Release preparation
*
*  Revision 1.5  2005/06/28 17:37:01  mjmaloney
*  Java-Only-Archive implementation.
*
*  Revision 1.4  2005/03/07 21:33:50  mjmaloney
*  dev
*
*  Revision 1.3  2005/01/05 19:21:06  mjmaloney
*  Bug fixes & updates.
*
*  Revision 1.2  2004/08/30 14:51:46  mjmaloney
*  Javadocs
*
*  Revision 1.1  2004/05/04 16:41:26  mjmaloney
*  Added.
*
*/
package lrgs.ldds;

import java.io.IOException;
import java.io.ByteArrayOutputStream;
import ilex.xml.XmlOutputStream;
import lrgs.common.*;
import lrgs.lrgsmain.LrgsConfig;
import lrgs.statusxml.StatusXmlTags;
import lrgs.statusxml.LrgsStatusSnapshotExt;
import lrgs.statusxml.LrgsStatusSnapshotXio;

/**
This command returns an XML block containing the current LRGS status.
*/
public class CmdGetStatus extends LddsCommand
{
	/**
	  Create a new 'GetStatus' request.
	*/
	public CmdGetStatus()
	{
	}

	/** @return "CmdGetStatus"; */
	public String cmdType()
	{
		return "CmdGetStatus";
	}

	/**
	  Executes the command.
	  Construct status response & send to user.
	  @param ldds the server thread object holding connection to client.
	*/
	public int execute(LddsThread ldds)
		throws ArchiveException, IOException
	{
		if (ldds.user == null)
			throw new UnknownUserException("HELLO required before GetStatus.");

		LrgsStatusProvider sp = ldds.getStatusProvider();
		LrgsStatusSnapshotExt lsse = sp.getStatusSnapshot();

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		XmlOutputStream xos = 
			new XmlOutputStream(baos, StatusXmlTags.LrgsStatusSnapshot);

		LrgsStatusSnapshotXio lssxio = new LrgsStatusSnapshotXio(lsse);
		lssxio.setHideHostNames(
			LrgsConfig.instance().getMiscBooleanProperty("hideHostNames", false)
			&& !ldds.user.isAdmin);
		lssxio.writeXml(xos);

		LddsMessage response = new LddsMessage(LddsMessage.IdStatus,
			baos.toString());
		ldds.send(response);
		return 0;
	}

	public String toString()
	{
		return "GetStatus";
	}

	/** @return the code associated with this command. */
	public char getCommandCode() { return LddsMessage.IdStatus; }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy