package org.alfresco.repo.publishing; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.alfresco.service.cmr.publishing.PublishingPackage; import org.alfresco.service.cmr.publishing.PublishingPackageEntry; import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian * @author Nick Smith * @since 4.0 */ public class PublishingPackageImpl implements PublishingPackage { private final Map entries; private final Set nodesToPublish; private final Set nodesToUnpublish; public PublishingPackageImpl(Map entries) { Set toPublish = new HashSet(); Set toUnpublish = new HashSet(); for (PublishingPackageEntry entry : entries.values()) { NodeRef node = entry.getNodeRef(); if (entry.isPublish()) { toPublish.add(node); } else { toUnpublish.add(node); } } HashMap entryMap = new HashMap(entries); this.entries = Collections.unmodifiableMap(entryMap); this.nodesToPublish = Collections.unmodifiableSet(toPublish); this.nodesToUnpublish = Collections.unmodifiableSet(toUnpublish); } /** * {@inheritDoc} */ public Collection getEntries() { return entries.values(); } public Map getEntryMap() { return entries; } /** * {@inheritDoc} */ public Set getNodesToPublish() { return nodesToPublish; } /** * {@inheritDoc} */ @Override public Set getNodesToUnpublish() { return nodesToUnpublish; } }