Package org.apache.jackrabbit.vault.fs.api

Examples of org.apache.jackrabbit.vault.fs.api.ImportMode


            if (primary != null) {
                if (info == null) {
                    info = new ImportInfoImpl();
                }
                // check import mode
                ImportMode mode = ImportMode.REPLACE;
                String path = PathUtil.getPath(parent, primary.getRelativePath());
                if (primary.getRelativePath().length() == 0 || parent.hasNode(primary.getRelativePath())) {
                    mode = wspFilter.getImportMode(path);
                }
                // only update if not MERGE (i.e. is REPLACE or UPDATE)
                if (mode != ImportMode.MERGE) {
                    InputSource source = primary.getInputSource();
                    if (source != null) {
                        info.merge(importDocView(parent, source, artifacts, wspFilter));
                    }
                } else {
                    info.onNop(path);
                }
            }
            // handle files
            for (Artifact file: artifacts.values(ArtifactType.FILE)) {
                if (info == null) {
                    info = new ImportInfoImpl();
                }
                // check type of file artifact
                if (file.getSerializationType() == SerializationType.GENERIC
                        || file.getSerializationType() == SerializationType.XML_GENERIC) {
                    // case 1: new file
                    final String fileName = file.getRelativePath();
                    if (!parent.hasNode(fileName)) {
                        importFile(info, parent, file, fileName, false);
                    } else {
                        // case 2: same structure, new data
                        if (file instanceof ImportArtifact) {
                            Node fileNode = parent.getNode(fileName);
                            // check import mode, only replace if not MERGE
                            if (wspFilter.getImportMode(fileNode.getPath()) != ImportMode.MERGE) {
                                if (!fileNode.hasNode(JcrConstants.JCR_CONTENT)) {
                                    // apparently no nt:file, recreate file node
                                    fileNode.remove();
                                    importFile(info, parent, file);
                                } else {
                                    if (!importNtResource(info, fileNode.getNode(JcrConstants.JCR_CONTENT), file)) {
                                        info.onNop(fileNode.getPath());
                                    }
                                }
                            } else {
                                info.onNop(fileNode.getPath());
                            }
                        } else {
                            // do nothing
                        }
                    }
                } else if (file.getSerializationType() == SerializationType.XML_DOCVIEW) {
                    // special case for full coverage files below a intermediate node
                    String relPath = Text.getRelativeParent(file.getRelativePath(), 1);
                    String newName = Text.getName(file.getRelativePath());
                    Node newParent = parent;
                    if (relPath.length() > 0) {
                        if (parent.hasNode(relPath)) {
                            newParent = parent.getNode(relPath);
                        } else {
                            throw new IllegalArgumentException("Special docview file can't be imported. parent does not exist: " + parent.getPath() + "/" + relPath);
                        }
                    }
                    ArtifactSetImpl newSet = new ArtifactSetImpl();
                    newSet.setCoverage(ItemFilterSet.INCLUDE_ALL);

                    // check import mode
                    ImportMode mode = ImportMode.REPLACE;
                    String path = PathUtil.getPath(newParent, newName);
                    if (newName.length() == 0 || newParent.hasNode(newName)) {
                        mode = wspFilter.getImportMode(path);
                    }
                    if (mode != ImportMode.MERGE) {
View Full Code Here


            if (primary != null) {
                if (info == null) {
                    info = new ImportInfoImpl();
                }
                // check import mode
                ImportMode mode = ImportMode.REPLACE;
                String path = PathUtil.getPath(parent, primary.getRelativePath());
                if (primary.getRelativePath().length() == 0 || parent.hasNode(primary.getRelativePath())) {
                    mode = wspFilter.getImportMode(path);
                }
                // only update if not MERGE (i.e. is REPLACE or UPDATE)
                if (mode != ImportMode.MERGE) {
                    InputSource source = primary.getInputSource();
                    if (source != null) {
                        info.merge(importDocView(parent, source, artifacts, wspFilter));
                    }
                } else {
                    info.onNop(path);
                }
            }
            // handle files
            for (Artifact file: artifacts.values(ArtifactType.FILE)) {
                if (info == null) {
                    info = new ImportInfoImpl();
                }
                // check type of file artifact
                if (file.getSerializationType() == SerializationType.GENERIC
                        || file.getSerializationType() == SerializationType.XML_GENERIC) {
                    // case 1: new file
                    if (!parent.hasNode(file.getRelativePath())) {
                        importFile(info, parent, file);
                    } else {
                        // case 2: same structure, new data
                        if (file instanceof ImportArtifact) {
                            Node fileNode = parent.getNode(file.getRelativePath());
                            // check import mode, only replace if not MERGE
                            if (wspFilter.getImportMode(fileNode.getPath()) != ImportMode.MERGE) {
                                if (!fileNode.hasNode(JcrConstants.JCR_CONTENT)) {
                                    // apparently no nt:file, recreate file node
                                    fileNode.remove();
                                    importFile(info, parent, file);
                                } else {
                                    if (!importNtResource(info, fileNode.getNode(JcrConstants.JCR_CONTENT), file)) {
                                        info.onNop(fileNode.getPath());
                                    }
                                }
                            } else {
                                info.onNop(fileNode.getPath());
                            }
                        } else {
                            // do nothing
                        }
                    }
                } else if (file.getSerializationType() == SerializationType.XML_DOCVIEW) {
                    // special case for full coverage files below a intermediate node
                    String relPath = Text.getRelativeParent(file.getRelativePath(), 1);
                    String newName = Text.getName(file.getRelativePath());
                    Node newParent = parent;
                    if (relPath.length() > 0) {
                        if (parent.hasNode(relPath)) {
                            newParent = parent.getNode(relPath);
                        } else {
                            throw new IllegalArgumentException("Special docview file can't be imported. parent does not exist: " + parent.getPath() + "/" + relPath);
                        }
                    }
                    ArtifactSetImpl newSet = new ArtifactSetImpl();
                    newSet.setCoverage(ItemFilterSet.INCLUDE_ALL);

                    // check import mode
                    ImportMode mode = ImportMode.REPLACE;
                    String path = PathUtil.getPath(newParent, newName);
                    if (newName.length() == 0 || newParent.hasNode(newName)) {
                        mode = wspFilter.getImportMode(path);
                    }
                    if (mode != ImportMode.MERGE) {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.vault.fs.api.ImportMode

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.