001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.ecm.platform.audit.io; 021 022import java.util.Collections; 023import java.util.HashMap; 024import java.util.List; 025import java.util.Map; 026 027import org.nuxeo.ecm.core.api.DocumentRef; 028import org.nuxeo.ecm.platform.audit.api.LogEntry; 029import org.nuxeo.ecm.platform.io.api.IOResources; 030 031/** 032 * IO Resources for logs 033 * <p> 034 * Holds a map of document resources, with a document reference as key, and a list of RDF resources as values. 035 */ 036public class IOAuditResources implements IOResources { 037 038 private static final long serialVersionUID = 8095413628515011558L; 039 040 private Map<DocumentRef, List<LogEntry>> docLogs = new HashMap<DocumentRef, List<LogEntry>>(); 041 042 public IOAuditResources(Map<DocumentRef, List<LogEntry>> docLogs) { 043 this.docLogs = docLogs; 044 } 045 046 public List<LogEntry> getDocumentLogs(DocumentRef docRef) { 047 List<LogEntry> logs = docLogs.get(docRef); 048 if (logs != null) { 049 return Collections.unmodifiableList(logs); 050 } 051 return null; 052 } 053 054 public Map<DocumentRef, List<LogEntry>> getLogsMap() { 055 return Collections.unmodifiableMap(docLogs); 056 } 057 058}