Project

General

Profile

« Previous | Next » 

Revision 9363

Added by Jing Tao about 9 years ago

In the reindex method, the error message will be sent back.

View differences:

src/edu/ucsb/nceas/metacat/MetacatHandler.java
2666 2666
            response.setContentType("text/xml");
2667 2667
            out = response.getWriter();
2668 2668
            
2669
            if (pid == null || pid.length == 0) {
2670
                //report the error
2671
                results = new StringBuffer();
2672
                results.append("<error>");
2673
                results.append("The parameter - pid is missing. Please check your parameter list.");
2674
                results.append("</error>");
2675
                //out.close(); it will be closed in the finally statement
2676
                return;
2677
            }
2669 2678
            // TODO: Check that the user is allowed to reindex this object, allow everyone for open annotations
2670 2679
            boolean isAuthorized = true;
2671 2680
   			String docid = IdentifierManager.getInstance().getLocalId(pid[0]);
......
2676 2685
			
2677 2686

  
2678 2687
            if (!isAuthorized) {
2679
                out.print("<error>");
2680
                out.print("The user \"" + username +
2688
                results.append("<error>");
2689
                results.append("The user \"" + username +
2681 2690
                        "\" is not authorized for this action.");
2682
                out.print("</error>");
2683
                out.close();
2691
                results.append("</error>");
2692
                //out.close(); it will be closed in the finally statement
2684 2693
                return;
2685 2694
            }
2686 2695
            
2687 2696
           
2688
            if (pid == null || pid.length == 0) {
2689
                //report the error
2690
                results = new StringBuffer();
2691
                results.append("<error>");
2692
                results.append("The parameter - pid is missing. Please check your parameter list.");
2693
                results.append("</error>");
2694
            } else {
2697
            
2695 2698
                Vector<String> successList = new Vector<String>();
2696 2699
                Vector<String> failedList = new Vector<String>();
2697 2700
                
......
2736 2739
                    results.append("</error>");
2737 2740
                }
2738 2741
                results.append("</results>\n");
2739
            }
2742
            
2740 2743
        } catch (Exception e) {
2741 2744
            logMetacat.error("MetacatHandler.handleReindex action - " +
2742 2745
            		         e.getMessage());
2743 2746
            e.printStackTrace();
2747
            results.append("<error>");
2748
            results.append("There was an error - "+e.getMessage());
2749
            results.append("</error>");
2744 2750
        } finally {
2751
            logMetacat.debug("================= in the finally statement");
2745 2752
            if(out != null) {
2753
                logMetacat.debug("================= in the finally statement which out is not null");
2746 2754
                out.print(results.toString());
2747 2755
                out.close();
2748 2756
            }

Also available in: Unified diff