Project

General

Profile

Revision 7851

Added by Jing Tao over 7 years ago

Check if the all components of a resource map have been processed before processing the resource map.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/resourcemap/ResourceMapSubprocessor.java
126 126
    private List<SolrDoc> processResourceMap(SolrDoc indexDocument, Document resourceMapDocument)
127 127
                    throws XPathExpressionException, IOException, SAXException, ParserConfigurationException, EncoderException, SolrServerException, NotImplemented, NotFound, UnsupportedType{
128 128
        ResourceMap resourceMap = new ResourceMap(resourceMapDocument);
129
        List<String> documentIds = resourceMap.getAllDocumentIDs();
129
        List<String> documentIds = resourceMap.getAllDocumentIDs();//this list includes the resourceMap id itself.
130 130
        //List<SolrDoc> updateDocuments = getHttpService().getDocuments(getSolrQueryUri(), documentIds);
131
        List<SolrDoc> updateDocuments = getSolrDocs(documentIds);
131
        List<SolrDoc> updateDocuments = getSolrDocs(resourceMap.getIdentifier(), documentIds);
132 132
        List<SolrDoc> mergedDocuments = resourceMap.mergeIndexedDocuments(updateDocuments);
133 133
        /*if(mergedDocuments != null) {
134 134
            for(SolrDoc doc : mergedDocuments) {
......
143 143
        return mergedDocuments;
144 144
    }
145 145
    
146
    private List<SolrDoc> getSolrDocs(String resourceMapId, List<String> ids) throws SolrServerException, IOException, ParserConfigurationException, SAXException, XPathExpressionException, NotImplemented, NotFound, UnsupportedType {
147
        List<SolrDoc> list = new ArrayList<SolrDoc>();
148
        if(ids != null) {
149
            for(String id : ids) {
150
                SolrDoc doc = getSolrDoc(id);
151
                if(doc != null) {
152
                    list.add(doc);
153
                } else if ( !id.equals(resourceMapId)) {
154
                    throw new SolrServerException("Solr index doesn't have the information about the id "+id+" which is a component in the resource map "+resourceMapId+". Metacat-Index can't process the resource map prior to its components.");
155
                }
156
            }
157
        }
158
        return list;
159
    } 
160
    
146 161
    /*
147 162
     * Get the SolrDoc list for the list of the ids.
148 163
     */

Also available in: Unified diff