Skip to content

Commit 139b4a3

Browse files
committed
Changed SubscriptionTemplate.json path lookup, so it uses the path from resource classes.
1 parent d8e6fa6 commit 139b4a3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/main/java/com.ericsson.ei.frontend/SubscriptionFilesController.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,39 @@
2626
import javax.servlet.http.HttpServletRequest;
2727
import javax.servlet.http.HttpServletResponse;
2828

29+
import org.springframework.beans.factory.annotation.Autowired;
2930
import org.springframework.beans.factory.annotation.Value;
3031
import org.springframework.boot.context.properties.ConfigurationProperties;
32+
import org.springframework.core.io.Resource;
33+
import org.springframework.core.io.ResourceLoader;
3134
import org.springframework.stereotype.Controller;
3235
import org.springframework.util.FileCopyUtils;
3336
import org.springframework.web.bind.annotation.RequestMapping;
3437
import org.springframework.web.bind.annotation.RequestMethod;
3538
import org.springframework.web.bind.annotation.ResponseBody;
39+
40+
import com.sun.glass.ui.Application;
41+
3642
import org.springframework.web.bind.annotation.RequestBody;
3743

3844

3945
@Controller
4046
public class SubscriptionFilesController {
4147

48+
@Autowired
49+
private ResourceLoader resourceLoader;
50+
4251
@Value("${ei.subscriptionFilePath}") private String subscriptionFilePath;
4352
private static final String APPLICATION_JSON = "application/json";
4453

4554

4655
@RequestMapping(value = "/download/subscriptiontemplate", method = RequestMethod.GET, produces = APPLICATION_JSON)
4756
public @ResponseBody void getSubscriptionJsonTemplate(HttpServletResponse response) throws IOException {
48-
File file = getFile(subscriptionFilePath);
49-
InputStream in = new FileInputStream(file);
5057

58+
Resource resource = resourceLoader.getResource("classpath:" + subscriptionFilePath);
59+
File file = resource.getFile();
60+
InputStream in = new FileInputStream(file);
61+
5162
response.setContentType(APPLICATION_JSON);
5263
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
5364
response.setHeader("Content-Length", String.valueOf(file.length()));

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ei.backendServiceHost=localhost
1111
ei.backendServicePort=8090
1212

1313
###### Subscription Template file ########
14-
ei.subscriptionFilePath=./src/main/resources/subscriptions/subscriptionsTemplate.json
14+
ei.subscriptionFilePath=subscriptions/subscriptionsTemplate.json
1515

1616

1717

0 commit comments

Comments
 (0)