Java Doc for SampleImplAccess.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » sample » 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.sample.impl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.sakaiproject.sample.impl.SampleImplAccess

SampleImplAccess
public class SampleImplAccess implements EntityProducer(Code)

SampleImplAccess is a service implementation that demonstrates how to store application-private content in ContentHosting, and to make these available from the Access servlet under the application's control. This code would usually be found in a service implementation of the application's service API. In this example, there is no API, but there is still an implementation. For a real application, we would add the API implementation code to this code.

The content is stored in ContentHosting's "private" space (/private/...), in a folder named for this application. The name choosen for example this is "sampleAccess". In our init() method, we make sure that this space exists. Note the use of a SecurityAdvisor there to assure that the ContentHostingService calls pass security.

A SecurityAdvisor is code you provide, related only to processing of the current request (i.e. code running on the current thread). When there is a security advisor, any normal security calls are first sent to the advisor code. That code can allow the access, deny the access, or say nothing about the access, passing the decision on to any other SecurityAdvisors in a stack, or to the normal security processing code.

You use a security advisor when you can establish that some operation should be allowed to happen, but you are going to collaborate with some other service to make the action happen, and the other service might not know that it is ok to perform the calls you are about to make. The natural security it would invoke might not be proper for your application. So you place a security advisor on the stack and take over security for the duration of your request processing.

In a normal application, the end-user's HTTP interaction would result in content to save in the application's ContentHosting area, either from form fields or from a file upload. Once the body bytes are created, the application would save these in some named and located file in ContentHosting. We emulate this and show how to do it in the init() method, creating our one hosted item.

In a normal application, the HTML sent to the end-user would include URL references to the files in our private ContentHosting space. These might be IMG tags (to embed images), or FRAME or IFRAME addresses, or anything else HTML allows. We ask the ContentResources for their URLs so we can form our HTML responses.

When the request comes back from the browser to the URL of our ContentHosting items, the Access servlet fields the request. We register as a EntityProducer in our init() method so that Access will allow us to handle the heart of these requests.

Note that we also declare our implementation class as implementing EntityProducer, which is needed to register. This is best done in the implementation class instead of the API, since nobody using your API services really need to know you are an EntityProducer.

The way that we know that the URL is for us to handle is because we set the ContentResource to have a URL prefix, our own special one, that we recognize. While an application can use any form of URL after this it wants, it is convienent to just prefix the ContentHosting's natural Access URL with our special code, leaving the rest as a ContentHosting entity reference. We do that in this example.

The key thing we are responsible for is determining if the access is allowed. The natural security set on our private area in ContentHosting assures that nobody has any access at all to the items there. If we decide to grant access, we setup a security advisor so that ContentHosting's security check is satisfied.

The most common way to check security is to encode the context id into the URL, and into the ContentHosting collection structure of your private content area. Then you can access the context directly from the URL and do a security check. This is what we do in this example.

An alternate way to handle security is to store meta-data about each item in your application database. Then you need to encode enough information in the URL to read the item's meta-data. From the meta-data, you can get the ContentHosting reference and security information. We do not show this in this example.

If you deploy this sample, you will have a working Access servlet / ContentHosting using application that serves up a single file to anyone authorized to see it. You can test this by entering this URL:

  • http:///access/sampleAccess/content/private/sampleAccess/mercury/test.txt

Note that there are some methods needed for EntityProducer that we don't use here. The Entity Bus will be later enhanced to make this a cleaner process.

The key methods are: parseEntityReference...



Field Summary
final static  StringAPPLICATION_ID
     The type string for this application: should not change over time as it may be stored in various parts of persistent entities.
final static  StringREFERENCE_ROOT
    
final static  StringREFERENCE_ROOT_NAME
     This string starts the references to resources in this service.
final protected static  intSTREAM_BUFFER_SIZE
     The chunk size used when streaming (100k).
protected  ContentHostingServicem_contentHostingService
    
protected  EntityManagerm_entityManager
    
protected  SecurityServicem_securityService
    
protected  ServerConfigurationServicem_serverConfigurationService
     Dependency: ServerConfigurationService.
protected  SessionManagerm_sessionManager
    


Method Summary
public  Stringarchive(String siteId, Document doc, Stack stack, String archivePath, List attachments)
    
protected  voidassureCollection(String container, String name)
     Assure that a collection with this name exists in the container collection: create it if it is missing.
protected  booleancheckSecurity(Reference ref)
     Check security for this entity.
Parameters:
  ref - The Reference to the entity.
public  voiddestroy()
     Returns to uninitialized state.
public  EntitygetEntity(Reference ref)
    
