001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2010-2012 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.server;
011
012import mondrian.olap.Util;
013
014import java.io.IOException;
015
016/**
017* Implementation of {@link mondrian.server.RepositoryContentFinder} that reads
018 * from a URL.
019 *
020 * <p>The URL might be a string representation of a {@link java.net.URL}, such
021 * as 'file:/foo/bar/datasources.xml' or 'http://server/datasources.xml', but
022 * it might also be the mondrian-specific URL format 'inline:...'. The content
023 * of an inline URL is the rest of the string after the 'inline:' prefix.
024 *
025 * @author Julian Hyde
026*/
027public class UrlRepositoryContentFinder
028    implements RepositoryContentFinder
029{
030    protected final String url;
031
032    /**
033     * Creates a UrlRepositoryContentFinder.
034     *
035     * @param url URL of repository
036     */
037    public UrlRepositoryContentFinder(String url) {
038        assert url != null;
039        this.url = url;
040    }
041
042    public String getContent() {
043        try {
044            return Util.readURL(
045                url, Util.toMap(System.getProperties()));
046        } catch (IOException e) {
047            throw new RuntimeException(e);
048        }
049    }
050
051    public void shutdown() {
052        // nothing to do
053    }
054}
055
056// End UrlRepositoryContentFinder.java