Created
January 19, 2015 16:28
-
-
Save vpasquier/5f017f8fffdc806af6dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors. | |
* | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the GNU Lesser General Public License | |
* (LGPL) version 2.1 which accompanies this distribution, and is available at | |
* http://www.gnu.org/licenses/lgpl-2.1.html | |
* | |
* This library is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
* Lesser General Public License for more details. | |
* | |
* Contributors: | |
* vpasquier <[email protected]> | |
*/ | |
package org.nuxeo.binary.metadata.internals; | |
import java.util.LinkedList; | |
import org.nuxeo.binary.metadata.api.BinaryMetadataService; | |
import org.nuxeo.ecm.core.api.DocumentModel; | |
import org.nuxeo.ecm.core.event.impl.DocumentEventContext; | |
import org.nuxeo.ecm.core.work.AbstractWork; | |
import org.nuxeo.runtime.api.Framework; | |
/** | |
* Work handling binary metadata updates. | |
* | |
* @since 7.2 | |
*/ | |
public class BinaryMetadataWork extends AbstractWork { | |
private static final long serialVersionUID = 1L; | |
private static final String BINARY_METADATA_WORK = "binary_metadata_work"; | |
public static final String BINARY_METADATA_WORK_TITLE = "Binary Metadata Update Worker"; | |
protected final DocumentModel doc; | |
protected final LinkedList<MetadataMappingDescriptor> mappingDescriptors; | |
protected final DocumentEventContext docCtx; | |
public BinaryMetadataWork(DocumentModel doc, LinkedList<MetadataMappingDescriptor> mappingDescriptors, | |
DocumentEventContext docCtx) { | |
super("BinaryMetadataUpdate|docId=" + doc.getId()); | |
this.doc = doc; | |
this.mappingDescriptors = mappingDescriptors; | |
this.docCtx = docCtx; | |
} | |
@Override | |
public String getCategory() { | |
return BINARY_METADATA_WORK; | |
} | |
@Override | |
public String getTitle() { | |
return BINARY_METADATA_WORK_TITLE; | |
} | |
@Override | |
public void work() { | |
setProgress(Progress.PROGRESS_INDETERMINATE); | |
setStatus("Updating Metadata"); | |
initSession(); | |
BinaryMetadataService binaryMetadataService = Framework.getLocalService(BinaryMetadataService.class); | |
binaryMetadataService.handleUpdate(mappingDescriptors, doc, docCtx); | |
setStatus("Metadata Update Done"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment