⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 networkplacedetailsform.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
/*
 *  SSL-Explorer
 *
 *  Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
 *
 *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
			
package com.sslexplorer.vfs.wizards.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import com.sslexplorer.core.BundleActionMessage;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.core.forms.AbstractResourceDetailsWizardForm;
import com.sslexplorer.policyframework.PolicyConstants;
import com.sslexplorer.policyframework.Resource;
import com.sslexplorer.policyframework.ResourceType;
import com.sslexplorer.vfs.utils.URI;
import com.sslexplorer.vfs.utils.URI.MalformedURIException;
import com.sslexplorer.vfs.webdav.DAVBundleActionMessageException;
import com.sslexplorer.vfs.webdav.DAVRepository;
import com.sslexplorer.wizard.AbstractWizardSequence;

public class NetworkPlaceDetailsForm extends AbstractResourceDetailsWizardForm {

    public final static String ATTR_URI = "uri";
    public final static String ATTR_READ_ONLY = "readOnly";
    public final static String ATTR_SHOW_HIDDEN = "showHidden";
    public final static String ATTR_ALLOW_RECURSIVE = "allowRecursive";
    public final static String ATTR_NO_DELETE = "noDelete";
    public final static String ATTR_SCHEME = "scheme";

    private String uri;
    private String scheme;
    private boolean readOnly;
    private boolean showHidden;
    private boolean allowResursive;
    private boolean noDelete;

    final static Log log = LogFactory.getLog(NetworkPlaceDetailsForm.class);

    public NetworkPlaceDetailsForm(boolean nextAvailable, boolean previousAvailable, String page, String focussedField,
                    boolean autoComplete, boolean finishAvailable, String pageName, String resourceBundle, String resourcePrefix,
                    int stepIndex, ResourceType resourceTypeForResourcePermissions) {
        super(nextAvailable, previousAvailable, page, focussedField, autoComplete, finishAvailable, pageName, resourceBundle,
                        resourcePrefix, stepIndex, resourceTypeForResourcePermissions);
    }

    public NetworkPlaceDetailsForm() {
        super(true, true, "/WEB-INF/jsp/content/vfs/networkingWizard/networkPlaceDetails.jspf", "uri", true, false,
                        "networkPlaceDetails", "vfs", "networkPlaceWizard.networkPlaceDetails", 2,
                        PolicyConstants.NETWORK_PLACE_RESOURCE_TYPE);
    }

    public void init(AbstractWizardSequence sequence, HttpServletRequest request) throws Exception {
        super.init(sequence, request);
        uri = (String) sequence.getAttribute(ATTR_URI, "");
        scheme = (String) sequence.getAttribute(ATTR_SCHEME, "");        
        readOnly = ((Boolean) sequence.getAttribute(ATTR_READ_ONLY, Boolean.FALSE)).booleanValue();
        showHidden = ((Boolean) sequence.getAttribute(ATTR_SHOW_HIDDEN, Boolean.FALSE)).booleanValue();
        allowResursive = ((Boolean) sequence.getAttribute(ATTR_ALLOW_RECURSIVE, Boolean.TRUE)).booleanValue();
        noDelete = ((Boolean) sequence.getAttribute(ATTR_NO_DELETE, Boolean.FALSE)).booleanValue();
    }

    public void apply(AbstractWizardSequence sequence) throws Exception {
        super.apply(sequence);
        sequence.putAttribute(ATTR_URI, uri);
        sequence.putAttribute(ATTR_SCHEME, scheme);
        sequence.putAttribute(ATTR_READ_ONLY, new Boolean(readOnly));
        sequence.putAttribute(ATTR_SHOW_HIDDEN, new Boolean(showHidden));
        sequence.putAttribute(ATTR_ALLOW_RECURSIVE, new Boolean(allowResursive));
        sequence.putAttribute(ATTR_NO_DELETE, new Boolean(noDelete));
    }

    public Resource getResourceByName(String name) throws Exception {
        return CoreServlet.getServlet().getSystemDatabase().getNetworkPlace(name);
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        if (getResourceName() != null && !isCancelling()) {
            ActionErrors errs = super.validate(mapping, request);
            if (errs == null)
                errs = new ActionErrors();
            AbstractWizardSequence seq = getWizardSequence(request);
            if (uri == null || uri.equals("")) {
                errs.add(Globals.ERROR_KEY, new BundleActionMessage(seq.getCurrentPageForm().getResourceBundle(), seq
                                .getCurrentPageForm().getResourcePrefix()
                                + ".error.noUri"));
            } else {
                try {

                    if (uri.length() == 0) {
                        errs.add(Globals.ERROR_KEY, new ActionMessage("createNetworkPlace.error.noUri", uri));
                    } else {
                        /**
                         * BPS - We now reformat the path when its used as we need
                         * to take into account replacement variables that will
                         * likely by user specific.
                         */
                        scheme = DAVRepository.getInstance().validateUserEnteredPath(uri);
                    }

                } catch (DAVBundleActionMessageException ex) {
                    errs.add(Globals.ERROR_KEY, ex.getBundleActionMessage());
                }
            }
            return errs;
        }
        return null;
    }

    public void parentResourcePermissionChanged(AbstractWizardSequence sequence) {
    }

    public boolean isAllowResursive() {
        return allowResursive;
    }

    public void setAllowResursive(boolean allowResursive) {
        this.allowResursive = allowResursive;
    }

    public boolean isNoDelete() {
        return noDelete;
    }

    public void setNoDelete(boolean noDelete) {
        this.noDelete = noDelete;
    }

    public boolean isReadOnly() {
        return readOnly;
    }

    public void setReadOnly(boolean readOnly) {
        this.readOnly = readOnly;
    }

    public boolean isShowHidden() {
        return showHidden;
    }

    public void setShowHidden(boolean showHidden) {
        this.showHidden = showHidden;
    }

    public void reset(ActionMapping mapping, HttpServletRequest request) {
        super.reset(mapping, request);
        this.showHidden = false;
        this.readOnly = false;
        this.allowResursive = false;
        this.noDelete = false;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -