Eugeny, My advice would be not to change more than you need to change; Extend vs. create; and observe and modify instead of trying to build from scratch; take small steps from one known state to the next; and don't "fix" something that isn't broken.
If you extend the Tx stores instead of starting from scratch, you will find you can change behaviors where you need to and leave everything else alone. I do not understand why you think you need to change the content /files root, you are making more work for yourself. If I create a web folder to http://localhost:8080/slide/files/mytargetroot/ where "mytargetroot" is your root directory/folder/collection then your web folder won't show anything above it and /files will be hidden. All you will see in that web folder are the contents of mytargetroot. Michael Oliver CTO Alarius Systems LLC 6800 E. Lake Mead Blvd, #1096 Las Vegas, NV 89156 Phone:(702)953-8949 Fax:(702)974-0341 -----Original Message----- From: Eugeny N Dzhurinsky [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 15, 2006 8:50 AM To: [email protected] Subject: Virtual FS store implementation for WCK Sorry for asking so many dumb questions here, but I'm lost. I'm trying to create virtual file system with no ability to create folders and list resources, but with ability to read and write to predefined resources. Mapping between allowed resources and files on disk located in Map accessed by MappingSingleton (it's nothing except synchronized hashmap with disk file storage at the backend) I created BasicWebdavStore implementation: package webdav.store; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.security.Principal; import java.util.Date; import java.util.Hashtable; import java.util.Map; import org.apache.commons.transaction.util.LoggerFacade; import org.apache.slide.common.Service; import org.apache.slide.common.ServiceAccessException; import org.apache.slide.common.ServiceParameterErrorException; import org.apache.slide.common.ServiceParameterMissingException; import org.apache.slide.lock.ObjectLockedException; import org.apache.slide.security.AccessDeniedException; import org.apache.slide.security.UnauthenticatedException; import org.apache.slide.simple.store.BasicWebdavStore; import org.apache.slide.structure.ObjectAlreadyExistsException; import org.apache.slide.structure.ObjectNotFoundException; /** * Virtual filesystem store */ public class VirtualFileSystemStoreImpl implements BasicWebdavStore { public static final String MAPPING = "mapping"; private static final String FILES = "/files"; private static LoggerFacade logger; /** * Mapping instance */ private MappingSingleton mappings; /** * @see org.apache.slide.simple.store.BasicWebdavStore#begin(org.apache.slide.common .Service, * java.security.Principal, java.lang.Object, * org.apache.commons.transaction.util.LoggerFacade, * java.util.Hashtable) */ public void begin(Service service, Principal principal, Object connection, LoggerFacade logger, Hashtable parameters) throws ServiceAccessException, ServiceParameterErrorException, ServiceParameterMissingException { String mapping = (String) parameters.get(MAPPING); if (mapping == null) throw new ServiceParameterMissingException(service, "Parameter " + MAPPING + " missing"); mappings = MappingSingleton.getInstance(mapping); this.logger = logger; } /** * @see org.apache.slide.simple.store.BasicWebdavStore#checkAuthentication() */ public void checkAuthentication() throws UnauthenticatedException { } /** * @see org.apache.slide.simple.store.BasicWebdavStore#commit() */ public void commit() throws ServiceAccessException { } /** * @see org.apache.slide.simple.store.BasicWebdavStore#createFolder(java.lang.String ) */ public void createFolder(String folderUri) throws ServiceAccessException, AccessDeniedException, ObjectAlreadyExistsException, ObjectLockedException { logger.logInfo("Creating folder " + folderUri); throw new AccessDeniedException("", "", ""); } /** * @see org.apache.slide.simple.store.BasicWebdavStore#createResource(java.lang.Stri ng) */ public void createResource(String resourceUri) throws ServiceAccessException, AccessDeniedException, ObjectAlreadyExistsException, ObjectLockedException { throw new AccessDeniedException("", "", ""); } /** * @see org.apache.slide.simple.store.BasicWebdavStore#getChildrenNames(java.lang.St ring) */ public String[] getChildrenNames(String folderUri) throws ServiceAccessException, AccessDeniedException, ObjectNotFoundException, ObjectLockedException { // don't allow to view contents of directory return null; } /** * @see org.apache.slide.simple.store.BasicWebdavStore#getCreationDate(java.lang.Str ing) */ public Date getCreationDate(String uri) throws ServiceAccessException, AccessDeniedException, ObjectNotFoundException, ObjectLockedException { Map map = mappings.loadMapping(); Date modified = null; if (map.containsKey(uri)) { String path = (String) map.get(uri); File file = new File(path); modified = new Date(file.lastModified()); } return modified; } /** * @see org.apache.slide.simple.store.BasicWebdavStore#getLastModified(java.lang.Str ing) */ public Date getLastModified(String uri) throws ServiceAccessException, AccessDeniedException, ObjectNotFoundException, ObjectLockedException { return getCreationDate(uri); } /** * @see org.apache.slide.simple.store.BasicWebdavStore#getResourceContent(java.lang. String) */ public InputStream getResourceContent(String resourceUri) throws ServiceAccessException, AccessDeniedException, ObjectNotFoundException, ObjectLockedException { Map map = mappings.loadMapping(); if (map.containsKey(resourceUri)) { String path = (String) map.get(resourceUri); try { FileInputStream fis = new FileInputStream(path); return fis; } catch (FileNotFoundException e) { e.printStackTrace(); } } return null; } /** * @see org.apache.slide.simple.store.BasicWebdavStore#getResourceLength(java.lang.S tring) */ public long getResourceLength(String resourceUri) throws ServiceAccessException, AccessDeniedException, ObjectNotFoundException, ObjectLockedException { Map map = mappings.loadMapping(); long length = 0; if (map.containsKey(resourceUri)) { String path = (String) map.get(resourceUri); File file = new File(path); length = file.length(); } return length; } /** * @see org.apache.slide.simple.store.BasicWebdavStore#isFolder(java.lang.String) */ public boolean isFolder(String uri) throws ServiceAccessException, AccessDeniedException, ObjectLockedException { logger.logInfo("isFolder " + uri); return FILES.equals(uri); } /** * @see org.apache.slide.simple.store.BasicWebdavStore#isResource(java.lang.String) */ public boolean isResource(String uri) throws ServiceAccessException, AccessDeniedException, ObjectLockedException { Map map = mappings.loadMapping(); return map.containsKey(uri); } /** * @see org.apache.slide.simple.store.BasicWebdavStore#objectExists(java.lang.String ) */ public boolean objectExists(String uri) throws ServiceAccessException, AccessDeniedException, ObjectLockedException { Map map = mappings.loadMapping(); logger.logInfo("objectExists " + uri); return FILES.equals(uri) || map.containsKey(uri); } /** * @see org.apache.slide.simple.store.BasicWebdavStore#removeObject(java.lang.String ) */ public void removeObject(String uri) throws ServiceAccessException, AccessDeniedException, ObjectNotFoundException, ObjectLockedException { throw new AccessDeniedException("", "", ""); } /** * @see org.apache.slide.simple.store.BasicWebdavStore#rollback() */ public void rollback() throws ServiceAccessException { } /** * @see org.apache.slide.simple.store.BasicWebdavStore#setResourceContent(java.lang. String, * java.io.InputStream, java.lang.String, java.lang.String) */ public void setResourceContent(String resourceUri, InputStream content, String contentType, String characterEncoding) throws ServiceAccessException, AccessDeniedException, ObjectNotFoundException, ObjectLockedException { // FIXME Auto-generated method stub Map map = mappings.loadMapping(); if (map.containsKey(resourceUri)) { String path = (String) map.get(resourceUri); try { FileOutputStream fos = new FileOutputStream(path); byte[] buffer = new byte[1024 * 20]; int read = 0; while ((read = content.read(buffer)) > 0) fos.write(buffer, 0, read); fos.flush(); fos.close(); content.close(); } catch (Exception e) { e.printStackTrace(); } } } } but when I setup this store in Domain.xml, i'm getting exception: 15 Feb 2006 18:43:30 - org.apache.slide.common.XMLUnmarshaller - INFO - Loading object /files 15 Feb 2006 18:43:30 - WebDAV store - INFO - objectExists /files 15 Feb 2006 18:43:30 - WebDAV store - INFO - isFolder /files 15 Feb 2006 18:43:30 - org.apache.slide.common.XMLUnmarshaller - INFO - Object already exists at /files 15 Feb 2006 18:43:30 - WebDAV store - INFO - objectExists /files 15 Feb 2006 18:43:30 - WebDAV store - INFO - objectExists /files 15 Feb 2006 18:43:30 - WebDAV store - INFO - objectExists /files 15 Feb 2006 18:43:30 - WebDAV store - INFO - isFolder /files 15 Feb 2006 18:43:30 - WebDAV store - INFO - objectExists /files 15 Feb 2006 18:43:30 - org.apache.slide.common.Domain - WARNING - Invalid object at : No content 15 Feb 2006 18:43:30 - org.apache.slide.common.Namespace - ERROR - Unable to read Namespace base configuration file : 15 Feb 2006 18:43:30 - org.apache.slide.common.Namespace - ERROR - org.apache.slide.common.ObjectValidationFailedException: Invalid object at : No content org.apache.slide.common.ObjectValidationFailedException: Invalid object at : No content I don't have "files" folder under the root store, basically I don't have root folder in the store at all. I checked implementation of isFolder, isResource, objectExists methods in sources for org.apache.slide.simple.reference.WebdavFileStore Could somebody please help? -- Eugene N Dzhurinsky --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
