001: /*
002: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
003: *
004: * This file is part of TransferCM.
005: *
006: * TransferCM is free software; you can redistribute it and/or modify it under the
007: * terms of the GNU General Public License as published by the Free Software
008: * Foundation; either version 2 of the License, or (at your option) any later
009: * version.
010: *
011: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
014: * details.
015: *
016: * You should have received a copy of the GNU General Public License along with
017: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018: * Fifth Floor, Boston, MA 02110-1301 USA
019: */
020:
021: package com.methodhead.res;
022:
023: import com.methodhead.auth.AuthUser;
024: import javax.servlet.http.HttpServletRequest;
025: import java.io.File;
026: import org.apache.struts.util.MessageResources;
027: import org.apache.struts.Globals;
028: import com.methodhead.util.OperationContext;
029:
030: public class DefaultResPolicy implements ResPolicy {
031:
032: // constructors /////////////////////////////////////////////////////////////
033:
034: // constants ////////////////////////////////////////////////////////////////
035:
036: // classes //////////////////////////////////////////////////////////////////
037:
038: // methods //////////////////////////////////////////////////////////////////
039:
040: public boolean isMappingAuthorized(AuthUser user, String path) {
041: return true;
042: }
043:
044: public FileManager newFileManager() {
045: return new FileManager();
046: }
047:
048: /**
049: * Initializes the file manager, adding the app context root.
050: */
051: public void initFileManager(HttpServletRequest request,
052: FileManager fileManager) {
053:
054: //
055: // get the webapp root directory
056: //
057: String path = request.getSession().getServletContext()
058: .getRealPath("");
059:
060: if (path == null)
061: throw new ResException(
062: "Couldn't get real path for webapp root.");
063:
064: File f = new File(path);
065:
066: //
067: // add the root directory using the name from message resources
068: //
069: MessageResources messages = (MessageResources) request
070: .getAttribute(Globals.MESSAGES_KEY);
071:
072: fileManager
073: .addDirectory(messages.getMessage("res.rootName"), f);
074: }
075:
076: public FileTree newFileTree() {
077: return new FileTree();
078: }
079:
080: public String isFileMoveAuthorized(OperationContext op) {
081: return null;
082: }
083:
084: public String isFileCopyAuthorized(OperationContext op) {
085: return null;
086: }
087:
088: public String isFileDeleteAuthorized(OperationContext op) {
089: return null;
090: }
091:
092: public String isFileEditAuthorized(OperationContext op) {
093: return null;
094: }
095:
096: public String isFileUnzipAuthorized(OperationContext op) {
097: return null;
098: }
099:
100: public String isFileListAuthorized(OperationContext op) {
101: return null;
102: }
103:
104: public String isFileManageAuthorized(OperationContext op) {
105: return null;
106: }
107:
108: public String isFileUploadFormAuthorized(OperationContext op) {
109: return null;
110: }
111:
112: public String isFileUploadAuthorized(OperationContext op) {
113: return null;
114: }
115:
116: public String isFileCreateFormAuthorized(OperationContext op) {
117: return null;
118: }
119:
120: public String isFileCreateAuthorized(OperationContext op) {
121: return null;
122: }
123:
124: // properties ///////////////////////////////////////////////////////////////
125:
126: // attributes ///////////////////////////////////////////////////////////////
127: }
|