<commit_before>package org.loklak.api.cms;

import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;
import org.json.JSONObject;
import org.loklak.data.DAO;
import org.loklak.server.APIHandler;
import org.loklak.server.AbstractAPIHandler;
import org.loklak.server.Authorization;
import org.loklak.server.BaseUserRole;
import org.loklak.server.Query;
import org.loklak.tools.storage.JSONObjectWithDefault;

public class TopMenuService extends AbstractAPIHandler implements APIHandler {

	private static final long serialVersionUID = 1839868262296635665L;

	@Override
	public BaseUserRole getMinimalBaseUserRole() {
		return BaseUserRole.ANONYMOUS;
	}

	@Override
	public JSONObject getDefaultPermissions(BaseUserRole baseUserRole) {
		return null;
	}

	@Override
	public String getAPIPath() {
		return "/cms/topmenu.json";
	}

	@Override
	public JSONObject serviceImpl(Query call, HttpServletResponse response, Authorization rights,
			final JSONObjectWithDefault permissions) {

		int limited_count = (int) DAO.getConfig("download.limited.count", (long) Integer.MAX_VALUE);

		JSONObject json = new JSONObject(true);
		JSONArray topmenu = new JSONArray().put(new JSONObject().put("About", "http://loklak.org/about"))
				.put(new JSONObject().put("Search", "http://loklak.org"))
				.put(new JSONObject().put("Apps", "http://apps.loklak.org"))
				.put(new JSONObject().put("Blog", "http://blog.loklak.net"))
				.put(new JSONObject().put("Developers", "http://dev.loklak.org"))
				.put(new JSONObject().put("API", "http://api.loklak.org"));
		if (limited_count > 0)
			topmenu.put(new JSONObject().put("Dumps", "dump.html"));
		json.put("items", topmenu);

		// modify caching
		json.put("$EXPIRES", 600);
		return json;
	}
}<commit_msg>Fix #1533: Remove "dump" from topmenu if disabled in config (#1539)<commit_after>package org.loklak.api.cms;

import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;
import org.json.JSONObject;
import org.loklak.data.DAO;
import org.loklak.server.APIHandler;
import org.loklak.server.AbstractAPIHandler;
import org.loklak.server.Authorization;
import org.loklak.server.BaseUserRole;
import org.loklak.server.Query;
import org.loklak.tools.storage.JSONObjectWithDefault;

public class TopMenuService extends AbstractAPIHandler implements APIHandler {

	private static final long serialVersionUID = 1839868262296635665L;

	@Override
	public BaseUserRole getMinimalBaseUserRole() {
		return BaseUserRole.ANONYMOUS;
	}

	@Override
	public JSONObject getDefaultPermissions(BaseUserRole baseUserRole) {
		return null;
	}

	@Override
	public String getAPIPath() {
		return "/cms/topmenu.json";
	}

	@Override
	public JSONObject serviceImpl(Query call, HttpServletResponse response, Authorization rights,
			final JSONObjectWithDefault permissions) {

		int limited_count = (int) DAO.getConfig("download.limited.count", (long) Integer.MAX_VALUE);

		JSONObject json = new JSONObject(true);
		JSONArray topmenu = new JSONArray().put(new JSONObject().put("About", "http://loklak.org/about"))
				.put(new JSONObject().put("Search", "http://loklak.org"))
				.put(new JSONObject().put("Apps", "http://apps.loklak.org"))
				.put(new JSONObject().put("Blog", "http://blog.loklak.net"))
				.put(new JSONObject().put("Developers", "http://dev.loklak.org"))
				.put(new JSONObject().put("API", "http://api.<EMAIL>"));
		if (limited_count > 0 && DAO.writeDump)
			topmenu.put(new JSONObject().put("Dumps", "dump.html"));
		json.put("items", topmenu);

		// modify caching
		json.put("$EXPIRES", 600);
		return json;
	}
}
{'fraction_non_alphanumeric': 0.14154103852596314, 'fraction_numerical': 0.01507537688442211, 'mean_word_length': 5.2530541012216405, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '965965', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1193, 'n_words': 233}