Skip to main content
summaryrefslogtreecommitdiffstats
blob: c79febf9aa49c75957e9dee9d581318d65b4b1cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2014 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.orcs.account.admin.internal.oauth;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.jdbc.JdbcClientConfig;
import org.eclipse.osee.jdbc.JdbcSchemaResource;

/**
 * @author Roberto E. Escobar
 */
public class OAuthSchemaResource implements JdbcSchemaResource {

   private static final String SCHEMA_PATH = "schema/OAUTH.DS.SCHEMA.xml";

   @Override
   public InputStream getContent() throws OseeCoreException {
      InputStream inputStream = null;
      try {
         URL url = getResourceURL();
         inputStream = new BufferedInputStream(url.openStream());
      } catch (Exception ex) {
         throw new OseeCoreException(ex);
      }
      return inputStream;
   }

   @Override
   public boolean isApplicable(JdbcClientConfig config) {
      return true;
   }

   private URL getResourceURL() {
      return getClass().getResource(SCHEMA_PATH);
   }

   @Override
   public URI getLocation() throws OseeCoreException {
      try {
         return getResourceURL().toURI();
      } catch (URISyntaxException ex) {
         throw new OseeCoreException(ex, "Error finding [%s] schema resource", SCHEMA_PATH);
      }
   }
}

Back to the top