Processes a nested archive by delegating to the ExplodedArchiveExporter

@param parentDirectory
@param nestedArchiveAsset
358106
private void processArchiveAsset(File parentDirectory, ArchiveAsset nestedArchiveAsset) {
        // Get the nested archive
        Archive<?> nestedArchive = nestedArchiveAsset.getArchive();
        nestedArchive.as(ExplodedExporter.class).exportExploded(parentDirectory);
    }
806076
private void performArchive() throws Exception
    {
        // The source dir points to the target/classes directory where the Maven resources plugin
        // has copied the XAR files during the process-resources phase.
        // For package.xml, however, we look in the resources directory (i.e. src/main/resources).
        File sourceDir = new File(this.project.getBuild().getOutputDirectory());

        // Check that there are files in the source dir
        if (sourceDir.listFiles() == null) {
            throw new Exception(
                String.format("No XAR XML files found in [%s]. Has the Maven Resource plugin be called?", sourceDir));
        }

        File xarFile = new File(this.project.getBuild().getDirectory(),
            this.project.getArtifactId() + "-" + this.project.getVersion() + ".xar");

        ZipArchiver archiver = new ZipArchiver();
        archiver.setEncoding(this.encoding);
        archiver.setDestFile(xarFile);
        archiver.setIncludeEmptyDirs(false);
        archiver.setCompress(true);

        if (this.includeDependencies) {
            // Unzip dependent XARs on top of this project's XML documents but without overwriting
            // existing files since we want this project's files to be used if they override a file
            // present in a XAR dependency.
            unpackDependentXARs();
        }

        // Perform XML transformations
        performTransformations();

        // If no package.xml can be found at the top level of the current project, generate one
        // otherwise, try to use the existing one
        File resourcesDir = getResourcesDirectory();
        if (!hasPackageXmlFile(resourcesDir)) {
            // Add files and generate the package.xml file
            addFilesToArchive(archiver, sourceDir);
        } else {
            File packageXml = new File(resourcesDir, PACKAGE_XML);
            addFilesToArchive(archiver, sourceDir, packageXml);
        }
        archiver.createArchive();

        this.project.getArtifact().setFile(xarFile);
    }
360965
public void setSourceArchiveUrls(List<String> sourceArchiveUrls) {
        if (sourceArchiveUrls == null)
            throw new IllegalArgumentException();
        this.sourceArchiveUrls = new ArrayList<String>(sourceArchiveUrls);
    }
755148
private void verifyParentDir(String src) throws FileAlreadyExistsException,
      FileNotFoundException {
    Path parent = new Path(src).getParent();
    if (parent != null) {
      INode[] pathINodes = dir.getExistingPathINodes(parent.toString());
      if (pathINodes[pathINodes.length - 1] == null) {
        throw new FileNotFoundException("Parent directory doesn't exist: "
            + parent.toString());
      } else if (!pathINodes[pathINodes.length - 1].isDirectory()) {
        throw new FileAlreadyExistsException("Parent path is not a directory: "
            + parent.toString());
      }
    }
  }
1105533
function get_node_from_parent_directory_data(error, parentDirectoryData) {
    if(error) {
      callback(error);
    } else {
      if(!parentDirectoryData.hasOwnProperty(name)) {
        callback(new Errors.ENOENT(null, path));
      } else {
        var nodeId = parentDirectoryData[name].id;
        context.getObject(nodeId, create_node);
      }
    }
  }
512515
protected void updateTimestampsForParentDirectories(
      List<URI> modifiedObjects, List<URI> excludedParents) throws IOException {
    logger.atFine().log(
        "updateTimestampsForParentDirectories(%s, %s)", modifiedObjects, excludedParents);

    TimestampUpdatePredicate updatePredicate =
        options.getShouldIncludeInTimestampUpdatesPredicate();
    Set<URI> excludedParentPathsSet = new HashSet<>(excludedParents);

    Set<URI> parentUrisToUpdate = Sets.newHashSetWithExpectedSize(modifiedObjects.size());
    for (URI modifiedObjectUri : modifiedObjects) {
      URI parentPathUri = getParentPath(modifiedObjectUri);
      if (!excludedParentPathsSet.contains(parentPathUri)
          && updatePredicate.shouldUpdateTimestamp(parentPathUri)) {
        parentUrisToUpdate.add(parentPathUri);
      }
    }

    Map<String, byte[]> modificationAttributes = new HashMap<>();
    FileInfo.addModificationTimeToAttributes(modificationAttributes, Clock.SYSTEM);

    List<UpdatableItemInfo> itemUpdates = new ArrayList<>(parentUrisToUpdate.size());

    for (URI parentUri : parentUrisToUpdate) {
      StorageResourceId resourceId = pathCodec.validatePathAndGetId(parentUri, true);
      if (!resourceId.isBucket() && !resourceId.isRoot()) {
        itemUpdates.add(new UpdatableItemInfo(resourceId, modificationAttributes));
      }
    }

    if (!itemUpdates.isEmpty()) {
      gcs.updateItems(itemUpdates);
    } else {
      logger.atFine().log("All paths were excluded from directory timestamp updating.");
    }
  }
