Subversion Repositories SmartDukaan

Rev

Rev 3311 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3311 Rev 3320
Line 12... Line 12...
12
import org.json.JSONException;
12
import org.json.JSONException;
13
import org.json.JSONObject;
13
import org.json.JSONObject;
14
 
14
 
15
public class SpecialPageConfigurer {
15
public class SpecialPageConfigurer {
16
	private static Logger log = Logger.getLogger(SpecialPageConfigurer.class);
16
	private static Logger log = Logger.getLogger(SpecialPageConfigurer.class);
17
	private static Map<String, JSONObject> specialPagesDetails;
17
	private static Map<String, JSONObject> specialPagesDetails = new HashMap<String, JSONObject>();
18
	static {
18
	static {
19
	    try {
19
	    try {
20
	        loadSpecialPagesDetails();
20
	        loadSpecialPagesDetails();
21
	    }
21
	    }
22
	    catch (IOException e) {
22
	    catch (IOException e) {
Line 29... Line 29...
29
 
29
 
30
	/**
30
	/**
31
     * Loads all special pages related details
31
     * Loads all special pages related details
32
     */
32
     */
33
    private static void loadSpecialPagesDetails() throws IOException, JSONException {
33
    private static void loadSpecialPagesDetails() throws IOException, JSONException {
34
        FileReader fr = new FileReader(Utils.EXPORT_ENTITIES_PATH + "../../javascripts/special-pages.json");
34
    	FileReader fr = new FileReader(Utils.EXPORT_ENTITIES_PATH + "../../javascripts/special-pages.json");
35
        BufferedReader br = new BufferedReader(fr);
35
        BufferedReader br = new BufferedReader(fr);
36
        String str = null;
36
        String str = null;
37
 
37
 
38
        log.info("Start loading special page parameters");
38
        log.info("Start loading special page parameters");
39
        
39
        
40
        specialPagesDetails = new HashMap<String, JSONObject>();
-
 
41
        while ((str = br.readLine()) != null) {
40
        while ((str = br.readLine()) != null) {
42
            JSONObject jsonObject = new JSONObject(str);
41
            JSONObject jsonObject = new JSONObject(str);
43
            specialPagesDetails.put(jsonObject.getString("saholicURL"),
42
            specialPagesDetails.put(jsonObject.getString("saholicURL"),
44
                    jsonObject);
43
                    jsonObject);
45
        }
44
        }
Line 49... Line 48...
49
    
48
    
50
    /**
49
    /**
51
     * Returns true in case a string passed is a special page name
50
     * Returns true in case a string passed is a special page name
52
     */
51
     */
53
    public static boolean isValidSpecialPage(String specialPage) {
52
    public static boolean isValidSpecialPage(String specialPage) {
54
        if (specialPage == null || specialPagesDetails == null) {
53
        if (specialPage == null) {
55
            return false;
54
            return false;
56
        }
55
        }
57
        return specialPagesDetails.containsKey(specialPage);
56
        return specialPagesDetails.containsKey(specialPage);
58
    }
57
    }
59
    
58