/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see
Provides common code to the Alfresco filesystem implementations. * * @author gkspencer */ public abstract class AlfrescoDiskDriver implements IOCtlInterface, ExtendedDiskInterface { // Logging private static final Log logger = LogFactory.getLog(AlfrescoDiskDriver.class); // Service registry for desktop actions private ServiceRegistry m_serviceRegistry; // Transaction service protected TransactionService m_transactionService; protected IOControlHandler ioControlHandler; public void setIoControlHandler(IOControlHandler ioControlHandler) { this.ioControlHandler = ioControlHandler; } public IOControlHandler getIoControlHandler() { return ioControlHandler; } /** * Return the service registry * * @return ServiceRegistry */ public final ServiceRegistry getServiceRegistry() { return m_serviceRegistry; } /** * Return the transaction service * * @return TransactionService */ public final TransactionService getTransactionService() { return m_transactionService; } /** * Set the service registry * * @param serviceRegistry */ public void setServiceRegistry(ServiceRegistry serviceRegistry) { m_serviceRegistry = serviceRegistry; } /** * @param transactionService the transaction service */ public void setTransactionService(TransactionService transactionService) { m_transactionService = transactionService; } /** * Process a filesystem I/O control request * * @param sess Server session * @param tree Tree connection. * @param ctrlCode I/O control code * @param fid File id * @param dataBuf I/O control specific input data * @param isFSCtrl true if this is a filesystem control, or false for a device control * @param filter if bit0 is set indicates that the control applies to the share root handle * @return DataBuffer * @exception IOControlNotImplementedException * @exception SMBException */ public DataBuffer processIOControl(SrvSession sess, TreeConnection tree, int ctrlCode, int fid, DataBuffer dataBuf, boolean isFSCtrl, int filter) throws IOControlNotImplementedException, SMBException { // Validate the file id NetworkFile netFile = tree.findFile(fid); if ( netFile == null || netFile.isDirectory() == false) throw new SMBException(SMBStatus.NTErr, SMBStatus.NTInvalidParameter); // Check if the I/O control handler is enabled if(tree.getContext() instanceof ContentContext) { ContentContext ctx = (ContentContext) tree.getContext(); if(ioControlHandler != null) { return ioControlHandler.processIOControl(sess, tree, ctrlCode, fid, dataBuf, isFSCtrl, filter, this, ctx); } else { throw new IOControlNotImplementedException(); } } return null; } /** * Registers a device context object for this instance * of the shared device. The same DeviceInterface implementation may be used for multiple * shares. In this base class, we initialize all desktop actions. * * @param ctx the context * @param serverConfig ServerConfigurationBean * @exception DeviceContextException */ public void registerContext(DeviceContext ctx) throws DeviceContextException { if (ctx instanceof AlfrescoContext) { // Enable a standalone state cache on the filesystem AlfrescoContext alfCtx = (AlfrescoContext) ctx; // Initialize the filesystem alfCtx.initialize(this); } } }