Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A class that gets Accession Number, check for uniqueness
4
 *             and register it into db
5
 *  Copyright: 2000 Regents of the University of California and the
6
 *             National Center for Ecological Analysis and Synthesis
7
 *    Authors: Jivka Bojilova, Matt Jones
8
 *
9
 *   '$Author: leinfelder $'
10
 *     '$Date: 2011-11-02 20:40:12 -0700 (Wed, 02 Nov 2011) $'
11
 * '$Revision: 6595 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27
package edu.ucsb.nceas.metacat.index;
28

    
29
import java.io.FileInputStream;
30
import java.io.FileNotFoundException;
31
import java.io.InputStream;
32
import java.util.ArrayList;
33
import java.util.Calendar;
34
import java.util.Date;
35
import java.util.List;
36
import java.util.TimerTask;
37
import java.util.Vector;
38

    
39
import org.apache.commons.logging.Log;
40
import org.apache.commons.logging.LogFactory;
41
import org.apache.solr.client.solrj.SolrServerException;
42
import org.dataone.client.MNode;
43
import org.dataone.configuration.Settings;
44
import org.dataone.service.exceptions.InvalidRequest;
45
import org.dataone.service.exceptions.InvalidToken;
46
import org.dataone.service.exceptions.NotAuthorized;
47
import org.dataone.service.exceptions.NotImplemented;
48
import org.dataone.service.exceptions.ServiceFailure;
49
import org.dataone.service.types.v1.Identifier;
50
import org.dataone.service.types.v1.ObjectFormatIdentifier;
51
import org.dataone.service.types.v1.ObjectInfo;
52
import org.dataone.service.types.v1.ObjectList;
53
import org.dataone.service.types.v1.SystemMetadata;
54

    
55
import com.hazelcast.core.IMap;
56
import com.hazelcast.core.ISet;
57

    
58
import edu.ucsb.nceas.metacat.index.event.EventlogFactory;
59
import edu.ucsb.nceas.metacat.index.event.IndexEvent;
60
import edu.ucsb.nceas.metacat.index.event.IndexEventLogException;
61

    
62

    
63
/**
64
 * A class represents the object to generate massive solr indexes.
65
 * This can happen during an update of Metacat (generating index for all existing documents)
66
 * or regenerate index for those documents
67
 * failing to build index during the insert or update.
68
 * 
69
 * @author tao
70
 *
71
 */
