Project

General

Profile

« Previous | Next » 

Revision 8023

Added by Jing Tao almost 11 years ago

Use the ResourceMapFactory rather than the ResourceMap constructor to build a resource map.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/resourcemap/ResourceMapSubprocessor.java
69 69
import org.dataone.cn.indexer.parser.AbstractDocumentSubprocessor;
70 70
import org.dataone.cn.indexer.parser.IDocumentSubprocessor;
71 71
import org.dataone.cn.indexer.resourcemap.ResourceMap;
72
import org.dataone.cn.indexer.resourcemap.ResourceMapFactory;
72 73
import org.dataone.cn.indexer.solrhttp.SolrDoc;
73 74
import org.dataone.cn.indexer.solrhttp.SolrElementField;
74 75
import org.dataone.service.exceptions.NotFound;
75 76
import org.dataone.service.exceptions.NotImplemented;
76 77
import org.dataone.service.exceptions.UnsupportedType;
77 78
import org.dataone.service.types.v1.Subject;
79
import org.dspace.foresite.OREParserException;
78 80
import org.w3c.dom.Document;
79 81
import org.w3c.dom.Element;
80 82
import org.w3c.dom.NodeList;
......
113 115
    @Override
114 116
    public Map<String, SolrDoc> processDocument(String identifier, Map<String, SolrDoc> docs,
115 117
    Document doc) throws IOException, EncoderException, SAXException,
