Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.guvnor.server.files;
 
 import  net.sf.webdav.ITransaction;
 import  net.sf.webdav.IWebdavStore;
 import  net.sf.webdav.StoredObject;
 
 import java.io.*;
 import java.util.*;
 
 public class WebDAVImpl
         implements
         IWebdavStore {
 
     private static final String              SNAPSHOTS     = "snapshots";
 
     private static final String              PACKAGES      = "packages";
 
     private static final String              GLOBALAREA    = "globalarea";

    
for the rubbish OSX double data (the ._ rubbish)
 
     private static final Map<Stringbyte[]> osxDoubleData = Collections.synchronizedMapnew WeakHashMap<Stringbyte[]>() );
 
     // Note that a RulesRepository is @RequestScoped, so there's no need to put it into a thread local
     @Inject @Preferred
     protected RulesRepository                rulesRepository;
 
     @Inject
     protected Identity                       identity;
 
     @Inject
     protected AssetValidator                 assetValidator;
 
     public ITransaction begin(final Principal principal) {
         return new ITransaction() {
             public Principal getPrincipal() {
                 return principal;
             }
         };
     }
 
     public void checkAuthentication(ITransaction arg0) {
         //already done
     }
 
     public void commit(ITransaction iTransaction) {
         .save();
     }
 
     public void createFolder(ITransaction iTransaction,
                              String uri) {
         String[] path = getPathuri );
         if ( isPackagespath ) && isAdmin() ) {
             if ( path.length > 2 ) {
                 throw new UnsupportedOperationException"Can't nest packages." );
             }
             if ( .containsModulepath[1] ) ) {
                 ModuleItem pkg = loadPackageFromRepositorypath[1] );
                 pkg.archiveItemfalse );
                 pkg.checkin"restored by webdav" );
             } else {
                 .createModulepath[1],
                                               "from webdav" );
             }
         } else {
             throw new UnsupportedOperationException"Not able to create folders here..." );
         }
    }
    public void createResource(ITransaction iTransaction,
                               String uri) {
        //for mac OSX, ignore these annoying things
        if ( uri.endsWith".DS_Store" ) ) return;
        String[] path = getPathuri );
        if ( isPackagespath ) && checkPackagePermissionpath[1],
                                                           ..getName() ) ) {
            if ( path.length > 3 ) {
                throw new UnsupportedOperationException"Can't do nested packages." );
            }
            String[] resource = AssetItem.getAssetNameFromFileNamepath[2] );
            ModuleItem packageItem = loadPackageFromRepositorypath[1] );
            //for mac OSX, ignore these resource fork files
            if ( path[2].startsWith"._" ) ) {
                ..puturi,
                                              null );
                return;
            }
            if ( packageItem.containsAssetresource[0] ) ) {
                AssetItem lazarus = packageItem.loadAssetresource[0] );
                lazarus.archiveItemfalse );
                lazarus.checkin"restored by webdav" );
            } else {
                AssetItem asset = packageItem.addAssetresource[0],
                                                        "" );
                asset.updateFormatresource[1] );
                asset.updateValid(.validate(asset));
                asset.checkin"from webdav" );
            }
        } else if ( isGlobalAreaspath ) ) {
            String[] resource = AssetItem.getAssetNameFromFileNamepath[1] );
            ModuleItem packageItem = loadGlobalAreaFromRepository();
            //for mac OSX, ignore these resource fork files
            if ( path[1].startsWith"._" ) ) {
                ..puturi,
                                              null );
                return;
            }
            if ( packageItem.containsAssetresource[0] ) ) {
                AssetItem lazarus = packageItem.loadAssetresource[0] );
                lazarus.archiveItemfalse );
                lazarus.checkin"restored by webdav" );
            } else {
                AssetItem asset = packageItem.addAssetresource[0],
                                                        "" );
                asset.updateFormatresource[1] );
                asset.updateValid(.validate(asset));
                asset.checkin"from webdav" );
            }
        } else {
            throw new UnsupportedOperationException"Can't add assets here." );
        }
    }
    public String[] getChildrenNames(ITransaction iTransaction,
                                     String uri) {
        String[] path = getPathuri );
        List<Stringresult = new ArrayList<String>();
        if ( path.length == 0 ) {
            return new String[]{};
        }
        if ( isPackagespath ) ) {
            if ( path.length > 2 ) {
                return null;
            }
            if ( path.length == 1 ) {
                listPackages,
                              result );
            } else if ( checkPackagePermissionIfReadOnlypath ) ) {
                handleReadOnlyPackages,
                                        path,
                                        result );
            }
        } else if ( isSnaphostspath ) ) {
            if ( path.length > 3 ) {
                return null;
            }
            if ( path.length == 1 ) {
                listPackages,
                              result );
            } else if ( isPermissionpath,
                                      2 ) ) {
                return .listModuleSnapshotspath[1] );
            } else if ( isPermissionpath,
                                      3 ) ) {
                handleReadOnlySnapshotPackages,
                                                path,
                                                result );
            } else {
                throw new IllegalArgumentException();
            }
        } else if ( isGlobalAreaspath ) ) {
            if ( path.length > 2 ) {
                return null;
            }
            if ( path.length == 1 ) {
                // no packages under global area. show contents
                handleReadOnlyGlobalAreaPackages,
                                                  path,
                                                  result );
            }
        } else {
            throw new UnsupportedOperationException"Not a valid path : " + path[0] );
        }
        return result.toArraynew String[result.size()] );
    }
    private void handleReadOnlySnapshotPackages(RulesRepository repository,
                                                String[] path,
                                                List<Stringresult) {
        while ( it.hasNext() ) {
            AssetItem asset = it.next();
            if ( !asset.isArchived() ) {
                addNameAndFormatresult,
                                  asset );
            }
        }
    }
    private void handleReadOnlyGlobalAreaPackages(RulesRepository repository,
                                                  String[] path,
                                                  List<Stringresult) {
        while ( it.hasNext() ) {
            AssetItem asset = it.next();
            if ( !asset.isArchived() ) {
                addNameAndFormatresult,
                                  asset );
            }
        }
    }
    private void handleReadOnlyPackages(RulesRepository repository,
                                        String[] path,
                                        List<Stringresult) {
        ModuleItem pkg = loadPackageFromRepository(
                path[1] );
        Iterator<AssetItemit = pkg.getAssets();
        while ( it.hasNext() ) {
            AssetItem asset = it.next();
            if ( !asset.isArchived() ) {
                addNameAndFormatresult,
                                  asset );
            }
        }
    }
    private void addNameAndFormat(List<Stringresult,
                                     AssetItem asset) {
        result.addasset.getName() + "." + asset.getFormat() );
    }
    private void listPackages(RulesRepository repository,
                              List<Stringresult) {
        Iterator<ModuleItemit = repository.listModules();
        while ( it.hasNext() ) {
            ModuleItem pkg = it.next();
            String packageName = pkg.getName();
            if ( !pkg.isArchived() && checkPackagePermissionpackageName,
                                                              ..getName() ) ) {
                result.addpackageName );
            }
        }
    }
    public Date getCreationDate(String uri) {
        String[] path = getPathuri );
        if ( path.length < 2 ) {
            return new Date();
        }
        if ( isPackagespath ) && checkPackagePermissionIfReadOnlypath ) ) {
            return getCreationDateForPackage,
                                              path );
        }
        if ( isSnaphostspath ) && checkPackagePermissionIfReadOnlypath ) ) {
            return getCreationTimeForSnapshotPackage,
                                                      path );
        }
        if ( isGlobalAreaspath ) ) {
            return getCreationTimeForGlobalAreaPackage,
                                                        path );
        }
        throw new UnsupportedOperationException();
    }
                                                   String[] path) {
        if ( path.length == 2 ) {
            return new Date();
        } else if ( path.length == 3 ) {
            return loadPackageSnapshotFromRepositorypath ).getCreatedDate().getTime();
        } else if ( path.length == 4 ) {
                                                 path ),
                                                 path[3] ).getCreatedDate().getTime();
        }
        throw new UnsupportedOperationException();
    }
    private Date getCreationDateForPackage(RulesRepository repository,
                                           String[] path) {
        ModuleItem packageItem = loadPackageFromRepositorypath[1] );
        if ( path.length == 2 ) {
            return packageItem.getCreatedDate().getTime();
        }
        return loadAssetItemFromPackageItempackageItem,
                                             path[2] ).getCreatedDate().getTime();
    }
                                                     String[] path) {
        ModuleItem packageItem = loadGlobalAreaFromRepository();
        if ( path.length == 2 ) {
            return packageItem.getCreatedDate().getTime();
        }
        return loadAssetItemFromPackageItempackageItem,
                                             path[2] ).getCreatedDate().getTime();
    }
    public Date getLastModified(String uri) {
        String[] path = getPathuri );
        if ( path.length < 2 ) {
            return new Date();
        }
        if ( isPackagespath ) && checkPackagePermissionIfReadOnlypath ) ) {
            return getLastModifiedForPackage,
                                              path );
        }
        if ( isSnaphostspath ) && checkPackagePermissionIfReadOnlypath ) ) {
            return getLastModifiedForSnaphotPackage,
                                                     path );
        }
        if ( isGlobalAreaspath ) ) {
            return getLastModifiedForGlobalAreaPackage,
                                                        path );
        }
        throw new UnsupportedOperationException();
    }
                                                  String[] path) {
        if ( path.length == 2 ) {
            return new Date();
        } else if ( path.length == 3 ) {
            return loadPackageSnapshotFromRepositorypath ).getLastModified().getTime();
        } else if ( path.length == 4 ) {
            ModuleItem pkg = loadPackageSnapshotFromRepositorypath );
            return getLastModifiedFromPackageAssetItempkg,
                                                        path[3] );
        }
        throw new UnsupportedOperationException();
    }
    private Date getLastModifiedForPackage(RulesRepository repository,
                                           String[] path) {
        ModuleItem pkg = loadPackageFromRepositorypath[1] );
        if ( path.length == 2 ) {
            return pkg.getLastModified().getTime();
        }
        return getLastModifiedFromPackageAssetItempkg,
                                                    path[2] );
    }
                                                     String[] path) {
        ModuleItem pkg = loadGlobalAreaFromRepository();
        if ( path.length == 2 ) {
            return pkg.getLastModified().getTime();
        }
        return getLastModifiedFromPackageAssetItempkg,
                                                    path[2] );
    }
                                                     String path) {
        return loadAssetItemFromPackageItempackageItem,
                                             path ).getLastModified().getTime();
    }
    public InputStream getResourceContent(ITransaction iTransaction,
                                          String uri) {
        return getContenturi );
    }
    public StoredObject getStoredObject(ITransaction iTransaction,
                                        String uri) {
        String[] path = getPathuri );
        if ( path.length < 2 ) {
            return createStoredObjecturi );
        }
        if ( isPackagespath ) && checkPackagePermissionIfReadOnlypath ) ) {
            return getStoredObjectForReadOnlyPackagesuri,
                                                       ,
                                                       path );
        }
        if ( isSnaphostspath ) && checkPackagePermissionIfReadOnlypath ) ) {
            return getStoredObjectForReadOnlySnapshotsuri,
                                                        ,
                                                        path );
        }
        if ( isGlobalAreaspath ) ) {
            return getStoredObjectForReadOnlyGlobalAreauri,
                                                         ,
                                                         path );
        }
        throw new UnsupportedOperationException();
    }
    private StoredObject createStoredObject(String uri) {
        StoredObject so = new StoredObject();
        so.setCreationDate( new Date() );
        so.setFolder( isFolderuri ) );
        so.setLastModified( new Date() );
        so.setResourceLength( 0 );
        return so;
    }
    private StoredObject getStoredObjectForReadOnlySnapshots(String uri,
                                                             RulesRepository repository,
                                                             String[] path) {
        if ( path.length == 2 ) {
            StoredObject so = createStoredObjecturi,
                                                  loadPackageFromRepository(
                                                  path[1] ),
                                                  0 );
            so.setFolder( isFolderuri ) );
            return so;
        } else if ( path.length == 3 ) {
            return createStoredObjecturi,
                                       loadPackageSnapshotFromRepository(
                                       path ),
                                       0 );
        } else if ( path.length == 4 ) {
            ModuleItem pkg = loadPackageSnapshotFromRepositorypath );
            AssetItem asset;
            try {
                asset = loadAssetItemFromPackageItempkg,
                                                      path[3] );
            } catch ( Exception e ) {
                return null;
            }
            return createStoredObjecturi,
                                       asset,
                                       asset.getContentLength() );
        }
        throw new UnsupportedOperationException();
    }
    private StoredObject getStoredObjectForReadOnlyPackages(String uri,
                                                            RulesRepository repository,
                                                            String[] path) {
        ModuleItem packageItem = loadPackageFromRepositorypath[1] );
        if ( path.length == 2 ) {
            return createStoredObjecturi,
                                       packageItem,
                                       0 );
        }
        AssetItem asset;
        try {
            asset = loadAssetItemFromPackageItempackageItem,
                                                  path[2] );
        } catch ( Exception e ) {
            return null;
        }
        return createStoredObjecturi,
                                   asset,
                                   asset.getContentLength() );
    }
    private StoredObject getStoredObjectForReadOnlyGlobalArea(String uri,
                                                              RulesRepository repository,
                                                              String[] path) {
        if ( path.length == 1 ) {
            StoredObject so = createStoredObjecturi,
                                                  loadGlobalAreaFromRepository(),
                                                  0 );
            so.setFolder( isFolderuri ) );
            return so;
        } else if ( path.length == 2 ) {
            AssetItem asset;
            try {
                asset = loadAssetItemFromGlobalAreapath );
            } catch ( Exception e ) {
                return null;
            }
            return createStoredObjecturi,
                                       asset,
                                       asset.getContentLength() );
        } else if ( path.length == 3 ) {
            AssetItem asset;
            try {
                asset = loadAssetItemFromGlobalAreapath );
            } catch ( Exception e ) {
                return null;
            }
            return createStoredObjecturi,
                                       asset,
                                       asset.getContentLength() );
        }
        throw new UnsupportedOperationException();
    }
    private StoredObject createStoredObject(String uri,
                                            VersionableItem versionableItem,
                                            long resourceLength) {
        StoredObject so = new StoredObject();
        so.setCreationDate( versionableItem.getCreatedDate().getTime() );
        so.setFolder( isFolderuri ) );
        so.setLastModified( versionableItem.getLastModified().getTime() );
        so.setResourceLength( resourceLength );
        return so;
    }
    private InputStream getContent(String uri) {
        String[] path = getPathuri );
        if ( isPackagespath ) && checkPackagePermissionIfReadOnlypath ) ) {
            return getAssetDataloadAssetItemFromPackagepath ) );
        }
        if ( isSnaphostspath ) && checkPackagePermissionIfReadOnlypath ) ) {
            return getAssetDataloadAssetItemFromPackageSnaphotpath ) );
        }
        if ( isGlobalAreaspath ) ) {
            return getAssetDataloadAssetItemFromGlobalAreapath ) );
        }
        throw new UnsupportedOperationException();
    }
    private InputStream getAssetData(AssetItem assetItem) {
        if ( assetItem.isBinary() ) {
            return assetItem.getBinaryContentAttachment();
        }
        return new ByteArrayInputStreamassetItem.getContent().getBytes() );
    }
    public long getResourceLength(ITransaction iTransaction,
                                  String uri) {
        String[] path = getPathuri );
        try {
            if ( path.length == 3 && isPackagespath ) && checkPackagePermissionIfReadOnlypath ) ) {
                return loadAssetItemFromPackagepath ).getContentLength();
            }
            if ( path.length == 3 && isGlobalAreaspath ) ) {
                return loadAssetItemFromPackagepath ).getContentLength();
            }
            if ( path.length == 4 && isSnaphostspath ) && checkPackagePermissionIfReadOnlypath ) ) {
                return loadAssetItemFromPackageSnaphotpath ).getContentLength();
            }
            return 0;
        } catch ( Exception e ) {
            ..println"Not able to get content length" );
            return 0;
        }
    }
    boolean isFolder(String uri) {
        String[] path = getPathuri );
        if ( path.length == 0 ) {
            return true;
        }
        if ( path.length == 1 && (isPackagespath ) || isSnaphostspath ) || isGlobalAreaspath )) ) {
            return true;
        }
        if ( path.length == 2 ) {
            return .containsModulepath[1] );
        }
        if ( path.length == 3 && isSnaphostspath ) ) {
            return .containsModulepath[1] );
        }
        return false;
    }
    boolean isResource(String uri) {
        String[] path = getPathuri );
        if ( path.length < 3 ) {
            return false;
        }
        if ( !(isPackagespath ) || isSnaphostspath ) || isGlobalAreaspath )) ) {
            return false;
        }
        if ( .containsModulepath[1] ) ) {
            if ( isPackagespath ) ) {
                ModuleItem pkg = loadPackageFromRepositorypath[1] );
                if ( path[2].startsWith"._" ) ) {
                    return .containsKeyuri );
                }
                return pkg.containsAsset( AssetItem.getAssetNameFromFileNamepath[2] )[0] );
            }
            if ( path.length == 4 ) {
                return isAssetItemInPackage,
                                             path );
            }
            return false;
        }
        return false;
    }
    boolean objectExists(String uri) {
        if ( uri.indexOf" copy " ) > 0 ) {
            throw new IllegalArgumentException"OSX is not capable of copy and pasting without breaking the file extension." );
        }
        return internalObjectExistsuri );
    }
    private boolean internalObjectExists(String uri) {
        if ( uri.endsWith".DS_Store" ) ) {
            return false;
        }
        String[] path = getPathuri );
        if ( path.length == 0 || (path.length == 1 && (isPackagespath ) || isSnaphostspath ) || isGlobalAreaspath ))) ) {
            return true;
        }
        if ( path.length == 1 || !.containsModulepath[1] ) ) {
            return false;
        }
        if ( isPackagespath ) ) {
            return handlePackagesInternalObjectExistsuri,
                                                       ,
                                                       path );
        }
        if ( isSnaphostspath ) ) {
            return handleSnapshotsInternalObjectExists,
                                                        path );
        }
        if ( isGlobalAreaspath ) ) {
            return handlePackagesInternalObjectExistsuri,
                                                       ,
                                                       path );
        }
        throw new IllegalStateException();
    }
    private boolean handleSnapshotsInternalObjectExists(RulesRepository repository,
                                                        String[] path) {
        if ( path.length == 2 ) {
            return repository.containsModulepath[1] );
        }
        if ( path.length == 3 ) {
            return repository.containsSnapshotpath[1],
                                                path[2] );
        }
        if ( path.length == 4 ) {
            return isAssetItemInPackagerepository,
                                         path );
        }
        return false;
    }
    private boolean handlePackagesInternalObjectExists(String uri,
                                                       RulesRepository repository,
                                                       String[] path) {
        if ( path.length == 2 ) {
            ModuleItem pkg = loadPackageFromRepositorypath[1] );
            return !pkg.isArchived();
        }
        ModuleItem pkg = loadPackageFromRepositorypath[1] );
        if ( path[2].startsWith"._" ) ) {
            return ..containsKeyuri );
        }
        String assetName = AssetItem.getAssetNameFromFileNamepath[2] )[0];
        return pkg.containsAssetassetName ) && !pkg.loadAssetassetName ).isArchived();
    }
    public void removeObject(ITransaction iTransaction,
                             String uri) {
        String[] path = getPathuri );
        if ( path.length == 0 || path.length == 1 ) {
            throw new IllegalArgumentException();
        }
        if ( isPackagespath ) && checkPackagePermissionIfDeveloperpath ) ) {
            ModuleItem packageItem = loadPackageFromRepositorypath[1] );
            if ( path.length == 3 ) {
                //delete asset
                if ( path[2].startsWith"._" ) ) {
                    ..removeuri );
                    return;
                }
                AssetItem item = loadAssetItemFromPackageItempackageItem,
                                                               path[2] );
                item.archiveItemtrue );
                item.checkin"" );
            } else {
                //delete package
                packageItem.archiveItemtrue );
                packageItem.checkin"" );
            }
        } else if ( isGlobalAreaspath ) ) {
            if ( path.length == 2 ) {
                //delete asset
                if ( path[1].startsWith"._" ) ) {
                    ..removeuri );
                    return;
                }
                AssetItem item = loadAssetItemFromGlobalAreapath );
                item.archiveItemtrue );
                item.checkin"" );
            }
        } else {
            throw new IllegalArgumentException"Not allowed to remove this file." );
        }
    }
    public void rollback(ITransaction iTransaction) {
        .getSession().logout();
    }
    public long setResourceContent(ITransaction iTransaction,
                                   String uri,
                                   InputStream content,
                                   String contentType,
                                   String characterEncoding) {
        if ( uri.endsWith".DS_Store" ) ) {
            return 0;
        }
        String[] path = getPathuri );
        if ( isPackagespath ) && checkPackagePermissionIfDeveloperpath ) ) {
            if ( path.length != 3 ) {
                throw new IllegalArgumentException"Not a valid resource path " + uri );
            }
            if ( path[2].startsWith"._" ) ) {
                try {
                    ..puturi,
                                                  IOUtils.toByteArraycontent ) );
                } catch ( IOException e ) {
                    throw new RuntimeExceptione );
                }
                return 0;
            }
            AssetItem asset = loadAssetItemFromPackagepath );
            if ( asset.getFormat().equals"drl" ) ) {
                try {
                    BufferedReader reader = new BufferedReadernew InputStreamReadercontent ) );
                    StringBuilder sb = new StringBuilder();
                    String line = null;
                    while ( (line = reader.readLine()) != null ) {
                        if ( !line.startsWith"package " ) ) {
                            sb.appendline ).append"\n" );
                        }
                    }
                    asset.updateBinaryContentAttachmentnew ByteArrayInputStreamsb.toString().getBytes"UTF-8" ) ) );
                } catch ( Exception e ) {
                    //default
                    asset.updateBinaryContentAttachmentcontent );
                }
            } else {
                asset.updateBinaryContentAttachmentcontent );
            }
            //here we could save, or check in, depending on if enough time has passed to justify
            //a new version. Otherwise we will pollute the version history with lots of trivial versions.
            //if (shouldCreateNewVersion(asset.getLastModified())) {
            asset.updateValid(.validate(asset));
            asset.checkin"content from webdav" );
            //}
        } else if ( isGlobalAreaspath ) ) {
            if ( path[1].startsWith"._" ) ) {
                try {
                    ..puturi,
                                                  IOUtils.toByteArraycontent ) );
                } catch ( IOException e ) {
                    throw new RuntimeExceptione );
                }
                return 0;
            }
            AssetItem asset = loadAssetItemFromGlobalAreapath );
            if ( asset.getFormat().equals"drl" ) ) {
                try {
                    BufferedReader reader = new BufferedReadernew InputStreamReadercontent ) );
                    StringBuilder sb = new StringBuilder();
                    String line = null;
                    while ( (line = reader.readLine()) != null ) {
                        if ( !line.startsWith"package " ) ) {
                            sb.appendline ).append"\n" );
                        }
                    }
                    asset.updateBinaryContentAttachmentnew ByteArrayInputStreamsb.toString().getBytes"UTF-8" ) ) );
                } catch ( Exception e ) {
                    //default
                    asset.updateBinaryContentAttachmentcontent );
                }
            } else {
                asset.updateBinaryContentAttachmentcontent );
            }
            //here we could save, or check in, depending on if enough time has passed to justify
            //a new version. Otherwise we will pollute the version history with lots of trivial versions.
            //if (shouldCreateNewVersion(asset.getLastModified())) {
            asset.updateValid(.validate(asset));
            asset.checkin"content from webdav" );
            //}
        } else {
            throw new UnsupportedOperationException"Unable to save content to this location." );
        }
        return 0;
    }
    //REVISIT: We should never reach this code which is using webdav as regex,
    //i.e., input uri is sth like /webdav/packages/mypackage
    String[] getPath(String uri) {
        //        if (beanManagerLocator.isBeanManagerAvailable()) {
        return getPathuri,
                        false );
        //        } else {
        //            return getPath(uri,
        //                    true);
        //        }
    }
    String[] getPath(String uri,
                     boolean usingWebdavAsRegex) {
        if ( uri.equals"/" ) ) {
            return new String[0];
        }
        if ( usingWebdavAsRegex ) {
            if ( uri.endsWith"webdav" ) || uri.endsWith"webdav/" ) ) {
                return new String[0];
            }
            if ( uri.contains"webdav/" ) ) {
                return uri.split"webdav/",
                                  2 )[1].split"/" );
            }
        }
        return uri.substring( 1 ).split"/" );
    }
    private boolean isAdmin() {
        return .hasPermissionnew AdminType(),
                                       ..getName() );
    }
    private boolean checkPackagePermission(String packageName,
                                           String type) {
        return .hasPermissionnew WebDavPackageNameTypepackageName ),
                                       type );
    }
    private AssetItem loadAssetItemFromPackage(String[] path) {
                                             path[1] ),
                                             path[2] );
    }
                                             path ),
                                             path[3] );
    }
    private AssetItem loadAssetItemFromGlobalArea(String[] path) {
                                             path[1] );
    }
                                                   String path) {
        return pkg.loadAsset( AssetItem.getAssetNameFromFileNamepath )[0] );
    }
    private boolean isAssetItemInPackage(RulesRepository repository,
                                         String[] path) {
        return loadPackageSnapshotFromRepositorypath ).containsAsset( AssetItem.getAssetNameFromFileNamepath[3] )[0] );
    }
    private ModuleItem loadPackageFromRepository(String path) {
        return .loadModulepath );
    }
        return .loadModuleSnapshotpath[1],
                                                   path[2] );
    }
        return .loadGlobalArea();
    }
    private boolean isPermission(String[] path,
                                 int pathIndex) {
        return path.length == pathIndex && checkPackagePermissionIfReadOnlypath );
    }
    private boolean checkPackagePermissionIfReadOnly(String[] path) {
        return checkPackagePermissionpath[1],
                                       ..getName() );
    }
    private boolean checkPackagePermissionIfDeveloper(String[] path) {
        return checkPackagePermissionpath[1],
                                       ..getName() );
    }
    private boolean isPackages(String[] path) {
        return path[0].equals );
    }
    private boolean isSnaphosts(String[] path) {
        return path[0].equals );
    }
    private boolean isGlobalAreas(String[] path) {
        return path[0].equals );
    }