Skip to content

Commit

Permalink
Compliance with @nicos PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Goulven.Furet authored and Goulven.Furet committed Dec 1, 2023
1 parent 1b55973 commit 5ea2e03
Showing 1 changed file with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.open4goods.ui.controllers.ui;

import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.Random;
Expand All @@ -14,6 +13,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
Expand All @@ -35,14 +35,15 @@ public class AbstractUiController {
private @Autowired UiConfig config;
private @Autowired XwikiService xwikiService;




// Used to load Datasource configurations from classpath
private static final ClassLoader cl = DataSourceConfigService.class.getClassLoader();
private static final ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl);
private int maxImg;

// TODO : in a service (hot, controllers are multiply ionstanciated)
// TODO : in a service (hot, controllers are multiply instanciated)
@PostConstruct
public void init() {
try {
Expand All @@ -53,12 +54,10 @@ public void init() {
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}



}
}


/**
* Instanciates a ModelAndView and prefills pageNumber conf and pageNumber httpRequest
* with : <br/>
Expand Down Expand Up @@ -92,13 +91,9 @@ protected ModelAndView defaultModelAndView(final String tpl, final HttpServletRe

ret.addObject("config",config);

ret.addObject("dev", env.acceptsProfiles("dev","devsec"));
ret.addObject("dev", env.acceptsProfiles(Profiles.of("dev","devsec")));

ret.addObject("url",request.getRequestURL().toString() );

ret.addObject("loaderImg",loaderImage() );



ret.addObject("baseUrl",config.getBaseUrl(request.getLocale()));

Expand Down Expand Up @@ -131,13 +126,11 @@ protected ModelAndView defaultModelAndView(final String tpl, final HttpServletRe
return ret;
}


public String loaderImage() {
Random random = new Random();
int nb;
nb = random.nextInt(1,maxImg+1);
return "/assets/img/loader/"+nb+".jpg";

}

}
}

0 comments on commit 5ea2e03

Please sign in to comment.