116
    XPathExpressionException, ParserConfigurationException, SolrServerException, NotImplemented, NotFound, UnsupportedType {
118
    XPathExpressionException, ParserConfigurationException, SolrServerException, NotImplemented, NotFound, UnsupportedType, OREParserException {
117 119
        SolrDoc resourceMapDoc = docs.get(identifier);
118 120
        List<SolrDoc> processedDocs = processResourceMap(resourceMapDoc, doc);
119 121
        Map<String, SolrDoc> processedDocsMap = new HashMap<String, SolrDoc>();
......
124 126
    }
125 127

  
126 128
    private List<SolrDoc> processResourceMap(SolrDoc indexDocument, Document resourceMapDocument)
127
                    throws XPathExpressionException, IOException, SAXException, ParserConfigurationException, EncoderException, SolrServerException, NotImplemented, NotFound, UnsupportedType{
128
        ResourceMap resourceMap = new ResourceMap(resourceMapDocument);
129
                    throws XPathExpressionException, IOException, SAXException, ParserConfigurationException, EncoderException, SolrServerException, NotImplemented, NotFound, UnsupportedType, OREParserException{
130
        //ResourceMap resourceMap = new ResourceMap(resourceMapDocument);
131
        ResourceMap resourceMap = ResourceMapFactory.buildResourceMap(resourceMapDocument);
129 132
        List<String> documentIds = resourceMap.getAllDocumentIDs();//this list includes the resourceMap id itself.
130 133
        //List<SolrDoc> updateDocuments = getHttpService().getDocuments(getSolrQueryUri(), documentIds);
131 134
        List<SolrDoc> updateDocuments = getSolrDocs(resourceMap.getIdentifier(), documentIds);
metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java
63 63
import org.dataone.cn.indexer.parser.SolrField;
64 64
import org.dataone.cn.indexer.resourcemap.ResourceEntry;
65 65
import org.dataone.cn.indexer.resourcemap.ResourceMap;
66
import org.dataone.cn.indexer.resourcemap.ResourceMapFactory;
66 67
import org.dataone.cn.indexer.solrhttp.SolrDoc;
67 68
import org.dataone.cn.indexer.solrhttp.SolrElementField;
68 69
import org.dataone.service.exceptions.NotFound;
......
73 74
import org.dataone.service.types.v1.Identifier;
74 75
import org.dataone.service.types.v1.SystemMetadata;
75 76
import org.dataone.service.util.TypeMarshaller;
77
import org.dspace.foresite.OREParserException;
76 78
import org.jibx.runtime.JiBXException;
77 79
import org.w3c.dom.Document;
78 80
import org.xml.sax.SAXException;
......
450 452
     * @throws NotFound 
451 453
     * @throws NotImplemented 
452 454
     * @throws ServiceFailure 
455
     * @throws OREParserException 
453 456
     */
454 457
    public void update(String pid, List<String> obsoleteIds, SystemMetadata systemMetadata, InputStream data) 
455 458
                    throws IOException, SAXException, ParserConfigurationException,
456
                    XPathExpressionException, SolrServerException, JiBXException, EncoderException, NotImplemented, NotFound, UnsupportedType, ServiceFailure {
459
                    XPathExpressionException, SolrServerException, JiBXException, EncoderException, NotImplemented, NotFound, UnsupportedType, ServiceFailure, OREParserException {
457 460
        checkParams(pid, systemMetadata, data);
458 461
        boolean isArchive = systemMetadata.getArchived();
459 462
        if(isArchive || systemMetadata.getObsoletedBy() != null) {
......
476 479
    }
477 480
    
478 481
    
479
    private void removeObsoletesChain(String obsoleteId, List<String> obsoleteIdChain) throws SolrServerException, IOException, ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SAXException, ParserConfigurationException {
482
    private void removeObsoletesChain(String obsoleteId, List<String> obsoleteIdChain) throws SolrServerException, IOException, ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SAXException, ParserConfigurationException, OREParserException {
480 483
        if(obsoleteId != null && !obsoleteId.trim().equals("")) {
481 484
            if(obsoleteIdChain == null || obsoleteIdChain.isEmpty()) {
482 485
                throw new SolrServerException("SolrIndex.removeObsoletesChain - The obsoletes chain can't be null or empty since the system metadata already has the obsoletes element."); 
......
502 505
     * @throws NotImplemented 
503 506
     * @throws XPathExpressionException 
504 507
     * @throws ServiceFailure 
508
     * @throws OREParserException 
505 509
     */
506
    private void remove(List<String> pidList) throws IOException, SolrServerException, ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SAXException, ParserConfigurationException {
510
    private void remove(List<String> pidList) throws IOException, SolrServerException, ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SAXException, ParserConfigurationException, OREParserException {
507 511
        if(pidList != null) {
508 512
            for(String id : pidList) {
509 513
                remove(id);
......
523 527
     * @throws NotImplemented 
524 528
     * @throws XPathExpressionException 
525 529
     * @throws ServiceFailure 
530
     * @throws OREParserException 
526 531
     */
527
    public void remove(String pid) throws IOException, SolrServerException, ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SAXException, ParserConfigurationException {
532
    public void remove(String pid) throws IOException, SolrServerException, ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SAXException, ParserConfigurationException, OREParserException {
528 533
        if (isDataPackage(pid)) {
529 534
            removeDataPackage(pid);
530 535
        } else if (isPartOfDataPackage(pid)) {
......
540 545
    /*
541 546
     * Remove a resource map pid
542 547
     */
543
    private void removeDataPackage(String pid) throws ServiceFailure, SAXException, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SolrServerException, IOException, ParserConfigurationException  {
548
    private void removeDataPackage(String pid) throws ServiceFailure, SAXException, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SolrServerException, IOException, ParserConfigurationException, OREParserException  {
544 549
        Document resourceMapDoc = generateXmlDocument(DistributedMapsFactory.getDataObject(pid));
545
        ResourceMap resourceMap = new ResourceMap(resourceMapDoc);
550
        //ResourceMap resourceMap = new ResourceMap(resourceMapDoc);
551
        ResourceMap resourceMap = ResourceMapFactory.buildResourceMap(resourceMapDoc);
546 552
        List<String> documentIds = resourceMap.getAllDocumentIDs();
547 553
        List<SolrDoc> indexDocuments =ResourceMapSubprocessor.getSolrDocs(documentIds);
548 554
        removeFromIndex(pid);
metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/IndexGenerator.java
58 58
import org.dataone.service.types.v1.Identifier;
59 59
import org.dataone.service.types.v1.ObjectFormatIdentifier;
60 60
import org.dataone.service.types.v1.SystemMetadata;
61
import org.dspace.foresite.OREParserException;
61 62
import org.xml.sax.SAXException;
62 63

  
63 64
import com.hazelcast.core.IMap;
......
160 161
     * @throws UnsupportedType 
161 162
     * @throws NotFound 
162 163
     * @throws XPathExpressionException 
164
     * @throws OREParserException 
163 165
     */
164 166
    public void indexAll() throws InvalidRequest, InvalidToken,
165
                NotAuthorized, NotImplemented, ServiceFailure, SolrServerException, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException, XPathExpressionException, NotFound, UnsupportedType, IOException, SAXException, ParserConfigurationException {
167
                NotAuthorized, NotImplemented, ServiceFailure, SolrServerException, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException, XPathExpressionException, NotFound, UnsupportedType, IOException, SAXException, ParserConfigurationException, OREParserException {
166 168
        Date since = null;
167 169
        Date until = null;
168 170
        index(since, until);
......
187 189
     * @throws UnsupportedType 
188 190
     * @throws NotFound 
189 191
     * @throws XPathExpressionException 
192
     * @throws OREParserException 
190 193
     */
191 194
    public void index(Date since) throws InvalidRequest, InvalidToken, 
192
                    NotAuthorized, NotImplemented, ServiceFailure, SolrServerException, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException, XPathExpressionException, NotFound, UnsupportedType, IOException, SAXException, ParserConfigurationException {
195
                    NotAuthorized, NotImplemented, ServiceFailure, SolrServerException, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException, XPathExpressionException, NotFound, UnsupportedType, IOException, SAXException, ParserConfigurationException, OREParserException {
193 196
        Date until = null;
194 197
        index(since, until);
195 198
    }
......
214 217
     * @throws UnsupportedType 
215 218
     * @throws NotFound 
216 219
     * @throws XPathExpressionException 
220
     * @throws OREParserException 
217 221
     */
218 222
    public void index(Date since, Date until) throws SolrServerException, InvalidRequest, 
219
                                                InvalidToken, NotAuthorized, NotImplemented, ServiceFailure, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException, XPathExpressionException, NotFound, UnsupportedType, IOException, SAXException, ParserConfigurationException {
223
                                                InvalidToken, NotAuthorized, NotImplemented, ServiceFailure, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException, XPathExpressionException, NotFound, UnsupportedType, IOException, SAXException, ParserConfigurationException, OREParserException {
220 224
        Date processedDate = null;
221 225
        List<String> solrIds = null;
222 226
        initSystemMetadataMap();
......
500 504
        } catch (ParserConfigurationException e) {
501 505
            // TODO Auto-generated catch block
502 506
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
507
        } catch (OREParserException e) {
508
            // TODO Auto-generated catch block
509
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
503 510
        }
504 511
    }
505 512
    
......
678 685
    /*
679 686
     * Remove the solr index for the list of ids
680 687
     */
681
    private void removeIndex(List<String> ids) throws ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, IOException, SolrServerException, SAXException, ParserConfigurationException {
688
    private void removeIndex(List<String> ids) throws ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, IOException, SolrServerException, SAXException, ParserConfigurationException, OREParserException {
682 689
        if(ids!= null) {
683 690
            for(String id :ids) {
684 691
                removeIndex(id);
......
689 696
    /*
690 697
     * Remove the index for the id
691 698
     */
692
    private void removeIndex(String id) throws ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, IOException, SolrServerException, SAXException, ParserConfigurationException  {
699
    private void removeIndex(String id) throws ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, IOException, SolrServerException, SAXException, ParserConfigurationException, OREParserException  {
693 700
        if(id != null) {
694 701
            solrIndex.remove(id);
695 702
        }

Also available in: Unified diff