Derek Hulley 0c10d61a48 Merged V2.0 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5141 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@51352 .
      - FLOSS
      - Some files will need a follow-up
         -root/projects/repository/source/java/org/alfresco/repo/avm/wf/AVMRemoveWFStoreHandler.java (not yet on HEAD: 5094)
         -root/projects/repository/source/java/org/alfresco/filesys/server/state/FileStateLockManager.java (not yet on HEAD: 5093)
         -onContentUpdateRecord (not on HEAD)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5167 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2007-02-16 06:44:46 +00:00

248 lines
5.5 KiB
Java

/*
* Copyright (C) 2005 Alfresco, Inc.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.filesys.netbios.server;
import org.alfresco.filesys.netbios.NetBIOSName;
/**
* NetBIOS Request Class
* <p>
* Contains the details of NetBIOS server request, such as an add name request.
*/
class NetBIOSRequest
{
// Request types
public final static int AddName = 0;
public final static int DeleteName = 1;
public final static int RefreshName = 2;
// Default retry count and interval
public final static int DefaultRetries = 5;
public final static long DefaultInterval = 2000; // ms
// Requets type strings
private final static String[] _typeNames = { "AddName", "DelName", "RefreshName" };
// Request type
private int m_type;
// NetBIOS name details
private NetBIOSName m_nbName;
// Retry count and interval
private int m_retry;
private long m_retryIntvl;
// Response status
private boolean m_error;
// Transaction id for this request
private int m_tranId;
/**
* Class constructor
*
* @param typ int
* @param nbName NetBIOSName
* @param tranId int
*/
public NetBIOSRequest(int typ, NetBIOSName nbName, int tranId)
{
m_type = typ;
m_nbName = nbName;
m_tranId = tranId;
m_retry = DefaultRetries;
m_retryIntvl = DefaultInterval;
m_error = false;
}
/**
* Class constructor
*
* @param typ int
* @param nbName NetBIOSName
* @param tranId int
* @param retry int
*/
public NetBIOSRequest(int typ, NetBIOSName nbName, int tranId, int retry)
{
m_type = typ;
m_nbName = nbName;
m_tranId = tranId;
m_retry = retry;
m_retryIntvl = DefaultInterval;
m_error = false;
}
/**
* Return the request type
*
* @return int
*/
public final int isType()
{
return m_type;
}
/**
* Return the type as a string
*
* @return String
*/
public final String getTypeAsString()
{
if (m_type < 0 || m_type >= _typeNames.length)
return "";
return _typeNames[m_type];
}
/**
* Return the NetBIOS name details
*
* @return NetBIOSName
*/
public final NetBIOSName getNetBIOSName()
{
return m_nbName;
}
/**
* Return the retry count
*
* @return int
*/
public final int getRetryCount()
{
return m_retry;
}
/**
* Return the retry interval
*
* @return long
*/
public final long getRetryInterval()
{
return m_retryIntvl;
}
/**
* Return the transaction id
*
* @return int
*/
public final int getTransactionId()
{
return m_tranId;
}
/**
* Check if the request has an error status
*
* @return boolean
*/
public final boolean hasErrorStatus()
{
return m_error;
}
/**
* Decrement the retry count
*
* @return int
*/
protected final int decrementRetryCount()
{
return m_retry--;
}
/**
* Set the error status
*
* @param sts boolean
*/
protected final void setErrorStatus(boolean sts)
{
m_error = sts;
}
/**
* Set the request retry count
*
* @param retry int
*/
public final void setRetryCount(int retry)
{
m_retry = retry;
}
/**
* Set the retry interval, in milliseconds
*
* @param interval long
*/
public final void setRetryInterval(long interval)
{
m_retryIntvl = interval;
}
/**
* Return the request as a string
*
* @return String
*/
public String toString()
{
StringBuffer str = new StringBuffer();
str.append("[");
str.append(getTypeAsString());
str.append(":");
str.append(getNetBIOSName());
str.append(",");
str.append(getRetryCount());
str.append(",");
str.append(getRetryInterval());
str.append(",");
str.append(getTransactionId());
str.append("]");
return str.toString();
}
}