alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 *
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 *
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.javacvs;

import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.Set;

import org.openide.filesystems.AbstractFileSystem;
import org.openide.filesystems.FileSystem;

/**
 * An almost empty copy of JavaCvsFileSystem from javacvs module that is used
 * just for deserialization purpose. It's needed in order to successfully
 * deserialize NbJavaCvsFileSystem class. That class is then converted
 * to CommandLineVcsFileSystem with CVS profile.
 *
 * @author Martin Entlicher
 */
public class JavaCvsFileSystem extends AbstractFileSystem    {
    static final long serialVersionUID = -5990750897426301780L;
    
    /** Identifier of the property relative mountpoint
     */    
    public static final String PROP_REL_MOUNT = "relMount"; //NOI18N
    /** Identifier of the property working directory
     */    
    public static final String PROP_WORKING_DIR = "workingDir"; //NOI18N
    /** Identifier of the property off-line
     */    
    public static final String PROP_OFF_LINE = "offLine"; //NOI18N
    /** Identifier of the property auto-refresh
     */    
    public static final String PROP_AUTO_REFRESH = "autoRefresh"; //NOI18N
    /** Identifier of the property zipped transfer
     */    
    public static final String PROP_ZIPPED_TRANSFER = "ZippedTransfer"; //NOI18N
    /** Identifier of the property hide shadow files.
     */    
    public static final String PROP_HIDE_SHADOW_FILES  = "hideShadowFiles"; // NOI18N
    /** Identifier of the property cvs ignore list.
     */    
    public static final String PROP_CVS_IGNORE_LIST = "cvsIgnoreList"; //NOI18N

    public static final String PROP_FS_INGORED_FILES = "fsIgnoredFiles"; //NOI18N
    
    public static final String PROP_CREATE_BACKUPS = "createBackups"; //NOI18N
    
    public static final String PROP_CVS_SERVER_TYPE = "cvsServerType"; //NOI18N
    public static final String PROP_CVS_SERVER_NAME = "cvsServerName"; //NOI18N
    public static final String PROP_CVS_USER_NAME   = "cvsUserName"; //NOI18N
    public static final String PROP_CVS_REPOSITORY  = "cvsRepository"; //NOI18N
    
    
    /** Identifier of the property CvsPort.
     *
     */    
    public static final String PROP_CVS_PORT = "cvsPort"; //NOI18N

    public static final int STANDARD_PORT = 2401;    
    /** autoRefresh property's constant - never do auto refresh.
     */    
    public static final int AUTO_NONE = 0;
    /** autoRefresh property's constant - do refresh on newly opened directories.
     */    
    public static final int AUTO_SIMPLE = 1;
    /** autoRefresh property's constant - run recursive refresh upon mounting the fs.
     */    
    public static final int AUTO_RECURS_ONCE = 2;
    /** autoRefresh property's constant - on each start, run recursive refresh for the filesystem.
     */    
    public static final int AUTO_RECURS_EVERYTIME = 3;
    /**
     *combines AUTO_RECURS_ONCE and AUTO_RECURS_EVERYTIME
     */
    public static final int AUTO_MOUNT_AND_RESTART = 4;
    
    /** Server type constant - :server: access method
     */    
    public static final int TYPE_SERVER = 0;
    /** Server type constant - :pserver: access method
     */    
    public static final int TYPE_PSERVER = 1;
    
    private static final String[] TYPE_NAMES = { "server", "pserver"}; //NOI18N
    
    protected static final int REFRESH_TIME = 0; // Disabled by default (see #28352).

    protected int refreshTimeToSet = REFRESH_TIME;
    
    private File rootFile = null;
    private boolean readOnly;
    
    private boolean isRootSet;
    private long cacheId=0;
    
    // properties
    private java.io.File workingDir = null;
    private String relMount = ""; //NOI18N
    private boolean offLine = false;
    private int autoRefresh = 0;
    private boolean zippedTransfer = true;
    private boolean hideShadowFiles = false;
    /** regexp of ignorable children*/
    protected String fsIgnoredFiles = "~$|^\\.#"; //NOI18N
    
    
//    private transient boolean runningRefreshSemaphore = false;
    private String repository = ""; //NOI18N
    private String serverName = ""; //NOI18N 
    private int serverType = 1;
    private String userName = ""; //NOI18N
    protected Status status;
    
    private File homeDirectory = new File(System.getProperty("user.home")); //NOI18N
    
    private org.openide.ErrorManager errorManager;
    
//    protected transient GlobalOptions globalOptions;
    
    /** Holds value of property cvsPort. */
    private int cvsPort = STANDARD_PORT;    

    /** Holds value of property createBackups. */
    private boolean createBackups = true;
    
    
    /** 
     * Creates a new instance of JavaCvsFileSystem.
     */
    
    public JavaCvsFileSystem() {
    }
    
