use of lucee.runtime.extension.RHExtension in project Lucee by lucee.
the class ConfigServerImpl method loadLocalExtensions.
@Override
public List<ExtensionDefintion> loadLocalExtensions() {
Resource[] locReses = getLocalExtensionProviderDirectory().listResources(new ExtensionResourceFilter(".lex"));
if (localExtensions == null || localExtSize != locReses.length || extHash(locReses) != localExtHash) {
localExtensions = new ArrayList<ExtensionDefintion>();
Map<String, String> map = new HashMap<String, String>();
RHExtension ext;
String v, fileName, uuid, version;
ExtensionDefintion ed;
for (int i = 0; i < locReses.length; i++) {
ed = null;
// we stay happy with the file name when it has the right pattern (uuid-version.lex)
fileName = locReses[i].getName();
if (fileName.length() > 39) {
uuid = fileName.substring(0, 35);
version = fileName.substring(36, fileName.length() - 4);
if (Decision.isUUId(uuid)) {
ed = new ExtensionDefintion(uuid, version);
ed.setSource(this, locReses[i]);
}
}
if (ed == null) {
try {
ext = new RHExtension(this, locReses[i], false);
ed = new ExtensionDefintion(ext.getId(), ext.getVersion());
ed.setSource(ext);
} catch (Exception e) {
SystemOut.printDate(e);
}
}
if (ed != null) {
// check if we already have an extension with the same id to avoid having more than once
v = map.get(ed.getId());
if (v != null && v.compareToIgnoreCase(ed.getId()) > 0)
continue;
map.put(ed.getId(), ed.getVersion());
localExtensions.add(ed);
}
}
localExtHash = extHash(locReses);
// we store the size because localExtensions size could be smaller because of duplicates
localExtSize = locReses.length;
}
return localExtensions;
}
use of lucee.runtime.extension.RHExtension in project Lucee by lucee.
the class ConfigServerImpl method getAllRHExtensions.
@Override
public Collection<RHExtension> getAllRHExtensions() {
Map<String, RHExtension> rtn = new HashMap<>();
// server (this)
RHExtension[] arr = getRHExtensions();
for (RHExtension rhe : arr) {
rtn.put(rhe.getId(), rhe);
}
// webs
ConfigWeb[] cws = getConfigWebs();
for (ConfigWeb cw : cws) {
arr = ((ConfigWebImpl) cw).getRHExtensions();
for (RHExtension rhe : arr) {
rtn.put(rhe.getId(), rhe);
}
}
return rtn.values();
}
use of lucee.runtime.extension.RHExtension in project Lucee by lucee.
the class ExportImportHandler method _export.
private static Map<String, Object> _export(ConfigImpl config, short types, Resource dir, String pathAppendix, boolean addOptionalArtifacts, String regularMappingFilter, String componentMappingFilter, String customtagMappingFilter) throws IOException {
Map<String, Object> map = new HashMap<String, Object>();
// Core
if ((types & TYPE_CONFIGURATION) > 0) {
}
// Extension
if ((types & TYPE_EXTENSION) > 0) {
Resource extDir = dir.getRealResource("extensions");
extDir.mkdirs();
List<Object> extensions = new ArrayList<Object>();
map.put("extensions", extensions);
Map<String, String> m;
for (RHExtension ext : config.getRHExtensions()) {
m = new HashMap<String, String>();
extensions.add(m);
m.put("id", ext.getId());
m.put("version", ext.getVersion());
if (dir != null) {
m.put("artifact", pathAppendix + "/extensions/" + ext.getExtensionFile().getName());
if (addOptionalArtifacts)
IOUtil.copy(ext.getExtensionFile(), extDir.getRealResource(ext.getExtensionFile().getName()));
}
}
}
// Core
if ((types & TYPE_CORE) > 0 && config instanceof ConfigServer) {
map.put("core", CFMLEngineFactory.getInstance().getInfo().getVersion().toString());
}
// Files
if ((types & TYPE_FILES) > 0) {
Resource mapDir = dir.getRealResource("mappings");
HashMap<String, Object> mappings = new HashMap<String, Object>();
map.put("mappings", mappings);
mappings.put("regular", exportMapping(config.getMappings(), mapDir.getRealResource("regular"), pathAppendix + "/mappings/regular/", regularMappingFilter));
mappings.put("component", exportMapping(config.getComponentMappings(), mapDir.getRealResource("component"), pathAppendix + "/mappings/component/", componentMappingFilter));
mappings.put("customtag", exportMapping(config.getCustomTagMappings(), mapDir.getRealResource("customtag"), pathAppendix + "/mappings/customtag/", customtagMappingFilter));
}
return map;
}
use of lucee.runtime.extension.RHExtension in project Lucee by lucee.
the class XMLConfigAdmin method updateRHExtension.
public void updateRHExtension(Config config, Resource ext, boolean reload) throws PageException {
RHExtension rhext;
try {
rhext = new RHExtension(config, ext, true);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
DeployHandler.moveToFailedFolder(ext.getParentResource(), ext);
throw Caster.toPageException(t);
}
updateRHExtension(config, rhext, reload);
}
use of lucee.runtime.extension.RHExtension in project Lucee by lucee.
the class Admin method doGetLocalExtension.
private void doGetLocalExtension() throws PageException {
String id = getString("admin", action, "id");
boolean asBinary = getBoolV("asBinary", false);
if (asBinary) {
Iterator<ExtensionDefintion> it = DeployHandler.getLocalExtensions(config).iterator();
ExtensionDefintion ext;
while (it.hasNext()) {
ext = it.next();
if (id.equalsIgnoreCase(ext.getId())) {
try {
pageContext.setVariable(getString("admin", action, "returnVariable"), IOUtil.toBytes(ext.getSource()));
return;
} catch (IOException e) {
throw Caster.toPageException(e);
}
}
}
throw new ApplicationException("there is no local extension with id " + id);
} else {
List<RHExtension> locals = RHExtension.toRHExtensions(DeployHandler.getLocalExtensions(config));
Query qry = RHExtension.toQuery(config, locals.toArray(new RHExtension[locals.size()]));
int rows = qry.getRecordcount();
String _id;
int row = 0;
for (int r = 1; r <= rows; r++) {
_id = Caster.toString(qry.getAt(KeyConstants._id, r), null);
if (id.equalsIgnoreCase(_id)) {
row = r;
break;
}
}
if (row == 0)
throw new ApplicationException("there is no local extension with id " + id);
pageContext.setVariable(getString("admin", action, "returnVariable"), Caster.toStruct(qry, row));
}
}
Aggregations