Source Code Cross Referenced for BaseExtensionResourceFilter.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » content » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.content.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/content/tags/sakai_2-4-1/content-impl/impl/src/java/org/sakaiproject/content/impl/BaseExtensionResourceFilter.java $
003:         * $Id: BaseExtensionResourceFilter.java 22558 2007-03-13 19:16:50Z jimeng@umich.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2005, 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.content.impl;
021:
022:        import java.util.Iterator;
023:        import java.util.List;
024:
025:        import org.sakaiproject.content.api.ContentResource;
026:        import org.sakaiproject.content.api.ContentResourceFilter;
027:        import org.sakaiproject.content.api.ResourceToolAction;
028:        import org.sakaiproject.entity.api.ResourceProperties;
029:
030:        /**
031:         * This class implements the typical mime type and extension filter. This will be a registered bean with the component manager that application components can extend to control the list of mime types and the list of acceptable extentions.
032:         */
033:        public class BaseExtensionResourceFilter implements 
034:                ContentResourceFilter {
035:            private boolean viewAll = true;
036:
037:            private List mimeTypes;
038:
039:            private List acceptedExtensions;
040:
041:            public boolean allowSelect(ContentResource resource) {
042:                // on a new resource, it seems that getContentType is more reliable than accessing that value through properties.
043:                String mimeType = resource.getContentType(); // .getProperties().getProperty(ResourceProperties.PROP_CONTENT_TYPE);
044:                String[] parts = mimeType.split("/");
045:                String primaryType = parts[0];
046:
047:                if (!getMimeTypes().isEmpty()
048:                        && !getMimeTypes().contains(primaryType)
049:                        && !getMimeTypes().contains(mimeType)) {
050:                    return false;
051:                }
052:
053:                String filePath = resource.getUrl();
054:
055:                if (getAcceptedExtensions() != null) {
056:                    // check extension
057:                    for (Iterator i = getAcceptedExtensions().iterator(); i
058:                            .hasNext();) {
059:                        if (filePath.endsWith("."
060:                                + i.next().toString().toLowerCase())) {
061:                            return true;
062:                        }
063:                    }
064:
065:                    return false;
066:                } else {
067:                    return true;
068:                }
069:            }
070:
071:            public boolean allowView(ContentResource contentResource) {
072:                if (isViewAll()) {
073:                    return true;
074:                }
075:
076:                return allowSelect(contentResource);
077:            }
078:
079:            public List getMimeTypes() {
080:                return mimeTypes;
081:            }
082:
083:            /**
084:             * The list of mime types to allow. The passed in content resource will be tested to see if the resouce's primary mime type is included in the list (ie "text" for "text/xml") and then the whole mime type will be tested for existence in the list.
085:             * 
086:             * @param mimeTypes
087:             */
088:            public void setMimeTypes(List mimeTypes) {
089:                this .mimeTypes = mimeTypes;
090:            }
091:
092:            public boolean isViewAll() {
093:                return viewAll;
094:            }
095:
096:            /**
097:             * boolean to indicate if all resources should be viewable. If this is false, then the viewable resources will be based on the mime types and extention set in the other properties.
098:             * 
099:             * @param viewAll
100:             */
101:            public void setViewAll(boolean viewAll) {
102:                this .viewAll = viewAll;
103:            }
104:
105:            public List getAcceptedExtensions() {
106:                return acceptedExtensions;
107:            }
108:
109:            /**
110:             * List of accepted file name extensions. If this list is null, all extensions are acceptable.
111:             * 
112:             * @param acceptedExtensions
113:             */
114:            public void setAcceptedExtensions(List acceptedExtensions) {
115:                this .acceptedExtensions = acceptedExtensions;
116:            }
117:
118:            /**
119:             * This method controls which "create" actions are allowed for ContentCollections.  
120:             * Filtering "create" actions based on mimetype and extension is not yet
121:             * supported very well, so this may require tweaking over time.
122:             * @param actions A collection of actions to test
123:             * @return A list of actions that should be shown in the filepicker
124:             * 	for each collection.
125:             */
126:            public List<ResourceToolAction> filterAllowedActions(
127:                    List<ResourceToolAction> actions) {
128:                // suggest checking for html, text, upload, etc and treating each separately
129:                return actions;
130:            }
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.