Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Alfresco study presentation 38th customize How-To WebDAV

3,721 views

Published on

Alfresco勉強会#38で発表した資料です。どのようにAlfrescoをカスタマイズすればいいのか実際のWebDAVへの機能追加を例に説明しています。

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Alfresco study presentation 38th customize How-To WebDAV

  1. 1. WebDAV Home
  2. 2. Alfresco
  3. 3. Alfresco WebScript Alfresco Solr
  4. 4. Alfresco SDK
  5. 5. grep find
  6. 6. : WebDAV <servlet> <servlet-name>WebDAV</servlet-name> <servlet-class>org.alfresco.repo.webdav.WebDAVServlet</ servlet-class> <load-on-startup>5</load-on-startup> </servlet>
  7. 7. : WebDAV m_davMethods = new Hashtable<String, Class<? extends WebDAVMethod>>(); m_davMethods.put(WebDAV.METHOD_PROPFIND, PropFindMethod.class); m_davMethods.put(WebDAV.METHOD_PROPPATCH, PropPatchMethod.class); m_davMethods.put(WebDAV.METHOD_COPY, CopyMethod.class); m_davMethods.put(WebDAV.METHOD_DELETE, DeleteMethod.class); m_davMethods.put(WebDAV.METHOD_GET, GetMethod.class); m_davMethods.put(WebDAV.METHOD_HEAD, HeadMethod.class); m_davMethods.put(WebDAV.METHOD_LOCK, LockMethod.class); m_davMethods.put(WebDAV.METHOD_MKCOL, MkcolMethod.class); m_davMethods.put(WebDAV.METHOD_MOVE, MoveMethod.class); m_davMethods.put(WebDAV.METHOD_OPTIONS, OptionsMethod.class); m_davMethods.put(WebDAV.METHOD_POST, PostMethod.class); m_davMethods.put(WebDAV.METHOD_PUT, PutMethod.class); m_davMethods.put(WebDAV.METHOD_UNLOCK, UnlockMethod.class);
  8. 8. : WebDAV protected void executeImpl() throws WebDAVServerException, Exception { FileFolderService fileFolderService = getFileFolderService(); NodeRef rootNodeRef = getRootNodeRef(); String path = getPath(); ... FileInfo nodeInfo = null; try { nodeInfo = getDAVHelper().getNodeForPath(rootNodeRef, path); }
  9. 9. : WebDAV WebDAVServlet GetMethod DeleteMethod … WebDAVMethod WebDAVHelper getDAVHelper()
  10. 10. Bean <bean id="webdav.initParams" class="org.alfresco.repo.webdav.WebDAVServlet$WebDAVInitParameters"> <property name="enabled" value="${system.webdav.servlet.enabled}" /> <property name="storeName" value="${system.webdav.storeName}" /> <property name="rootPath" value="${system.webdav.rootPath}" /> </bean> … <bean id="webDAVHelper" class="org.alfresco.repo.webdav.WebDAVHelper" parent="baseWebDAVHelper" /> remote-api-context.xml
  11. 11. public class WebDAVHelper extends org.alfresco.repo.webdav.WebDAVHelper { public List<FileInfo> getChildren(FileInfo fileInfo) throws WebDAVServerException { List<FileInfo> children = this.getFileFolderService().list(fileInfo.getNodeRef()); if ( this.rootNodeRefs.contains(fileInfo.getNodeRef())) { YourHomeFileInfo yourHome = new YourHomeFileInfo(); children.add(yourHome); } return children; } YourHome
  12. 12. public FileInfo getNodeForPath(NodeRef rootNodeRef, String path) throws FileNotFoundException { … if ( path.startsWith("/" + YOUR_HOME)) { // resolve your your name String userName = this.getAuthenticationService().getCurrentUserName(); NodeRef person = this.personService.getPerson(userName); NodeRef homeFolderRef = (NodeRef)this.getNodeService().getProperty(person, ContentModel.PROP_HOMEFOLDER); if ( homeFolderRef != null ) { FileInfo userHome = this.getFileFolderService().getFileInfo(homeFolderRef); String pathLeft = path.replace("/" + YOUR_HOME, ""); if ( pathLeft.length() > 0 ) { List<String> splitPath = splitAllPaths(pathLeft); return this.getFileFolderService().resolveNamePath(userHome.getNodeRef(), splitPath); } else { return this.getFileFolderService().getFileInfo(homeFolderRef); } } YourHome
  13. 13. <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="webDAVHelper" class="jp.aegif.study.alfresco.webdav2.WebDAVHelper" parent="baseWebDAVHelper" > <property name="personService" ref="PersonService" /> </bean> </beans> bean custom-wedav—context.xml Alfresco
  14. 14. WebDAV

×