001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * <a href="mailto:[email protected]">Anahide Tchertchian</a> 018 * 019 * $Id: IOResourceAdapter.java 25080 2007-09-18 14:52:20Z atchertchian $ 020 */ 021 022package org.nuxeo.ecm.platform.io.api; 023 024import java.io.InputStream; 025import java.io.OutputStream; 026import java.io.Serializable; 027import java.util.Collection; 028import java.util.Map; 029 030import org.nuxeo.ecm.core.api.DocumentRef; 031import org.nuxeo.ecm.core.io.DocumentTranslationMap; 032 033/** 034 * Resource adapter holding the import/export for document associated resources. 035 * 036 * @author <a href="mailto:[email protected]">Anahide Tchertchian</a> 037 */ 038public interface IOResourceAdapter extends Serializable { 039 040 /** 041 * Returns properties. 042 */ 043 Map<String, Serializable> getProperties(); 044 045 /** 046 * Set properties. 047 */ 048 void setProperties(Map<String, Serializable> properties); 049 050 /** 051 * Extracts resources for given document locations. 052 * 053 * @param repo TODO 054 * @param sources locations of documents to consider. Has to include documents children if needed. 055 * @return a structure holding associated resources. 056 */ 057 IOResources extractResources(String repo, Collection<DocumentRef> sources); 058 059 /** 060 * Returns translated resources once copy has been done, passing a correspondence map. 061 * 062 * @param repo target repository for resources. 063 * @param resources resources previously extracted thanks to 064 * {@link IOResourceAdapter#extractResources(String, Collection)} 065 * @param map correspondence map between old locations and new ones. 066 * @return translated resources. 067 */ 068 IOResources translateResources(String repo, IOResources resources, DocumentTranslationMap map); 069 070 /** 071 * Persists resources. 072 * 073 * @param newResources resources previously extracted thanks to 074 * {@link IOResourceAdapter#extractResources(String, Collection)} or 075 * {@link IOResourceAdapter#translateResources(String, IOResources, DocumentTranslationMap)} 076 */ 077 void storeResources(IOResources newResources); 078 079 /** 080 * Export resources as XML. 081 * 082 * @param out stream where export will be written. 083 * @param newResources resources previously extracted thanks to 084 * {@link IOResourceAdapter#extractResources(String, Collection)} or 085 * {@link IOResourceAdapter#translateResources(String, IOResources, DocumentTranslationMap)} 086 */ 087 void getResourcesAsXML(OutputStream out, IOResources newResources); 088 089 /** 090 * Returns resources built from given stream. 091 */ 092 IOResources loadResourcesFromXML(InputStream stream); 093 094}