-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from SBI-/configuration-enhancement
Configuration enhancement
- Loading branch information
Showing
25 changed files
with
335 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
plugin/src/main/java/com/siemens/bt/jazz/services/base/configuration/Configuration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.siemens.bt.jazz.services.base.configuration; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
|
||
public class Configuration { | ||
// make sure every configurator is added exactly once | ||
protected Collection<ServiceConfigurator> configurations = new HashSet<>(); | ||
|
||
public Configuration() {} | ||
|
||
public Configuration(ServiceConfigurator... configurators) { | ||
configurations.addAll(Arrays.asList(configurators)); | ||
} | ||
|
||
public Configuration(Configuration... configurations) { | ||
for (Configuration c : configurations) { | ||
this.configurations.addAll(c.get()); | ||
} | ||
} | ||
|
||
public Collection<ServiceConfigurator> get() { | ||
return configurations; | ||
} | ||
|
||
public void add(ServiceConfigurator configurator) { | ||
configurations.add(configurator); | ||
} | ||
|
||
public void add(Collection<ServiceConfigurator> configurators) { | ||
configurations.addAll(configurators); | ||
} | ||
|
||
public void merge(Configuration other) { | ||
this.configurations.addAll(other.get()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...in/src/main/java/com/siemens/bt/jazz/services/base/configuration/ServiceConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.siemens.bt.jazz.services.base.configuration; | ||
|
||
import com.ibm.team.repository.service.TeamRawService; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.apache.commons.logging.Log; | ||
|
||
public interface ServiceConfigurator { | ||
void configure( | ||
Log log, | ||
HttpServletRequest request, | ||
HttpServletResponse response, | ||
TeamRawService parentService); | ||
} |
25 changes: 25 additions & 0 deletions
25
...main/java/com/siemens/bt/jazz/services/base/configuration/preset/ContentConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.siemens.bt.jazz.services.base.configuration.preset; | ||
|
||
import com.ibm.team.repository.service.TeamRawService; | ||
import com.siemens.bt.jazz.services.base.configuration.ServiceConfigurator; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.apache.commons.logging.Log; | ||
|
||
public class ContentConfigurator implements ServiceConfigurator { | ||
|
||
private final String contentType; | ||
|
||
public ContentConfigurator(String contentType) { | ||
this.contentType = contentType; | ||
} | ||
|
||
@Override | ||
public void configure( | ||
Log log, | ||
HttpServletRequest request, | ||
HttpServletResponse response, | ||
TeamRawService parentService) { | ||
response.setContentType(contentType); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ain/java/com/siemens/bt/jazz/services/base/configuration/preset/EncodingConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.siemens.bt.jazz.services.base.configuration.preset; | ||
|
||
import com.ibm.team.repository.service.TeamRawService; | ||
import com.siemens.bt.jazz.services.base.configuration.ServiceConfigurator; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.apache.commons.logging.Log; | ||
|
||
public class EncodingConfigurator implements ServiceConfigurator { | ||
|
||
private final String encoding; | ||
|
||
public EncodingConfigurator(String encoding) { | ||
this.encoding = encoding; | ||
} | ||
|
||
@Override | ||
public void configure( | ||
Log log, | ||
HttpServletRequest request, | ||
HttpServletResponse response, | ||
TeamRawService parentService) { | ||
response.setCharacterEncoding(encoding); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.