use of lucee.runtime.rest.Mapping in project Lucee by lucee.
the class RestDeleteApplication method call.
public static String call(PageContext pc, String dirPath, String strWebAdminPassword) throws PageException {
Password webAdminPassword = CacheUtil.getPassword(pc, strWebAdminPassword, false);
Resource dir = RestDeleteApplication.toResource(pc, dirPath);
ConfigWebImpl config = (ConfigWebImpl) pc.getConfig();
try {
XMLConfigAdmin admin = XMLConfigAdmin.newInstance((ConfigWebImpl) pc.getConfig(), webAdminPassword);
Mapping[] mappings = config.getRestMappings();
Mapping mapping;
for (int i = 0; i < mappings.length; i++) {
mapping = mappings[i];
if (RestUtil.isMatch(pc, mapping, dir)) {
admin.removeRestMapping(mapping.getVirtual());
admin.storeAndReload();
}
}
} catch (Exception e) {
throw Caster.toPageException(e);
}
return null;
}
use of lucee.runtime.rest.Mapping in project Lucee by lucee.
the class RestInitApplication method _call.
public static String _call(PageContext pc, String dirPath, String serviceMapping, Boolean defaultMapping, String webAdminPassword) throws PageException {
if (StringUtil.isEmpty(serviceMapping, true)) {
serviceMapping = pc.getApplicationContext().getName();
}
Resource dir = RestDeleteApplication.toResource(pc, dirPath);
ConfigWebImpl config = (ConfigWebImpl) pc.getConfig();
Mapping[] mappings = config.getRestMappings();
Mapping mapping;
// id is mapping name
String virtual = serviceMapping.trim();
if (!virtual.startsWith("/"))
virtual = "/" + virtual;
if (!virtual.endsWith("/"))
virtual += "/";
boolean hasResetted = false;
for (int i = 0; i < mappings.length; i++) {
mapping = mappings[i];
if (mapping.getVirtualWithSlash().equals(virtual)) {
// directory has changed
if (!RestUtil.isMatch(pc, mapping, dir) || (defaultMapping != null && mapping.isDefault() != defaultMapping.booleanValue())) {
update(pc, dir, virtual, CacheUtil.getPassword(pc, webAdminPassword, false), defaultMapping == null ? mapping.isDefault() : defaultMapping.booleanValue());
}
mapping.reset(pc);
hasResetted = true;
}
}
if (!hasResetted) {
update(pc, dir, virtual, CacheUtil.getPassword(pc, webAdminPassword, false), defaultMapping == null ? false : defaultMapping.booleanValue());
}
return null;
}
Aggregations