Project

General

Profile

Revision 2904

Added by harris over 14 years ago

Got rid of some debugging.

View differences:

src/edu/ucsb/nceas/metacat/lsid/LSIDAuthorityMetaData.java
84 84
                                    MetadataResponse.RDF_FORMAT);
85 85
    }
86 86

  
87
    private ByteArrayInputStream doMetadataRequest(LSID lsid)
88
                    throws LSIDServerException
89
    {
90
        logger.debug("getting metadata for lsid " + lsid.getLsid());
87
    private ByteArrayInputStream doMetadataRequest(LSID lsid) throws
88
        LSIDServerException {
89
      logger.debug("getting metadata for lsid " + lsid.getLsid());
91 90

  
92
        try {
91
      try {
93 92

  
93
        LSIDDataLookup myLookup = new LSIDDataLookup();
94
        InputStream content = myLookup.lsidData(lsid);
95
        InputStream content2 = myLookup.lsidData(lsid);
96
        if (!isEML(content2)) {
97
          content = getEML(lsid);
98
        }
99
        content2.close();
100
        setCurrentLSID(lsid);
94 101

  
102
        // based on the doctype choose the appropriate stylesheet
103
        String styleSheetName = null;
104
        String _docType = myLookup.getDocType(lsid);
95 105

  
96
            LSIDDataLookup myLookup = new LSIDDataLookup();
97
            InputStream content = myLookup.lsidData(lsid);
98
            InputStream content2 = myLookup.lsidData(lsid);
99
            if (!isEML(content2)) {
100
                content = getEML(lsid);
101
            }
102
            content2.close();
103
            setCurrentLSID(lsid);
104

  
105
            // based on the doctype choose the appropriate stylesheet
106
            String styleSheetName = null;
107
            String _docType = myLookup.getDocType(lsid);
108

  
109
            try {
110
              ResourceBundle rb = ResourceBundle.getBundle("metacat-lsid");
111

  
112

  
113
              for (Enumeration e =  rb.getKeys(); e.hasMoreElements() ;) {
114
                System.out.println(e.nextElement());
115
              }
116

  
117

  
118
              styleSheetName = rb.getString(_docType.replaceAll(":",""));
119
              logger.debug("the stylesheet: " + styleSheetName);
120

  
121
              logger.debug("\n\nlsid is of type: " + _docType + " using stylesheet: "
122
                           + styleSheetName + "\n\n");
123
            }
124
            catch (java.util.MissingResourceException mre) {
125
              logger.warn("there is no style corresponding to: '" + _docType +
126
                          "' -- using default");
127
              styleSheetName = this.DEFAULT_STYLESHEET;
128
              mre.getMessage();
129
            }
130
            InputStream styleSheet = getClass()
131
                            .getResourceAsStream(styleSheetName);
132
            TransformerFactory factory = TransformerFactory.newInstance();
133
            Transformer transformer = factory
134
                            .newTransformer(new StreamSource(styleSheet));
135
            ByteArrayOutputStream out = new ByteArrayOutputStream();
136
            transformer.transform(new StreamSource(content),
137
                                  new StreamResult(out));
138
            content.close();
139
            clearState();
140
            return new ByteArrayInputStream(out.toByteArray());
141
        } catch (Exception e) {
142
            throw new LSIDServerException(e, "Error transforming XML for: "
143
                                             + lsid);
106
        try {
107
          ResourceBundle rb = ResourceBundle.getBundle("metacat-lsid");
108
          styleSheetName = rb.getString(_docType.replaceAll(":", ""));
144 109
        }
110
        catch (java.util.MissingResourceException mre) {
111
          logger.warn("there is no style corresponding to: '" + _docType +
112
                      "' -- using default");
113
          styleSheetName = this.DEFAULT_STYLESHEET;
114
          mre.getMessage();
115
        }
116
        InputStream styleSheet = getClass()
117
            .getResourceAsStream(styleSheetName);
118
        TransformerFactory factory = TransformerFactory.newInstance();
119
        Transformer transformer = factory
120
            .newTransformer(new StreamSource(styleSheet));
121
        ByteArrayOutputStream out = new ByteArrayOutputStream();
122
        transformer.transform(new StreamSource(content),
123
                              new StreamResult(out));
124
        content.close();
125
        clearState();
126
        return new ByteArrayInputStream(out.toByteArray());
127
      }
128
      catch (Exception e) {
129
        throw new LSIDServerException(e, "Error transforming XML for: "
130
                                      + lsid);
131
      }
145 132
    }
146 133

  
147 134
    public static String getStringFromInputStream(InputStream input)

Also available in: Unified diff