Changeset 875
- Timestamp:
- 11/10/10 13:57:18 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistryImpl.java
r836 r875 2 2 3 3 import java.io.File; 4 import java.io.FileInputStream;5 import java.io.FileNotFoundException;6 4 import java.io.FileOutputStream; 7 5 import java.io.IOException; 8 6 import java.io.OutputStream; 7 import java.io.UnsupportedEncodingException; 9 8 import java.security.Principal; 10 9 import java.text.ParseException; … … 24 23 import org.apache.commons.collections.map.LRUMap; 25 24 import org.apache.commons.io.FileUtils; 26 import org.apache.commons.io.IOUtils;27 25 import org.apache.commons.io.filefilter.IOFileFilter; 28 26 import org.apache.commons.io.filefilter.NameFileFilter; … … 201 199 202 200 public void getMDProfileAsXml(String profileId, OutputStream output) { 203 File file = getProfileFile(profileId);204 copyStream(file, output);201 CMDComponentSpec expandedSpec = CMDComponentSpecExpander.expandProfile(profileId, this); 202 writeXml(expandedSpec, output); 205 203 } 206 204 … … 214 212 } 215 213 216 public File getProfileFile(String profileId) { 214 private void writeXml(CMDComponentSpec spec, OutputStream outputStream) { 215 try { 216 MDMarshaller.marshal(spec, outputStream); 217 } catch (UnsupportedEncodingException e) { 218 LOG.error("Error in encoding: ", e); 219 } catch (JAXBException e) { 220 LOG.error("Cannot marshall spec: " + spec, e); 221 } 222 } 223 224 private File getProfileFile(String profileId) { 217 225 String id = stripRegistryId(profileId); 218 226 File file = new File(getProfileDir(), id + File.separator + id + ".xml"); … … 230 238 231 239 public void getMDComponentAsXml(String componentId, OutputStream output) { 232 File file = getComponentFile(componentId); 233 copyStream(file, output); 234 } 235 236 private void copyStream(File file, OutputStream output) { 237 try { 238 IOUtils.copy(new FileInputStream(file), output); 239 } catch (FileNotFoundException e) { 240 LOG.error("Cannot retrieve file: " + file, e); 241 } catch (IOException e) { 242 LOG.error("Cannot retrieve content from file: " + file, e); 243 } 240 CMDComponentSpec expandedSpec = CMDComponentSpecExpander.expandComponent(componentId, this); 241 writeXml(expandedSpec, output); 244 242 } 245 243 … … 249 247 } 250 248 251 p ublicFile getComponentFile(String componentId) {249 private File getComponentFile(String componentId) { 252 250 String id = stripRegistryId(componentId); 253 251 File file = new File(getComponentDir(), id + File.separator + id + ".xml");
Note: See TracChangeset
for help on using the changeset viewer.