Package org.webslinger.container

Examples of org.webslinger.container.FileInfo


        protected void checkForMigration(FileObject ptr) throws EditorException, IOException, ServletException {
            Editor.this.checkForMigration(ptr, CollectionUtil.toMap("fileInfo", getFileInfo(), "filePath", filePath, "fileContext", this));
        }

        protected FileInfo checkHook(String hook, String command) throws EditorException, IOException, ServletException {
            FileInfo fileInfo = getFileInfo();
            Object result = runHook(hook, CollectionUtil.toMap("fileInfo", fileInfo, "filePath", filePath, "fileContext", this));
            if (result instanceof Collection) {
                Iterator it = ((Collection) result).iterator();
                while (it.hasNext()) {
                    Object hookResult = it.next();
View Full Code Here


            runHook(hook, CollectionUtil.toMap("fileInfo", fileInfo, "filePath", filePath, "fileContext", this));
        }

        public void delete() throws EditorException {
            try {
                FileInfo fileInfo = checkHook("PreDelete", "delete");
                fileInfo.getFile().delete();
                refresh(fileInfo);
                hook("PostDelete", fileInfo);
            } catch (EditorException e) {
                throw e;
            } catch (ServletException e) {
View Full Code Here

        public void save() throws EditorException {
            hookDatas.clear();
            try {
                logger.info(this + ".save()");
                FileInfo fileInfo = checkHook("PreSave", "save");
                FileObject file = fileInfo.getFile();
                checkForMigration(file.getParent());
                FileContent fileContent = file.getContent();
                if (hasContent()) IOUtil.copy(getContent().getInputStream(), true, fileContent.getOutputStream(), true);
                Iterator it = deletedAttributes.iterator();
                while (it.hasNext()) {
                    String name = (String) it.next();
                    if (fileContent.hasAttribute(name)) {
                        fileContent.removeAttribute(name);
                    } else {
                        fileContent.setAttribute(name, null);
                    }
                }
                Map defaultAttributes = fileInfo.getDefaultAttributes();
                it = attributes.entrySet().iterator();
                while (it.hasNext()) {
                    Map.Entry entry = (Map.Entry) it.next();
                    String name = (String) entry.getKey();
                    Object value = entry.getValue();
View Full Code Here

            fileInfo.refresh();
        }

        protected FileInfo getFileInfo() throws IOException {
            try {
                FileInfo fileInfo = Editor.this.createFileInfo(prefix + filePath);
                FileObject file = fileInfo.getFile();
                String contentType = (String) attributes.get("content-type");
                if (file.getType().hasChildren()) {
                    String extension;
                    if (contentType != null) {
                        extension = Editor.this.findExtensionByMimeType(contentType);
                        if (extension == null) extension = Editor.this.getDefaultExtension();
                    } else {
                        extension = Editor.this.getDefaultExtension();
                    }
                    String name = "index";
                    String defaultIndex = (String) file.getContent().getAttribute("default-index");
                    if (defaultIndex != null) name = defaultIndex;
                    FileObject base = file;
                    file = base.resolveFile(name);
                    if (file.exists()) {
                        fileInfo = Editor.this.createFileInfo(file.getName().getPath());
                    } else {
                        if (extension != null && extension.length() > 0) {
                            file = base.resolveFile(name + '.' + extension);
                            fileInfo = Editor.this.createFileInfo(file.getName().getPath());
                        }
                    }
                } else {
                if (file.getName().getExtension().length() == 0) {
                    // no extension
                    String extension;
                    if (contentType == null && !servletContext.getContainer().getDefaultMimeType().equals(fileInfo.getContentType())) {
                        contentType = (String) fileInfo.getAttribute("content-type");
                    }
                    if (contentType != null) {
                        extension = Editor.this.findExtensionByMimeType(contentType);
                        if (extension == null) extension = Editor.this.getDefaultExtension();
                    } else {
View Full Code Here

        public String getType() throws EditorException {
            try {
                String type = (String) attributes.get("editor-type");
                if (type != null) return type;
                FileInfo fileInfo = getFileInfo();
                type = (String) fileInfo.getAttribute("editor-type");
                if (type != null) return type;
                return Editor.this.getDefaultEditor();
            } catch (EditorException e) {
                throw e;
            } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.webslinger.container.FileInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.