1101261
@Override
    public T add(final Archive<?> archive, final ArchivePath path, final Class<? extends StreamExporter> exporter) {
        // Add archive asset
        super.add(archive, path, exporter);

        // Expected Archive Path
        final ArchivePath archivePath = new BasicPath(path, archive.getName());

        // Get the Asset that was just added
        final Node node = get(archivePath);

        // Make sure it is an ArchiveAsset
        if (node.getAsset() != null && node.getAsset() instanceof ArchiveAsset) {
            final ArchiveAsset archiveAsset = ArchiveAsset.class.cast(node.getAsset());
            // Add asset to ArchiveAsset Map
            nestedArchives.put(archivePath, archiveAsset);
        }

        return covariantReturn();
    }
560225
private function computeAssociationChanges(object $parentDocument, array $assoc, $value) : void
    {
        $isNewParentDocument   = isset($this->documentInsertions[spl_object_hash($parentDocument)]);
        $class                 = $this->dm->getClassMetadata(get_class($parentDocument));
        $topOrExistingDocument = ( ! $isNewParentDocument || ! $class->isEmbeddedDocument);

        if ($value instanceof GhostObjectInterface && ! $value->isProxyInitialized()) {
            return;
        }

        if ($value instanceof PersistentCollectionInterface && $value->isDirty() && $value->getOwner() !== null && ($assoc['isOwningSide'] || isset($assoc['embedded']))) {
            if ($topOrExistingDocument || CollectionHelper::usesSet($assoc['strategy'])) {
                $this->scheduleCollectionUpdate($value);
            }

            $topmostOwner                                               = $this->getOwningDocument($value->getOwner());
            $this->visitedCollections[spl_object_hash($topmostOwner)][] = $value;
            if (! empty($assoc['orphanRemoval']) || isset($assoc['embedded'])) {
                $value->initialize();
                foreach ($value->getDeletedDocuments() as $orphan) {
                    $this->scheduleOrphanRemoval($orphan);
                }
            }
        }

        // Look through the documents, and in any of their associations,
        // for transient (new) documents, recursively. ("Persistence by reachability")
        // Unwrap. Uninitialized collections will simply be empty.
        $unwrappedValue = $assoc['type'] === ClassMetadata::ONE ? [$value] : $value->unwrap();

        $count = 0;
        foreach ($unwrappedValue as $key => $entry) {
            if (! is_object($entry)) {
                throw new InvalidArgumentException(
                    sprintf('Expected object, found "%s" in %s::%s', $entry, get_class($parentDocument), $assoc['name'])
                );
            }

            $targetClass = $this->dm->getClassMetadata(get_class($entry));

            $state = $this->getDocumentState($entry, self::STATE_NEW);

            // Handle "set" strategy for multi-level hierarchy
            $pathKey = ! isset($assoc['strategy']) || CollectionHelper::isList($assoc['strategy']) ? $count : $key;
            $path    = $assoc['type'] === 'many' ? $assoc['name'] . '.' . $pathKey : $assoc['name'];

            $count++;

            switch ($state) {
                case self::STATE_NEW:
                    if (! $assoc['isCascadePersist']) {
                        throw new InvalidArgumentException('A new document was found through a relationship that was not'
                            . ' configured to cascade persist operations: ' . $this->objToStr($entry) . '.'
                            . ' Explicitly persist the new document or configure cascading persist operations'
                            . ' on the relationship.');
                    }

                    $this->persistNew($targetClass, $entry);
                    $this->setParentAssociation($entry, $assoc, $parentDocument, $path);
                    $this->computeChangeSet($targetClass, $entry);
                    break;

                case self::STATE_MANAGED:
                    if ($targetClass->isEmbeddedDocument) {
                        [, $knownParent ] = $this->getParentAssociation($entry);
                        if ($knownParent && $knownParent !== $parentDocument) {
                            $entry = clone $entry;
                            if ($assoc['type'] === ClassMetadata::ONE) {
                                $class->setFieldValue($parentDocument, $assoc['fieldName'], $entry);
                                $this->setOriginalDocumentProperty(spl_object_hash($parentDocument), $assoc['fieldName'], $entry);
                                $poid = spl_object_hash($parentDocument);
                                if (isset($this->documentChangeSets[$poid][$assoc['fieldName']])) {
                                    $this->documentChangeSets[$poid][$assoc['fieldName']][1] = $entry;
                                }
                            } else {
                                // must use unwrapped value to not trigger orphan removal
                                $unwrappedValue[$key] = $entry;
                            }
                            $this->persistNew($targetClass, $entry);
                        }
                        $this->setParentAssociation($entry, $assoc, $parentDocument, $path);
                        $this->computeChangeSet($targetClass, $entry);
                    }
                    break;

                case self::STATE_REMOVED:
                    // Consume the $value as array (it's either an array or an ArrayAccess)
                    // and remove the element from Collection.
                    if ($assoc['type'] === ClassMetadata::MANY) {
                        unset($value[$key]);
                    }
                    break;

                case self::STATE_DETACHED:
                    // Can actually not happen right now as we assume STATE_NEW,
                    // so the exception will be raised from the DBAL layer (constraint violation).
                    throw new InvalidArgumentException('A detached document was found through a '
                        . 'relationship during cascading a persist operation.');

                default:
                    // MANAGED associated documents are already taken into account
                    // during changeset calculation anyway, since they are in the identity map.
            }
        }
    }