72
public class IndexGenerator extends TimerTask {
73
    
74
    private static final int FIRST =0;
75
    private static final int SECOND =1;
76
    public static final int WAITTIME = 10000;
77
    public static final int MAXWAITNUMBER = 180;
78
    private static final String HTTP = "http://";
79
    private static final String MNAPPENDIX = "/d1/mn";
80
    private static final String RESOURCEMAPPROPERYNAME = "index.resourcemap.namespace";
81
    public static final String WAITIMEPOPERTYNAME = "index.regenerate.start.waitingtime";
82
    public static final String MAXATTEMPTSPROPERTYNAME = "index.regenerate.start.maxattempts";
83
    
84
    private static int waitingTime = WAITTIME;
85
    private static int maxAttempts = MAXWAITNUMBER;
86
    
87
    private SolrIndex solrIndex = null;
88
    //private SystemMetadataEventListener systemMetadataListener = null;
89
    private IMap<Identifier, SystemMetadata> systemMetadataMap;
90
    private IMap<Identifier, String> objectPathMap;
91
    private Log log = LogFactory.getLog(IndexGenerator.class);
92
    //private MNode mNode = null;
93
    private static List<String> resourceMapNamespaces = null;
94
    
95
    /**
96
     * Constructor
97
     * @param solrIndex
98
     * @param systemMetadataListener
99
     */
100
    public IndexGenerator(SolrIndex solrIndex) {
101
        this.solrIndex = solrIndex;
102
        resourceMapNamespaces = Settings.getConfiguration().getList(RESOURCEMAPPROPERYNAME);
103
        //this.systemMetadataListener = systemMetadataListener;
104
        //this.mNode = new MNode(buildMNBaseURL());
105
        try {
106
            waitingTime = Settings.getConfiguration().getInt(WAITIMEPOPERTYNAME);
107
            maxAttempts = Settings.getConfiguration().getInt(MAXATTEMPTSPROPERTYNAME);
108
        } catch (Exception e) {
109
            log.warn("IndexGenerator.constructor - couldn't read the waiting time or maxattempts from the metacat.properties file since : "+e.getMessage()+". Default values will be used");
110
            waitingTime = WAITTIME;
111
            maxAttempts = MAXWAITNUMBER;
112
        }
113
    }
114
    
115
    /**
116
     * Build the index for all documents in Metacat without overwriting.
117
     * @throws SolrServerException 
118
     * @throws ServiceFailure 
119
     * @throws NotImplemented 
120
     * @throws NotAuthorized 
121
     * @throws InvalidToken 
122
     * @throws InvalidRequest 
123
     * @throws IndexEventLogException 
124
     * @throws IllegalAccessException 
125
     * @throws InstantiationException 
126
     * @throws ClassNotFoundException 
127
     */
128
    /*public void indexAll() throws InvalidRequest, InvalidToken, NotAuthorized, 
129
                            NotImplemented, ServiceFailure, SolrServerException, FileNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException {
130
        boolean force = false;
131
        indexAll(force);
132
    }*/
133
    
134
    /**
135
     * Build the index for all documents.
136
     * @throws SolrServerException 
137
     * @throws ServiceFailure 
138
     * @throws NotImplemented 
139
     * @throws NotAuthorized 
140
     * @throws InvalidToken 
141
     * @throws InvalidRequest 
142
     * @throws IndexEventLogException 
143
     * @throws IllegalAccessException 
144
     * @throws InstantiationException 
145
     * @throws ClassNotFoundException 
146
     */
147
    public void indexAll() throws InvalidRequest, InvalidToken,
148
                NotAuthorized, NotImplemented, ServiceFailure, SolrServerException, FileNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException {
149
        Date since = null;
150
        Date until = null;
151
        index(since, until);
152
    }
153
    
154
    /**
155
     * Build the index for the docs which have been modified since the specified date.
156
     * @param since
157
     * @throws SolrServerException 
158
     * @throws ServiceFailure 
159
     * @throws NotImplemented 
160
     * @throws NotAuthorized 
161
     * @throws InvalidToken 
162
     * @throws InvalidRequest 
163
     * @throws IndexEventLogException 
164
     * @throws IllegalAccessException 
165
     * @throws InstantiationException 
166
     * @throws ClassNotFoundException 
167
     */
168
    public void index(Date since) throws InvalidRequest, InvalidToken, 
169
                    NotAuthorized, NotImplemented, ServiceFailure, SolrServerException, FileNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException {
170
        Date until = null;
171
        index(since, until);
172
    }
173
    
174
    /**
175
     *  Build the index for the docs which have been modified between the specified date.s
176
     * @param since
177
     * @param until
178
     * @throws SolrServerException 
179
     * @throws ServiceFailure 
180
     * @throws NotImplemented 
181
     * @throws NotAuthorized 
182
     * @throws InvalidToken 
183
     * @throws InvalidRequest 
184
     * @throws FileNotFoundException 
185
     * @throws IndexEventLogException 
186
     * @throws IllegalAccessException 
187
     * @throws InstantiationException 
188
     * @throws ClassNotFoundException 
189
     */
190
    public void index(Date since, Date until) throws SolrServerException, InvalidRequest, 
191
                                                InvalidToken, NotAuthorized, NotImplemented, ServiceFailure, FileNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IndexEventLogException {
192
        Date processedDate = null;
193
        List<String> solrIds = null;
194
        initSystemMetadataMap();
195
        initObjectPathMap();
196
        List[] metacatIds = getMetacatIds(since, until);
197
        List<String> otherMetacatIds = metacatIds[FIRST];
198
        List<String> resourceMapIds =  metacatIds[SECOND];
199
        
200
        //figure out the procesedDate by comparing the last element of otherMetacatIds and resourceMapIds.
201
        Date latestOtherId = null;
202
        if (otherMetacatIds != null && !otherMetacatIds.isEmpty()) {
203
            int size = otherMetacatIds.size();
204
            String id = otherMetacatIds.get(size-1);
205
            SystemMetadata sysmeta = getSystemMetadata(id);
206
            latestOtherId = sysmeta.getDateSysMetadataModified();
207
        }
208
        Date latestResourceId = null;
209
        if (resourceMapIds != null && !resourceMapIds.isEmpty()) {
210
            int size = resourceMapIds.size();
211
            String id = resourceMapIds.get(size-1);
212
            SystemMetadata sysmeta = getSystemMetadata(id);
213
            latestResourceId = sysmeta.getDateSysMetadataModified();
214
        }
215
        if(latestOtherId != null && latestResourceId != null && latestOtherId.getTime() > latestResourceId.getTime()) {
216
            processedDate = latestOtherId;
217
        } else if (latestOtherId != null && latestResourceId != null && latestOtherId.getTime()  <= latestResourceId.getTime()) {
218
            processedDate = latestResourceId;
219
        } else if (latestOtherId == null && latestResourceId != null) {
220
            processedDate = latestResourceId;
221
        } else if (latestOtherId != null && latestResourceId == null) {
222
            processedDate = latestOtherId;
223
        }
224
        
225
        //add the failedPids 
226
        List<String> failedPids = EventlogFactory.createIndexEventLog().getFailedPids();
227
        List<String> failedOtherIds = new ArrayList<String>();
228
        List<String> failedResourceMapIds = new ArrayList<String>();
229
        if(failedPids != null) {
230
            for(String id : failedPids) {
231
                SystemMetadata sysmeta = getSystemMetadata(id);
232
                if(sysmeta != null && !sysmeta.getArchived()) {
233
                    ObjectFormatIdentifier formatId =sysmeta.getFormatId();
234
                    if(formatId != null && formatId.getValue() != null && resourceMapNamespaces != null && isResourceMap(formatId)) {
235
                        failedResourceMapIds.add(id);
236
                    } else {
237
                        failedOtherIds.add(id);
238
                    }
239
                }
240
            }
241
        }
242
        
243
        if(!failedOtherIds.isEmpty()) {
244
            failedOtherIds.addAll(otherMetacatIds);
245
        } else {
246
            failedOtherIds = otherMetacatIds;
247
        }
248
        
249
        if(!failedResourceMapIds.isEmpty()) {
250
            failedResourceMapIds.addAll(resourceMapIds);
251
        } else {
252
            failedResourceMapIds = resourceMapIds;
253
        }
254
        
255
        log.info("the metacat ids (exception resource map -----------------------------"+failedOtherIds);
256
        log.info("the metacat resroucemap ids -----------------------------"+failedResourceMapIds);
257
        index(failedOtherIds);
258
        index(failedResourceMapIds);
259
       
260
        //record the timed index.
261
        if(processedDate != null) {
262
            EventlogFactory.createIndexEventLog().setLastProcessDate(processedDate);
263
        }
264
        
265
    }
266
    
267
    /*
268
     * Doing index
269
     */
270
    private void index(List<String> metacatIds) {
271
        if(metacatIds != null) {
272
            for(String metacatId : metacatIds) {
273
                if(metacatId != null) {
274
                        try {
275
                            generateIndex(metacatId);
276
                        } catch (Exception e) {
277
                            log.error("IndexGenerator.index - Metacat Index couldn't generate the index for the id - "+metacatId+" because "+e.getMessage());
278
                        }
279
                        
280
                   
281
                }
282
            }
283
        }
284
    }
285
    
286
    public void run() {
287
        /*IndexEvent event = new IndexEvent();
288
        event.setDate(Calendar.getInstance().getTime());
289
        event.setType(IndexEvent.STARTTIMEDINDEX);
290
        event.setDescription("Start the timed index job");
291
        try {
292
            EventlogFactory.createIndexEventLog().write(event);
293
        } catch (Exception e) {
294
            log.error("IndexGenerator.run - IndexEventLog can't log the timed indexing start event :"+e.getMessage());
295
        }*/
296
        try {
297
            Date since = EventlogFactory.createIndexEventLog().getLastProcessDate();
298
            index(since);
299
        } catch (InvalidRequest e) {
300
            // TODO Auto-generated catch block
301
            //e.printStackTrace();
302
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
303
        } catch (InvalidToken e) {
304
            // TODO Auto-generated catch block
305
            //e.printStackTrace();
306
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
307
        } catch (NotAuthorized e) {
308
            // TODO Auto-generated catch block
309
            //e.printStackTrace();
310
        } catch (NotImplemented e) {
311
            // TODO Auto-generated catch block
312
            //e.printStackTrace();
313
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
314
        } catch (ServiceFailure e) {
315
            // TODO Auto-generated catch block
316
            //e.printStackTrace();
317
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
318
        } catch (SolrServerException e) {
319
            // TODO Auto-generated catch block
320
            //e.printStackTrace();
321
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
322
        } catch (FileNotFoundException e) {
323
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
324
        }
325
        /*event.setDate(Calendar.getInstance().getTime());
326
        event.setType(IndexEvent.FINISHTIMEDINDEX);
327
        event.setDescription("Finish the timed index job");
328
        try {
329
            EventlogFactory.createIndexEventLog().write(event);
330
        } catch (Exception e) {
331
            log.error("IndexGenerator.run - IndexEventLog can't log the timed indexing finish event :"+e.getMessage());
332
        }*/ catch (ClassNotFoundException e) {
333
            // TODO Auto-generated catch block
334
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
335
        } catch (InstantiationException e) {
336
            // TODO Auto-generated catch block
337
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
338
        } catch (IllegalAccessException e) {
339
            // TODO Auto-generated catch block
340
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
341
        } catch (IndexEventLogException e) {
342
            // TODO Auto-generated catch block
343
            log.error("IndexGenerator.run - Metadata-Index couldn't generate indexes for those documents which haven't been indexed : "+e.getMessage());
344
        }
345
    }
346
    
347
    /*
348
     * Get the indexed ids list from the solr server.
349
     * An empty list will be returned if there is no ids.
350
     */
351
    private List<String> getSolrDocIds() throws SolrServerException {
352
        List<String> ids = solrIndex.getSolrIds();
353
        return ids;
354
    }
355
    
356
    /*
357
     * Get an array of the list of ids of the metacat which has the systemmetadata modification in the range.
358
     * 
359
     * If since and util are null, it will return all of them.
360
     * The first element of the list is the ids except the resource map. The second elements of the list is the ids of the resource map.
361
     * The reason to split them is when we index the resource map, we need the index of the documents in the resource map ready.
362
     * The last element in the each list has the latest SystemMetadata modification date. But they are not sorted.
363
     */
364
    private List[] getMetacatIds(Date since, Date until) throws InvalidRequest, 
365
                        InvalidToken, NotAuthorized, NotImplemented, ServiceFailure, FileNotFoundException {
366
        
367
        List<String> resourceMapIds = new ArrayList();
368
        List<String> otherIds = new ArrayList();
369
        List[] ids = new List[2];
370
        ids[FIRST]= otherIds;
371
        ids[SECOND] = resourceMapIds;
372
        ISet<Identifier> metacatIds = DistributedMapsFactory.getIdentifiersSet();
373
        Date otherPreviousDate = null;
374
        Date resourceMapPreviousDate = null;
375
        if(metacatIds != null) {
376
            for(Identifier identifier : metacatIds) {
377
                if(identifier != null && identifier.getValue() != null && !identifier.getValue().equals("")) {
378
                    SystemMetadata sysmeta = getSystemMetadata(identifier.getValue());
379
                    if(sysmeta != null && !sysmeta.getArchived()) {
380
                        ObjectFormatIdentifier formatId =sysmeta.getFormatId();
381
                        //System.out.println("the object format id is "+formatId.getValue());
382
                        //System.out.println("the ============ resourcMapNamespaces"+resourceMapNamespaces);
383
                        boolean correctTimeRange = false;
384
                        Date sysDate = sysmeta.getDateSysMetadataModified();
385
                        if(since == null && until == null) {
386
                            correctTimeRange = true;
387
                        } else if (since != null && until == null) {
388
                            if(sysDate.getTime() >= since.getTime()) {
389
                                correctTimeRange = true;
390
                            }
391
                        } else if (since == null && until != null) {
392
                            if(sysDate.getTime() <= until.getTime()) {
393
                                correctTimeRange = true;
394
                            }
395
                        } else if (since != null && until != null) {
396
                            if(sysDate.getTime() >= since.getTime() && sysDate.getTime() <= until.getTime()) {
397
                                correctTimeRange = true;
398
                            }
399
                        }
400
                        if(correctTimeRange && formatId != null && formatId.getValue() != null && resourceMapNamespaces != null && isResourceMap(formatId)) {
401
                            //for the resource map
402
                            if(!resourceMapIds.isEmpty()) {
403
                                if(sysDate.getTime() > resourceMapPreviousDate.getTime()) {
404
                                    resourceMapIds.add(identifier.getValue());//append to the end of the list if current is later than the previous one
405
                                } else {
406
                                    int size = resourceMapIds.size();//
407
                                    resourceMapIds.add(size -1, identifier.getValue());//keep the previous one at the end of the list.
408
                                }
409
                            } else {
410
                                resourceMapIds.add(identifier.getValue());
411
                            }
412
                            resourceMapPreviousDate = sysDate;
413
                        } else {
414
                            if(!otherIds.isEmpty()) {
415
                                if(sysDate.getTime() > otherPreviousDate.getTime()) {
416
                                    otherIds.add(identifier.getValue());
417
                                } else {
418
                                    int size = otherIds.size();
419
                                    otherIds.add(size-1, identifier.getValue());
420
                                }
421
                            } else {
422
                                otherIds.add(identifier.getValue());
423
                            }
424
                            otherPreviousDate = sysDate;
425
                        }
426
                        
427
                    }
428
                }
429
            }
430
        }
431
        return ids;
432
    }
433
    
434
    /*
435
     * If the specified ObjectFormatIdentifier is a resrouce map namespace.
436
     */
437
    public static boolean isResourceMap(ObjectFormatIdentifier formatId) {
438
        boolean isResourceMap = false;
439
        if(formatId != null && resourceMapNamespaces != null) {
440
            for(String namespace : resourceMapNamespaces) {
441
                if(namespace != null && formatId.getValue() != null && !formatId.getValue().trim().equals("") && formatId.getValue().equals(namespace)) {
442
                    isResourceMap = true;
443
                    break;
444
                }
445
            }
446
        }
447
        return isResourceMap;
448
    }
449
    
450
   
451
    
452
    /*
453
     * Generate index for the id.
454
     */
455
    private void generateIndex(String id) throws Exception {
456
        if(id != null)  {
457
                SystemMetadata sysmeta = getSystemMetadata(id);
458
                //only update none-archived id.
459
                if(sysmeta != null && !sysmeta.getArchived()) {
460
                        InputStream data = getDataObject(id);
461
                        Identifier obsolete = sysmeta.getObsoletes();
462
                        List<String> obsoleteChain = null;
463
                        if(obsolete != null) {
464
                            obsoleteChain = getObsoletes(id);
465
                        } 
466
                        solrIndex.update(id, obsoleteChain, sysmeta, data);
467
                } else {
468
                    throw new Exception("IndexGenerator.generate - there is no found SystemMetadata associated with the id "+id);
469
                }
470
           
471
        }
472
    }
473
    
474
    /*
475
     * Initialize the system metadata map
476
     */
477
    private void initSystemMetadataMap() throws FileNotFoundException, ServiceFailure{
478
        int times = 0;
479
        if(systemMetadataMap == null) {
480
            systemMetadataMap = DistributedMapsFactory.getSystemMetadataMap();
481
            /*while(true) {
482
                try {
483
                    systemMetadataMap = DistributedMapsFactory.getSystemMetadataMap();
484
                    break;
485
                } catch (FileNotFoundException e) {
486
                    throw e;
487
                } catch (ServiceFailure e) {
488
                    if(times <= maxAttempts) {
489
                        log.warn("IndexGenerator.initSystemMetadataMap - the hazelcast service is not ready : "
490
                                         +e.getMessage()+"\nWe will try to access it "+waitingTime/1000+" seconds later ");
491
                        try {
492
                            Thread.sleep(waitingTime);
493
                        } catch (Exception ee) {
494
                            log.warn("IndexGenerator.initSystemMetadataMap - the thread can't sleep for "+waitingTime/1000+" seconds to wait the hazelcast service");
495
                        }
496
                       
497
                    } else {
498
                        throw new ServiceFailure("0000", "IndexGenerator.initSystemMetadataMap - the hazelcast service is not ready even though Metacat-index wailted for "+maxAttempts*waitingTime/1000+" seconds. We can't get the system metadata from it and the building index can't happen this time");
499
                    }
500
                }
501
                times++;
502
            }*/
503
        }
504
    }
505
    
506
    /*
507
     * We should call this method after calling initSystemMetadataMap since this method doesn't have the mechanism to wait the readiness of the hazelcast service
508
     */
509
    private void initObjectPathMap() throws FileNotFoundException, ServiceFailure {
510
        if(objectPathMap == null) {
511
            objectPathMap = DistributedMapsFactory.getObjectPathMap();
512
        }
513
    }
514
    /**
515
     * Get an InputStream as the data object for the specific pid.
516
     * @param pid
517
     * @return
518
     * @throws FileNotFoundException
519
     */
520
    private InputStream getDataObject(String pid) throws FileNotFoundException {
521
        Identifier identifier = new Identifier();
522
        identifier.setValue(pid);
523
        String objectPath = objectPathMap.get(identifier);
524
        InputStream data = null;
525
        data = new FileInputStream(objectPath);
526
        return data;
527

    
528
    }
529
    
530
    /**
531
     * Get the SystemMetadata for the specified id from the distributed Map.
532
     * The null maybe is returned if there is no system metadata found.
533
     * @param id  the specified id.
534
     * @return the SystemMetadata associated with the id.
535
     */
536
    private SystemMetadata getSystemMetadata(String id) {
537
        SystemMetadata metadata = null;
538
        if(systemMetadataMap != null && id != null) {
539
            Identifier identifier = new Identifier();
540
            identifier.setValue(id);
541
            metadata = systemMetadataMap.get(identifier);
542
        }
543
        return metadata;
544
    }
545
    
546
    /**
547
     * Get the obsoletes chain of the specified id. The returned list doesn't include
548
     * the specified id itself. The newer version has the lower index number in the list.
549
     * Empty list will be returned if there is no document to be obsoleted by this id.
550
     * @param id
551
     * @return
552
     */
553
    private List<String> getObsoletes(String id) {
554
        List<String> obsoletes = new ArrayList<String>();
555
        while (id != null) {
556
            SystemMetadata metadata = getSystemMetadata(id);
557
            id = null;//set it to be null in order to stop the while loop if the id can't be assinged to a new value in the following code.
558
            if(metadata != null) {
559
                Identifier identifier = metadata.getObsoletes();
560
                if(identifier != null && identifier.getValue() != null && !identifier.getValue().trim().equals("")) {
561
                    obsoletes.add(identifier.getValue());
562
                    id = identifier.getValue();
563
                } 
564
            } 
565
        }
566
        return obsoletes;
567
    }
568
    
569
    /**
570
     * Overwrite and do nothing
571
     */
572
    public boolean cancel() {
573
        return true;
574
    }
575

    
576
}
(3-3/6)