BlankEditor.java :  » Content-Management-System » harmonise » org » openharmonise » him » editors » Java Open Source

Java Open Source » Content Management System » harmonise 
harmonise » org » openharmonise » him » editors » BlankEditor.java
/*
 * The contents of this file are subject to the 
 * Mozilla Public License Version 1.1 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
 * See the License for the specific language governing rights and 
 * limitations under the License.
 *
 * The Initial Developer of the Original Code is Simulacra Media Ltd.
 * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
 *
 * All Rights Reserved.
 *
 * Contributor(s):
 */
package org.openharmonise.him.editors;

import org.openharmonise.vfs.*;
import org.openharmonise.vfs.status.*;


/**
 * Editor that does nothing. Editors that wish to safely implement only
 * part of the editor interface can extend this class.
 * 
 * @author Matthew Large
 * @version $Revision: 1.1 $
 *
 */
public class BlankEditor implements Editor {

  private boolean m_bResourceCreated = false;

  /**
   * 
   */
  public BlankEditor() {
    super();
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.editors.Editor#open(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
   */
  public PathStatusWrapper open(String sPath, AbstractVirtualFileSystem vfs) {
    return new PathStatusWrapper(null, new VFSStatus());
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
   */
  public PathStatusWrapper createNew(String sPath, AbstractVirtualFileSystem vfs) {
    ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(null, new VFSStatus());
    
    try {
      VirtualFile vfFile = new VirtualFile(sPath);
      vfFile.setContent(null);
      statusWrapper = vfs.addVirtualFile(sPath, vfFile);
      if(statusWrapper.getStatus().isOK()) {
        this.m_bResourceCreated = true;  
      }  
    } catch(Exception e) {
      e.printStackTrace();
    }
    return new PathStatusWrapper(null, statusWrapper.getStatus());
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.editors.Editor#discardChanges(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
   */
  public StatusData discardChanges(String sPath, AbstractVirtualFileSystem vfs) {
    return new VFSStatus();
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.editors.Editor#export(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
   */
  public StatusData export(String sPath, AbstractVirtualFileSystem vfs) {
    return new VFSStatus();
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.editors.Editor#createNew(java.lang.String, byte[], com.simulacramedia.vfs.AbstractVirtualFileSystem)
   */
  public PathStatusWrapper createNew(String sPath, byte[] content, AbstractVirtualFileSystem vfs) {
    ResourceStatusWrapper statusWrapper = new ResourceStatusWrapper(null, new VFSStatus());
    
    try {
      VirtualFile vfFile = new VirtualFile(sPath);
      vfFile.setContent(content);
      statusWrapper = vfs.addVirtualFile(sPath, vfFile); 
      if(statusWrapper.getStatus().isOK()) {
        this.m_bResourceCreated = true;  
      }  
    } catch(Exception e) {
      e.printStackTrace();
    }
    
    return new PathStatusWrapper(null, statusWrapper.getStatus());
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.editors.Editor#hasResourceBeenCreated()
   */
  public boolean hasResourceBeenCreated() {
    return this.m_bResourceCreated;
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.editors.Editor#preview(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
   */
  public PathStatusWrapper preview(String sPath, AbstractVirtualFileSystem vfs) {
    return new PathStatusWrapper(null, new VFSStatus());
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.editors.Editor#upload(java.lang.String, com.simulacramedia.vfs.AbstractVirtualFileSystem)
   */
  public PathStatusWrapper upload(String path, AbstractVirtualFileSystem vfs) {
    return new PathStatusWrapper(null, new VFSStatus());
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.