Skip to content

Commit

Permalink
Resources: fix styles omission
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsCharlier committed Nov 20, 2015
1 parent 4dc9c6f commit 40e7845
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/main/src/main/java/org/geoserver/catalog/ResourcePool.java
Expand Up @@ -1820,8 +1820,8 @@ public void writeStyle( StyleInfo info, Style style ) throws IOException {
*/
public void writeStyle( StyleInfo info, Style style, boolean format) throws IOException {
synchronized ( styleCache ) {
File styleFile = dataDir().findOrCreateStyleSldFile(info);
BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( styleFile ) );
Resource styleFile = dataDir().style(info);
BufferedOutputStream out = new BufferedOutputStream( styleFile.out() );

try {
Styles.handler(info.getFormat()).encode(Styles.sld(style), info.getFormatVersion(), format, out);
Expand All @@ -1842,7 +1842,7 @@ public void writeStyle( StyleInfo info, Style style, boolean format) throws IOEx
*/
public void writeStyle( StyleInfo style, InputStream in ) throws IOException {
synchronized ( styleCache ) {
File styleFile = dataDir().findOrCreateStyleSldFile(style);
Resource styleFile = dataDir().style(style);
writeStyle(in, styleFile);
clear(style);
}
Expand All @@ -1857,26 +1857,16 @@ public void writeStyle( StyleInfo style, InputStream in ) throws IOException {
* file to update
* @throws IOException
*/
public static void writeStyle(final InputStream in, final File styleFile)
public static void writeStyle(final InputStream in, final Resource styleFile)
throws IOException {
final File temporaryFile = File.createTempFile(styleFile.getName(),
null, styleFile.getParentFile());
BufferedOutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(temporaryFile));
out = new BufferedOutputStream(styleFile.out());
IOUtils.copy(in, out);
out.flush();
} finally {
out.close();
}
// move the file
try {
org.geoserver.data.util.IOUtils.rename(temporaryFile, styleFile);
} finally {
if (temporaryFile.exists()) {
temporaryFile.delete();
}
}
}

/**
Expand Down

0 comments on commit 40e7845

Please sign in to comment.