WEB开发网
开发学院软件开发Java 开放源码 CMS 入门,第 3 部分: 构建定制存储 阅读

开放源码 CMS 入门,第 3 部分: 构建定制存储

 2010-04-16 00:00:00 来源:WEB开发网   
核心提示: SFTxFileContentStore 现在看上去应该如清单 2 所示:清单 2. SFTxFileContentStore + 覆盖/**CreatedonAug5,2005*/packageorg.apache.slide.store.txfile;/***@authorMichaelOl

SFTxFileContentStore 现在看上去应该如清单 2 所示:

清单 2. SFTxFileContentStore + 覆盖

/* 
 * Created on Aug 5, 2005 
 */ 
package org.apache.slide.store.txfile; 
 
/** 
 * @author Michael Oliver Created: Aug 5, 2005 Package: 
 *     org.apache.slide.store.txfile 
 */ 
public class SFTxFileContentStore extends TxFileContentStore { 
 
  public void storeRevisionContent(Uri uri,       
           NodeRevisionDescriptor revisionDescriptor, 
           NodeRevisionContent revisionContent) 
           throws ServiceAccessException, 
           RevisionNotFoundException { 
            
     String revisionUri = revisionUri = uri.toString() + "_" 
                + revisionDescriptor.getRevisionNumber(); 
     OutputStream os = null; 
     InputStream is = null; 
     try { 
      os = rm.writeResource(getActiveTxId(), revisionUri); 
      is = revisionContent.streamContent(); 
      if (is != null) { 
        long contentBytes = FileHelper.copy(is, os); 
        long contentLength = 
          revisionDescriptor.getContentLength(); 
        revisionDescriptor.setContentLength(contentBytes); 
        if (contentLength != -1 
          && contentBytes != contentLength) { 
          rm.deleteResource(getActiveTxId(), revisionUri); 
          throwInternalError( 
            "Content length does not match expected"); 
        } 
      } 
    } catch (IOException e) { 
      throwInternalError(e, uri.toString()); 
    } catch (ResourceManagerException e) { 
      if (e.getStatus() == 
        ResourceManagerException.ERR_NO_SUCH_RESOURCE) { 
        throw new RevisionNotFoundException(uri.toString(), 
                     revisionDescriptor.getRevisionNumber()); 
      } else { 
         throwInternalError(e, uri.toString()); 
      }     
    } finally { 
      try { 
        if (os != null) { 
          os.close(); 
        } 
      } catch (IOException e) { 
      }       
      try { 
        if (is != null) { 
          is.close(); 
        } 
      } catch (IOException e) { 
      } 
    }   
  } 
} 

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:开放 源码 CMS

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接