631095
private static void dirToTarArchiveOutputStreamRecursive(FileStatus dirFileStatus, FileSystem fs,
      Optional<Path> destDir, TarArchiveOutputStream tarArchiveOutputStream) throws IOException {

    Preconditions.checkState(fs.isDirectory(dirFileStatus.getPath()));

    Path dir = destDir.isPresent() ? new Path(destDir.get(), dirFileStatus.getPath().getName())
        : new Path(dirFileStatus.getPath().getName());
    dirToTarArchiveOutputStream(dir, tarArchiveOutputStream);

    for (FileStatus childFileStatus : fs.listStatus(dirFileStatus.getPath())) {
      Path childFile = new Path(dir, childFileStatus.getPath().getName());

      if (fs.isDirectory(childFileStatus.getPath())) {
        dirToTarArchiveOutputStreamRecursive(childFileStatus, fs, Optional.of(childFile), tarArchiveOutputStream);
      } else {
        try (FSDataInputStream fsDataInputStream = fs.open(childFileStatus.getPath())) {
          fileToTarArchiveOutputStream(childFileStatus, fsDataInputStream, childFile, tarArchiveOutputStream);
        }
      }
    }
  }
1163675
function(parentItem, children) {
			// Note that the Parents property is not available for metadatas retrieved with fetchChildren().
			var parents = parentItem.Projects ? [] : [parentItem].concat(parentItem.Parents || []);
			if (this.excludeFiles || this.excludeFolders || this.filteredResources) {
				var filtered = [];
				children.forEach(function(child) {
					var exclude = child.Directory ? this.excludeFolders : this.excludeFiles;
					if(this.filteredResources && this.filter) {
						exclude = exclude || this.filter.isFiltered(child.Name);
					}
					if (!exclude) {
						filtered.push(child);
						child.parent = parentItem;
						if (!child.Parents) {
							child.Parents = parents;
						}
					}
				}.bind(this));
				children = filtered;
			} else {
				children.forEach(function(child) {
					child.parent = parentItem;
					if (!child.Parents) {
						child.Parents = parents;
					}
				});
			}

			//link the parent and children together
			parentItem.children = children;

			// not ideal, but for now, sort here so it's done in one place.
			// this should really be something pluggable that the UI defines
			parentItem.children.sort(this.sortChildren);
			return children;
		}