    //-- cvs root string is stored in each CVS directory, also used for authentification
    /*
    public String getCvsRootString() {
        StringBuffer toReturn = new StringBuffer(":"); //NOI18N
        toReturn.append(getCvsServerTypeName());
        toReturn.append(':');
        toReturn.append(getCvsUserName());
        toReturn.append('@');
        toReturn.append(getCvsServerName());
        toReturn.append(':');
        if (getCvsPort() != PServerConnection.DEFAULT_PORT) {
            toReturn.append(""+getCvsPort());
        }        
        toReturn.append(getCvsRepository());
        return toReturn.toString();
    }
     */
    
    /**
     * Returns what should be displayed to the user as the filesystem name.
     * Overrides AbstractFileSystem method.
     * @return name of the filesystem.
     */
    public String getDisplayName () {
        //return NbBundle.getMessage (JavaCvsFileSystem.class, "JavaCvsFileSystem.validFilesystemLabel", rootFile.toString ()); //NOI18N
        return "JavaCVSFileSystem"; // NOI18N
    }
    
    // Bean getter.
    /** Returns the read-only property.
     */
    public boolean isReadOnly () {
        return readOnly;
    }
    
    // Bean getter.
    /** Returns the working directory property.
     */    
    public java.io.File getWorkingDir() {
        return workingDir;
    }
    
    // Bean getter.
    /** Returns the relative mountpoint. It is a relative part to the filesystem root from the working directory.
     */    
    public String getRelMount () {
        if (relMount == null) return ""; //NOI18N
        return relMount;
    }
    
    //Bean getter
    public boolean isOffLine() {
        return offLine;
    }
    
    //Bean getter
    public int getAutoRefresh() {
        return autoRefresh;
    }
    
    public String getFsIgnoredFiles () {
        return fsIgnoredFiles;
    }
    
    public String getCvsRepository() {
        return repository;
    }

    public String getCvsServerTypeName() {
        if ((serverType >= 0) && (serverType < TYPE_NAMES.length)) {
            return TYPE_NAMES[serverType];
        }
        return ""; //NOI18N
    }
    
    public String getCvsServerName() {
        return serverName;
    }
    
    public String getCvsUserName() {
        return userName;
    }
    
    /** Returns a port that the pserver access method uses for connection.
     *
     * @return Value of property cvsPort.
     */
    public int getCvsPort() {
        return cvsPort;
    }
    
    /** Getter for property createBackups.
     * @return Value of property createBackups.
     */
    public boolean isCreateBackups() {
        return this.createBackups;
    }
    
    /*                                              
    //------------------------------------------------------------------------------
    // ---------------- serialization stuff
    //-------------------------------------------
    private void readObject(ObjectInputStream in) throws
    ClassNotFoundException, IOException, NotActiveException{
        // cache is transient
        //        cache = new CvsFsCache(this);
        
        in.defaultReadObject();
        if (cvsPort == 0) {
            setCvsPort(STANDARD_PORT);
        }
    }
    
    
    //-------------------------------------------
    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
    }
     */
    
    // Dummy implementation of serialized interfaces so that the class can be
    // successfully deserialized.
    
    public class MyStatus implements Status, Serializable {
        
        static final long serialVersionUID = 7525827069203814770L;
        
        public Image annotateIcon(Image icon, int iconType, Set files) {
            return null;
        }
        
        public String annotateName (String name, Set files) {
            return null;
        }
        
    }
    
    protected class InfoImpl implements AbstractFileSystem.Info {

        public InfoImpl () {}
        
        static final long serialVersionUID = -627867218820299311L;
        
        public boolean folder (String name) {
            return false;
        }
        public java.util.Date lastModified (String name) {
            return null;
        }
        public boolean readOnly (String name) {
            return false;
        }
        // Some filesystems, e.g. based on HTTP, could have better heuristics for this:
        public String mimeType (String name) {
            return "content/unknown"; // NOI18N
        }
        public long size (String name) {
            return 0L;
        }
        public java.io.InputStream inputStream (String name) throws java.io.FileNotFoundException {
            return null;
        }
        public java.io.OutputStream outputStream (String name) throws IOException {
            return null;
        }
        // AbstractFileSystem handles locking the file to the rest of the IDE.
        // This only means that you should define how the file should be locked
        // to the outside world--perhaps it does not need to be.
        public void lock (String name) throws IOException {
        }
        public void unlock (String name) {
            // Nothing special needed to unlock a file to the outside world.
        }
        public void markUnimportant (String name) {
        }
        
    }
    
    public class ChangeImpl implements AbstractFileSystem.Change {
        
        static final long serialVersionUID = 1647280700071658302L;
        
        public void createFolder (String name) throws IOException {
        }
        
        private boolean createRecursiveFolder (File f) {
            return false;
        }
        
        public void createData (String name) throws IOException {
        }
        
        public void rename (String oldName, String newName) throws IOException {
        }
        
        public void delete (String name) throws IOException {
        }
        
        private boolean deleteFile (File file) {
            return false;
        }
        
    }
    
    // Operation which provides the directory structure.
    public class ListImpl implements AbstractFileSystem.List {
        
        static final long serialVersionUID = -102893327017356802L;
        
        public String[] children (String name) {
            return null;
        }
    }
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.