1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.store.migration.hibernate

File MigrationResourceAccessor.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

2
6
2
1
68
28
4
0.67
3
2
2

Classes

Class Line # Actions
MigrationResourceAccessor 36 6 0% 4 10
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20   
21    package com.xpn.xwiki.store.migration.hibernate;
22   
23    import java.io.ByteArrayInputStream;
24    import java.io.IOException;
25    import java.io.InputStream;
26    import java.io.UnsupportedEncodingException;
27   
28    import liquibase.resource.ClassLoaderResourceAccessor;
29   
30    /**
31    * Liquibase accessor that provide access to changelogs stored in DataMigration.
32    *
33    * @version $Id: 12ed1e5e5cd4de9dea738198d9560431265d21a1 $
34    * @since 4.0M1
35    */
 
36    public class MigrationResourceAccessor extends ClassLoaderResourceAccessor
37    {
38    /** Name for which the change log is served. */
39    public static final String CHANGELOG_NAME = "liquibase.xml";
40   
41    /** The dynamic change log file. */
42    private byte[] changeLog;
43   
44    /**
45    * Create a new accessor to support the dynamically created change log.
46    *
47    * @param changeLog the dynamically created change log
48    */
 
49  0 toggle public MigrationResourceAccessor(String changeLog)
50    {
51  0 super();
52  0 try {
53  0 this.changeLog = changeLog.getBytes("UTF-8");
54    } catch (UnsupportedEncodingException ignored) {
55    // UTF-8 encoding is always available.
56    }
57    }
58   
 
59  0 toggle @Override
60    public InputStream getResourceAsStream(String file) throws IOException
61    {
62  0 if (CHANGELOG_NAME.equals(file)) {
63  0 return new ByteArrayInputStream(this.changeLog);
64    } else {
65  0 return super.getResourceAsStream(file);
66    }
67    }
68    }