use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class Ftp method doEndTag.
@Override
public int doEndTag() throws PageException {
pool = ((PageContextImpl) pageContext).getFTPPool();
AFTPClient client = null;
// retries
do {
try {
if (action.equals("open"))
client = actionOpen();
else if (action.equals("close"))
client = actionClose();
else if (action.equals("changedir"))
client = actionChangeDir();
else if (action.equals("createdir"))
client = actionCreateDir();
else if (action.equals("listdir"))
client = actionListDir();
else if (action.equals("removedir"))
client = actionRemoveDir();
else if (action.equals("getfile"))
client = actionGetFile();
else if (action.equals("putfile"))
client = actionPutFile();
else if (action.equals("rename"))
client = actionRename();
else if (action.equals("remove"))
client = actionRemove();
else if (action.equals("getcurrentdir"))
client = actionGetCurrentDir();
else if (action.equals("getcurrenturl"))
client = actionGetCurrentURL();
else if (action.equals("existsdir"))
client = actionExistsDir();
else if (action.equals("existsfile"))
client = actionExistsFile();
else if (action.equals("exists"))
client = actionExists();
else
throw new ApplicationException("attribute action has an invalid value [" + action + "]", "valid values are [open,close,listDir,createDir,removeDir,changeDir,getCurrentDir," + "getCurrentURL,existsFile,existsDir,exists,getFile,putFile,rename,remove]");
} catch (IOException ioe) {
if (count++ < retrycount)
continue;
throw Caster.toPageException(ioe);
}
if (client == null || !checkCompletion(client))
break;
} while (true);
return EVAL_PAGE;
}
use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class ThreadTag method register.
public void register(Page currentPage, int threadIndex) throws PageException {
if (ACTION_RUN != action)
return;
Key name = name(true);
try {
// pc.getThreadScope(name);
Threads ts = ThreadTag.getThreadScope(pc, name, ThreadTag.LEVEL_ALL);
if (type == TYPE_DAEMON) {
if (ts != null)
throw new ApplicationException("could not create a thread with the name [" + name.getString() + "]. name must be unique within a request");
ChildThreadImpl ct = new ChildThreadImpl((PageContextImpl) pc, currentPage, name.getString(), threadIndex, attrs, false);
pc.setThreadScope(name, new ThreadsImpl(ct));
ct.setPriority(priority);
ct.setDaemon(false);
ct.start();
} else {
ChildThreadImpl ct = new ChildThreadImpl((PageContextImpl) pc, currentPage, name.getString(), threadIndex, attrs, true);
ct.setPriority(priority);
((ConfigImpl) pc.getConfig()).getSpoolerEngine().add(new ChildSpoolerTask(ct, plans));
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t);
} finally {
// this method is not called from template when type is run, a call from template is to early,
((PageContextImpl) pc).reuse(this);
}
}
use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class VideoPlayerParamBean method setFlash.
/**
* @param flash the flash to set
* @throws PageException
*/
public void setFlash(Resource flash, String pathFlash) throws PageException {
if (!"swf".equalsIgnoreCase(getExtension(flash)))
throw new ApplicationException("only swf movies are supported");
this.flash = flash;
this.pathFlash = pathFlash;
}
use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class Zip method actionRead.
private void actionRead(boolean binary) throws ZipException, IOException, PageException {
required("file", file, true);
required("variable", variable);
required("entrypath", entryPaths);
ZipFile zip = getZip(file);
if (entryPaths.length > 1)
throw new ApplicationException("you can only read one entry!");
try {
ZipEntry ze = getZipEntry(zip, entryPaths[0]);
if (ze == null) {
String msg = ExceptionUtil.similarKeyMessage(names(zip), entryPaths[0], "entry", "zip file", "in the zip file [" + file + "]", true);
throw new ApplicationException(msg);
// throw new ApplicationException("zip file ["+file+"] has no entry with name ["+entryPath+"]");
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = zip.getInputStream(ze);
IOUtil.copy(is, baos, true, false);
zip.close();
if (binary)
pageContext.setVariable(variable, baos.toByteArray());
else {
if (charset == null)
charset = ((PageContextImpl) pageContext).getResourceCharset().name();
pageContext.setVariable(variable, new String(baos.toByteArray(), charset));
}
} finally {
IOUtil.closeEL(zip);
}
}
use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class Zip method actionDelete.
private void actionDelete() throws ApplicationException, IOException {
required("file", file, true);
Resource existing = pageContext.getConfig().getTempDirectory().getRealResource(getTempName());
IOUtil.copy(file, existing);
ZipInputStream zis = null;
ZipOutputStream zos = null;
try {
zis = new ZipInputStream(IOUtil.toBufferedInputStream(existing.getInputStream()));
zos = new ZipOutputStream(IOUtil.toBufferedOutputStream(file.getOutputStream()));
ZipEntry entry;
String path, name;
int index;
boolean accept;
if (filter == null && recurse && (entryPaths == null || entryPaths.length == 0))
throw new ApplicationException("define at least one restriction, can't delete all the entries from a zip file");
while ((entry = zis.getNextEntry()) != null) {
accept = false;
path = entry.getName().replace('\\', '/');
index = path.lastIndexOf('/');
if (!recurse && index > 0)
accept = true;
// dir=index==-1?"":path.substring(0,index);
name = path.substring(index + 1);
if (filter != null && !filter.accept(file.getRealResource(name)))
accept = true;
if (!entryPathMatch(path))
accept = true;
if (!accept)
continue;
add(zos, entry, zis, false);
zis.closeEntry();
}
} finally {
IOUtil.closeEL(zis);
IOUtil.closeEL(zos);
existing.delete();
}
}
Aggregations