977209
private static void fileToTarArchiveOutputStream(FileStatus fileStatus, FSDataInputStream fsDataInputStream,
      Path destFile, TarArchiveOutputStream tarArchiveOutputStream) throws IOException {
    TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(formatPathToFile(destFile));
    tarArchiveEntry.setSize(fileStatus.getLen());
    tarArchiveEntry.setModTime(System.currentTimeMillis());
    tarArchiveOutputStream.putArchiveEntry(tarArchiveEntry);

    try {
      IOUtils.copy(fsDataInputStream, tarArchiveOutputStream);
    } finally {
      tarArchiveOutputStream.closeArchiveEntry();
    }
  }
341256
public final void collapseParent(int parentPosition) {
        if (isExpanded(parentPosition)) {
            mExpandItemArray.append(parentPosition, false);

            int position = positionFromParentPosition(parentPosition);
            int childCount = childItemCount(parentPosition);
            notifyItemRangeRemoved(position + 1, childCount);
        }
    }
536000
protected void processParentEvent() throws Exception {
        // get current children snapshot and reset this watch.
        Set<String> children = new TreeSet<String>(m_zk.getChildren(m_rootNode, m_parentWatch));
        // intersect to get newChildren and update m_lastChildren to the current set.
        Set<String> newChildren = new HashSet<String>(children);
        newChildren.removeAll(m_lastChildren);
        m_lastChildren = children;

        List<ByteArrayCallback> callbacks = new ArrayList<ByteArrayCallback>();
        for (String child : children) {
            ByteArrayCallback cb = new ByteArrayCallback();
            // set watches on new children.
            if(newChildren.contains(child)) {
                m_zk.getData(ZKUtil.joinZKPath(m_rootNode, child), m_childWatch, cb, null);
            } else {
                m_zk.getData(ZKUtil.joinZKPath(m_rootNode, child), false, cb, null);
            }

            callbacks.add(cb);
        }

        HashMap<Integer, LeaderCallBackInfo> cache = new HashMap<Integer, LeaderCallBackInfo>();
        for (ByteArrayCallback callback : callbacks) {
            try {
                byte payload[] = callback.get();
                // During initialization children node may contain no data.
                if (payload == null) {
                    continue;
                }
                String data = new String(payload, "UTF-8");
                LeaderCallBackInfo info = LeaderCache.buildLeaderCallbackFromString(data);
                Integer partitionId = getPartitionIdFromZKPath(callback.getPath());
                cache.put(partitionId, info);
            } catch (KeeperException.NoNodeException e) {
                // child may have been deleted between the parent trigger and getData.
            }
        }

        m_publicCache = ImmutableMap.copyOf(cache);
        if (m_cb != null) {
            m_cb.run(m_publicCache);
        }
    }
1012732
function mergeAssets (parentVal, childVal) {
  var res = Object.create(parentVal || null);
  return childVal
    ? extend(res, childVal)
    : res
}
108803
private void createFolder(final StructrShellCommand parent, final Folder currentFolder, final String target) throws FrameworkException, IOException {

		final App app = StructrApp.getInstance();
		if (target.contains("/")) {

			final int lastSlashIndex      = target.lastIndexOf("/");
			final String targetFolderPath = target.substring(0, lastSlashIndex);
			final String targetFolderName = target.substring(lastSlashIndex + 1);
			final Folder parentFolder     = parent.findRelativeFolder(currentFolder, targetFolderPath);

			if (parentFolder != null) {

				checkAndCreateFolder(app, parent, parentFolder, targetFolderName);

			} else {

				term.println("Folder " + targetFolderPath + " does not exist");
			}

		} else {

			checkAndCreateFolder(app, parent, currentFolder, target);
		}
	}
1239195
private static void createParentFile(final File file) throws ExtractionException {
        final File parent = file.getParentFile();
        if (!parent.isDirectory() && !parent.mkdirs()) {
            final String msg = String.format(
                    "Unable to build directory '%s'.",
                    parent.getAbsolutePath());
            throw new ExtractionException(msg);
        }
    }
1374832
protected function isParentArchived()
    {
        if ($parentID = $this->ParentID) {
            /** @var SiteTree $parentPage */
            $parentPage = Versioned::get_latest_version(self::class, $parentID);
            if (!$parentPage || !$parentPage->isOnDraft()) {
                return true;
            }
        }
        return false;
    }