001/* 002 * (C) Copyright 2006-2008 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 * bstefanescu 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.core.rest; 023 024import java.util.List; 025 026import javax.ws.rs.GET; 027 028import org.nuxeo.ecm.core.api.DocumentModel; 029import org.nuxeo.ecm.platform.audit.api.LogEntry; 030import org.nuxeo.ecm.platform.audit.api.Logs; 031import org.nuxeo.ecm.webengine.model.View; 032import org.nuxeo.ecm.webengine.model.WebAdapter; 033import org.nuxeo.ecm.webengine.model.impl.DefaultAdapter; 034import org.nuxeo.runtime.api.Framework; 035 036/** 037 * Audit Service - manage document versions TODO not yet implemented 038 * <p> 039 * Accepts the following methods: 040 * <ul> 041 * <li>GET - get audit records 042 * </ul> 043 * 044 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 045 */ 046@WebAdapter(name = "audits", type = "AuditService", targetType = "Document") 047public class AuditService extends DefaultAdapter { 048 049 @GET 050 public Object doGet() { 051 return new View(getTarget(), "audits").resolve(); 052 } 053 054 public List<LogEntry> getAudits() { 055 Logs logs = Framework.getService(Logs.class); 056 DocumentObject document = (DocumentObject) getTarget(); 057 DocumentModel model = document.getAdapter(DocumentModel.class); 058 String id = model.getId(); 059 String repo = model.getRepositoryName(); 060 return logs.getLogEntriesFor(id, repo); 061 } 062 063}