/** * Copyright 2008 The University of North Carolina at Chapel Hill * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package edu.unc.lib.dl.data.ingest.solr.action; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import edu.unc.lib.dl.data.ingest.solr.SolrUpdateRequest; import edu.unc.lib.dl.data.ingest.solr.exception.IndexingException; import edu.unc.lib.dl.data.ingest.solr.exception.UnsupportedContentModelException; import edu.unc.lib.dl.data.ingest.solr.indexing.DocumentIndexingPackage; /** * Updates or adds the metadata for a single object * * @author bbpennel * */ public class UpdateObjectAction extends AbstractIndexingAction { private static final Logger log = LoggerFactory.getLogger(UpdateObjectAction.class); @Override public void performAction(SolrUpdateRequest updateRequest) throws IndexingException { // Retrieve object metadata from Fedora and add to update document list DocumentIndexingPackage dip = updateRequest.getDocumentIndexingPackage(); if (dip == null) { dip = factory.createDip(updateRequest.getPid()); updateRequest.setDocumentIndexingPackage(dip); } try { pipeline.process(dip); if (this.addDocumentMode) { solrUpdateDriver.addDocument(dip.getDocument()); } else { solrUpdateDriver.updateDocument("set", dip.getDocument()); } } catch (UnsupportedContentModelException e) { log.debug("Skipping indexing of object {} because of invalid content model", dip.getPid().getPid(), e); } } }