Skip to content

Commit

Permalink
Renamed app "sector" to app "segment".
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Apr 17, 2016
1 parent 82a2786 commit c8337dd
Show file tree
Hide file tree
Showing 26 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion rapidoid-commons/src/main/resources/default/config.yml
Expand Up @@ -16,7 +16,7 @@ app:
contextPath: /
home: /
menu: {}
sectors:
segments:
admin:
contextPath: /_
home: /_
Expand Down
6 changes: 3 additions & 3 deletions rapidoid-gui/src/main/java/org/rapidoid/gui/HtmlPage.java
Expand Up @@ -114,13 +114,13 @@ private Map<String, Object> pageModel() {
model.put("appUrl", appUrl);
model.put("adminUrl", adminUrl);

model.put("admin", "admin".equalsIgnoreCase(req.sector()));
model.put("admin", "admin".equalsIgnoreCase(req.segment()));

model.put("host", req.host());
model.put("verb", req.verb());
model.put("uri", req.uri());
model.put("path", req.path());
model.put("sector", req.sector());
model.put("segment", req.segment());

model.put("username", req.username());

Expand Down Expand Up @@ -151,7 +151,7 @@ private Map<String, Object> has(IReqInfo req) {

has.put("role", has(req.roles()));
has.put("path", has(req.path().replace('/', '_')));
has.put("sector", has(req.sector()));
has.put("segment", has(req.segment()));

return has;
}
Expand Down
Expand Up @@ -62,7 +62,7 @@ public interface IReqInfo {

Set<String> roles();

String sector();
String segment();

String contextPath();
}
Expand Up @@ -39,7 +39,7 @@ public class MockReqInfo extends AbstractReqInfo {

private String host = "localhost";

private String sector = "main";
private String segment = "main";

private String contextPath = "/";

Expand Down Expand Up @@ -206,12 +206,12 @@ public MockReqInfo setRoles(Set<String> roles) {
}

@Override
public String sector() {
return sector;
public String segment() {
return segment;
}

public MockReqInfo sector(String sector) {
this.sector = sector;
public MockReqInfo segment(String segment) {
this.segment = segment;
return this;
}

Expand All @@ -232,7 +232,7 @@ public String toString() {
+ ", path=" + path
+ ", uri=" + uri
+ ", host=" + host
+ ", sector=" + sector
+ ", segment=" + segment
+ ", contextPath=" + contextPath
+ ", data=" + (data != null ? toString(data.entrySet(), maxLen) : null)
+ ", params=" + (params != null ? toString(params.entrySet(), maxLen) : null)
Expand Down
Expand Up @@ -113,7 +113,7 @@ public Set<String> roles() {
}

@Override
public String sector() {
public String segment() {
return "main";
}

Expand Down
Expand Up @@ -109,8 +109,8 @@ public Set<String> roles() {
}

@Override
public String sector() {
return req().sector();
public String segment() {
return req().segment();
}

@Override
Expand Down
Expand Up @@ -146,19 +146,19 @@ public void onRequest(Channel channel, boolean isGet, boolean isKeepAlive, Range
String uri = xuri.str(buf);
String path = Msc.urlDecode(xpath.str(buf));
String query = Msc.urlDecode(xquery.str(buf));
String sector = "main";
String segment = "main";

if (handler != null) {
contentType = handler.contentType();
sector = handler.options().sector();
segment = handler.options().segment();
}

params = Collections.synchronizedMap(params);
headers = Collections.synchronizedMap(headers);
cookies = Collections.synchronizedMap(cookies);

req = new ReqImpl(this, channel, isKeepAlive, verb, uri, path, query, body, params, headers, cookies,
posted, files, contentType, sector, customization);
posted, files, contentType, segment, customization);

if (!attributes.isEmpty()) {
req.attrs().putAll(attributes);
Expand Down
Expand Up @@ -472,7 +472,7 @@ public Set<Route> allAdmin() {

for (Iterator<Route> it = routes.iterator(); it.hasNext(); ) {
Route route = it.next();
if (!route.config().sector().equalsIgnoreCase("admin")) {
if (!route.config().segment().equalsIgnoreCase("admin")) {
it.remove();
}
}
Expand All @@ -485,7 +485,7 @@ public Set<Route> allNonAdmin() {

for (Iterator<Route> it = routes.iterator(); it.hasNext(); ) {
Route route = it.next();
if (route.config().sector().equalsIgnoreCase("admin")) {
if (route.config().segment().equalsIgnoreCase("admin")) {
it.remove();
}
}
Expand Down
Expand Up @@ -287,11 +287,11 @@ public static void resultToResponse(Req req, Object result) {
}
}

public static String getContextPath(Customization customization, String sector) {
public static String getContextPath(Customization customization, String segment) {
Config cfg = customization.appConfig();

if (sector != null) {
cfg = cfg.sub("sectors", sector);
if (segment != null) {
cfg = cfg.sub("segments", segment);
}

return cfg.entry("contextPath").or("/");
Expand Down
16 changes: 8 additions & 8 deletions rapidoid-http-fast/src/main/java/org/rapidoid/http/Req.java
Expand Up @@ -98,25 +98,25 @@ public interface Req {
Req host(String host);

/**
* Gets the name of the <b>application sector</b> handling the request. <br>
* The default sector name is <code>main</code> for the <code>On</code> API, and <code>admin</code> for the <code>Admin</code> API.
* Gets the name of the <b>application segment</b> handling the request. <br>
* The default segment name is <code>main</code> for the <code>On</code> API, and <code>admin</code> for the <code>Admin</code> API.
*/
String sector();
String segment();

/**
* Overwrites the name of the <b>application sector</b> handling the request. <br>
* The default sector name is <code>main</code> for the <code>On</code> API, and <code>admin</code> for the <code>Admin</code> API.
* Overwrites the name of the <b>application segment</b> handling the request. <br>
* The default segment name is <code>main</code> for the <code>On</code> API, and <code>admin</code> for the <code>Admin</code> API.
*/
Req sector(String sector);
Req segment(String segment);

/**
* Gets the <b>context path</b> of the application sector handling the request. <br>
* Gets the <b>context path</b> of the application segment handling the request. <br>
* The default context path is <code>/</code> for the <code>On</code> API, and <code>/_</code> for the <code>Admin</code> API.
*/
String contextPath();

/**
* Overwrites the <b>context path</b> of the application sector handling the request. <br>
* Overwrites the <b>context path</b> of the application segment handling the request. <br>
* The default context path is <code>/</code> for the <code>On</code> API, and <code>/_</code> for the <code>Admin</code> API.
*/
Req contextPath(String contextPath);
Expand Down
16 changes: 8 additions & 8 deletions rapidoid-http-fast/src/main/java/org/rapidoid/http/ReqImpl.java
Expand Up @@ -56,7 +56,7 @@ public class ReqImpl implements Req, Constants, HttpMetadata {

private volatile String query;

private volatile String sector = "main";
private volatile String segment = "main";

private volatile String contextPath;

Expand Down Expand Up @@ -99,7 +99,7 @@ public class ReqImpl implements Req, Constants, HttpMetadata {
public ReqImpl(FastHttp http, Channel channel, boolean isKeepAlive, String verb, String uri, String path,
String query, byte[] body, Map<String, String> params, Map<String, String> headers,
Map<String, String> cookies, Map<String, Object> posted, Map<String, List<Upload>> files,
MediaType defaultContentType, String sector, Customization customization) {
MediaType defaultContentType, String segment, Customization customization) {

this.http = http;
this.channel = channel;
Expand All @@ -115,7 +115,7 @@ public ReqImpl(FastHttp http, Channel channel, boolean isKeepAlive, String verb,
this.posted = posted;
this.files = files;
this.defaultContentType = defaultContentType;
this.sector = sector;
this.segment = segment;
this.customization = customization;
}

Expand Down Expand Up @@ -650,13 +650,13 @@ public <T extends Serializable> T cookiepack(String name, T defaultValue) {
}

@Override
public String sector() {
return sector;
public String segment() {
return segment;
}

@Override
public Req sector(String sector) {
this.sector = sector;
public Req segment(String segment) {
this.segment = segment;
return this;
}

Expand All @@ -665,7 +665,7 @@ public String contextPath() {
if (contextPath == null) {
synchronized (this) {
if (contextPath == null) {
contextPath = HttpUtils.getContextPath(customization, sector());
contextPath = HttpUtils.getContextPath(customization, segment());
}
}
}
Expand Down
Expand Up @@ -55,7 +55,7 @@ public interface RouteConfig {

RouteOptions wrap(HttpWrapper... wrappers);

String sector();
String segment();

RouteOptions sector(String sector);
RouteOptions segment(String segment);
}
Expand Up @@ -40,7 +40,7 @@ public class RouteOptions implements RouteConfig {

private volatile boolean mvc;

private volatile String sector;
private volatile String segment;

private volatile TransactionMode transactionMode = TransactionMode.NONE;

Expand Down Expand Up @@ -127,13 +127,13 @@ public RouteOptions wrap(HttpWrapper... wrappers) {
}

@Override
public String sector() {
return sector;
public String segment() {
return segment;
}

@Override
public RouteOptions sector(String sector) {
this.sector = sector;
public RouteOptions segment(String segment) {
this.segment = segment;
return this;
}

Expand All @@ -146,7 +146,7 @@ public RouteOptions copy() {
copy.transactionMode(transactionMode());
copy.roles(roles.toArray(new String[roles.size()]));
copy.wrap(wrappers());
copy.sector(sector());
copy.segment(segment());

return copy;
}
Expand All @@ -161,7 +161,7 @@ public boolean equals(Object o) {
if (mvc != that.mvc) return false;
if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null) return false;
if (view != null ? !view.equals(that.view) : that.view != null) return false;
if (sector != null ? !sector.equals(that.sector) : that.sector != null) return false;
if (segment != null ? !segment.equals(that.segment) : that.segment != null) return false;
if (transactionMode != that.transactionMode) return false;
if (roles != null ? !roles.equals(that.roles) : that.roles != null) return false;
return wrappers != null ? wrappers.equals(that.wrappers) : that.wrappers == null;
Expand All @@ -172,7 +172,7 @@ public int hashCode() {
int result = contentType != null ? contentType.hashCode() : 0;
result = 31 * result + (view != null ? view.hashCode() : 0);
result = 31 * result + (mvc ? 1 : 0);
result = 31 * result + (sector != null ? sector.hashCode() : 0);
result = 31 * result + (segment != null ? segment.hashCode() : 0);
result = 31 * result + (transactionMode != null ? transactionMode.hashCode() : 0);
result = 31 * result + (roles != null ? roles.hashCode() : 0);
result = 31 * result + (wrappers != null ? wrappers.hashCode() : 0);
Expand Down
Expand Up @@ -37,11 +37,11 @@
@Since("5.1.0")
public class DefaultErrorHandler implements ErrorHandler {

private final Config sectors;
private final Config segments;
private final Value<String> home;

public DefaultErrorHandler(Customization customization) {
this.sectors = customization.appConfig().sub("sectors");
this.segments = customization.appConfig().sub("segments");
this.home = customization.appConfig().sub("app").entry("home").str();
}

Expand Down Expand Up @@ -79,11 +79,11 @@ private Object page(Req req, Resp resp, Throwable error) {
return resp.code(403).view("login").mvc(true);
} else {

Config sector = sectors.sub(req.sector());
Config segment = segments.sub(req.segment());

Map<String, ?> errorInfo = HttpUtils.getErrorInfo(resp, error);
resp.model().put("error", errorInfo);
resp.model().put("home", sector.entry("home").str().orElse(home).or("/"));
resp.model().put("home", segment.entry("home").str().orElse(home).or("/"));

return resp.mvc(true).view("error");
}
Expand Down
Expand Up @@ -82,7 +82,7 @@ public boolean equals(Object o) {

@Override
public String toString() {
return U.frmt("Route %s %s [sector %s]: %s", verb, path, config().sector(), handler);
return U.frmt("Route %s %s [segment %s]: %s", verb, path, config().segment(), handler);
}

@Override
Expand Down
Expand Up @@ -317,8 +317,8 @@ public OnRoute tx() {
return tx(TransactionMode.AUTO);
}

public OnRoute sector(String sector) {
options.sector(sector);
public OnRoute segment(String segment) {
options.segment(segment);
return this;
}

Expand Down

0 comments on commit c8337dd

Please sign in to comment.