001/* 002 * Copyright (c) 2015 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Nuxeo - initial API and implementation 011 * 012 */ 013 014package org.nuxeo.ecm.core.io.impl.extensions; 015 016import org.dom4j.Element; 017import org.nuxeo.ecm.core.api.DocumentModel; 018import org.nuxeo.ecm.core.api.Lock; 019import org.nuxeo.ecm.core.io.ExportExtension; 020import org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl; 021 022/** 023 * Allows to export Lock information as part of the XML strem 024 * 025 * @since 7.4 026 */ 027public class LockExporterExtension implements ExportExtension { 028 029 @Override 030 public void updateExport(DocumentModel docModel, ExportedDocumentImpl result) throws Exception { 031 032 if (docModel.isLocked()) { 033 Element lockElement = result.getDocument().getRootElement().addElement("lockInfo"); 034 Lock lock = docModel.getLockInfo(); 035 Long created = lock.getCreated().getTimeInMillis(); 036 String owner = lock.getOwner(); 037 lockElement.addElement("created").setText(created.toString()); 038 ; 039 lockElement.addElement("owner").setText(owner.toString()); 040 ; 041 } 042 } 043 044}