Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

protect configuration service in case Identity is not available

  • Loading branch information...
commit a3c78f021fb5f819b59374e62a10810b189a59a0 1 parent 9247155
@mswiderski mswiderski authored
View
12 ...end-server/src/main/java/org/uberfire/backend/server/config/ConfigurationServiceImpl.java
@@ -9,6 +9,7 @@
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
@@ -90,14 +91,13 @@ public boolean accept( final Path entry ) throws IOException {
public boolean addConfiguration( final ConfigGroup configGroup ) {
try {
final Path filePath = ioSystemService.get( systemRepository.getUri() ).resolve( configGroup.getName() + configGroup.getType().getExt() );
- final CommentedOption commentedOption = new CommentedOption( identity.getName(),
+ final CommentedOption commentedOption = new CommentedOption( getIdentityName(),
"Created config " + filePath.getFileName() );
final OutputStream outputStream = ioSystemService.newOutputStream( filePath,
StandardOpenOption.TRUNCATE_EXISTING,
commentedOption );
final String xml = marshaller.marshall( configGroup );
- System.out.println( xml );
outputStream.write( xml.getBytes( "UTF-8" ) );
outputStream.close();
@@ -112,4 +112,12 @@ public boolean addConfiguration( final ConfigGroup configGroup ) {
public boolean removeConfiguration( final ConfigGroup configGroup ) {
return ioSystemService.deleteIfExists( ioSystemService.get( systemRepository.getUri() ).resolve( configGroup.getName() + configGroup.getType().getExt() ) );
}
+
+ protected String getIdentityName() {
+ try{
+ return identity.getName();
+ } catch (ContextNotActiveException e) {
+ return "unknown";
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.