public  CollectiongetEntityAuthzGroups(Reference ref, String userId)
    
public  StringgetEntityDescription(Reference ref)
    
public  ResourcePropertiesgetEntityResourceProperties(Reference ref)
    
public  StringgetEntityUrl(Reference ref)
    
public  HttpAccessgetHttpAccess()
    
public  StringgetLabel()
    
public  voidinit()
     Final initialization, once all dependencies are set.
public  Stringmerge(String siteId, Element root, String archivePath, String fromSiteId, Map attachmentNames, Map userIdTrans, Set userListAllowImport)
    
public  booleanparseEntityReference(String reference, Reference ref)
    
protected  voidpopAdvisor()
     Remove our security advisor.
protected  voidpushAdvisor()
     Setup a security advisor.
public  voidsetContentHostingService(ContentHostingService service)
     Dependency: ContentHostingService.
public  voidsetEntityManager(EntityManager service)
     Dependency: EntityManager.
public  voidsetSecurityService(SecurityService service)
     Dependency: SecurityService.
public  voidsetServerConfigurationService(ServerConfigurationService service)
     Dependency: ServerConfigurationService.
public  voidsetSessionManager(SessionManager service)
     Dependency: SessionManager.
public  booleanwillArchiveMerge()
    

Field Detail
APPLICATION_ID
final static String APPLICATION_ID(Code)
The type string for this application: should not change over time as it may be stored in various parts of persistent entities.



REFERENCE_ROOT
final static String REFERENCE_ROOT(Code)



REFERENCE_ROOT_NAME
final static String REFERENCE_ROOT_NAME(Code)
This string starts the references to resources in this service.



STREAM_BUFFER_SIZE
final protected static int STREAM_BUFFER_SIZE(Code)
The chunk size used when streaming (100k).



m_contentHostingService
protected ContentHostingService m_contentHostingService(Code)
Dependency: ContentHostingService



m_entityManager
protected EntityManager m_entityManager(Code)
Dependency: EntityManager



m_securityService
protected SecurityService m_securityService(Code)
Dependency: SecurityService



m_serverConfigurationService
protected ServerConfigurationService m_serverConfigurationService(Code)
Dependency: ServerConfigurationService.



m_sessionManager
protected SessionManager m_sessionManager(Code)
Dependency: SessionManager





Method Detail
archive
public String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments)(Code)



assureCollection
protected void assureCollection(String container, String name)(Code)
Assure that a collection with this name exists in the container collection: create it if it is missing.
Parameters:
  container - The full path of the container collection.
Parameters:
  name - The collection name to check and create.



checkSecurity
protected boolean checkSecurity(Reference ref)(Code)
Check security for this entity.
Parameters:
  ref - The Reference to the entity. true if allowed, false if not.



destroy
public void destroy()(Code)
Returns to uninitialized state.



getEntity
public Entity getEntity(Reference ref)(Code)



getEntityAuthzGroups
public Collection getEntityAuthzGroups(Reference ref, String userId)(Code)



getEntityDescription
public String getEntityDescription(Reference ref)(Code)



getEntityResourceProperties
public ResourceProperties getEntityResourceProperties(Reference ref)(Code)



getEntityUrl
public String getEntityUrl(Reference ref)(Code)



getHttpAccess
public HttpAccess getHttpAccess()(Code)



getLabel
public String getLabel()(Code)



init
public void init()(Code)
Final initialization, once all dependencies are set.



merge
public String merge(String siteId, Element root, String archivePath, String fromSiteId, Map attachmentNames, Map userIdTrans, Set userListAllowImport)(Code)



parseEntityReference
public boolean parseEntityReference(String reference, Reference ref)(Code)



popAdvisor
protected void popAdvisor()(Code)
Remove our security advisor.



pushAdvisor
protected void pushAdvisor()(Code)
Setup a security advisor.



setContentHostingService
public void setContentHostingService(ContentHostingService service)(Code)
Dependency: ContentHostingService.
Parameters:
  service - The ContentHostingService.



setEntityManager
public void setEntityManager(EntityManager service)(Code)
Dependency: EntityManager.
Parameters:
  service - The EntityManager.



setSecurityService
public void setSecurityService(SecurityService service)(Code)
Dependency: SecurityService.
Parameters:
  service - The SecurityService.



setServerConfigurationService
public void setServerConfigurationService(ServerConfigurationService service)(Code)
Dependency: ServerConfigurationService.
Parameters:
  service - The ServerConfigurationService.



setSessionManager
public void setSessionManager(SessionManager service)(Code)
Dependency: SessionManager.
Parameters:
  service - The SessionManager.



willArchiveMerge
public boolean willArchiveMerge()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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