-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ee665c
commit f18d4ab
Showing
3 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#Build Number for ANT. Do not edit! | ||
#Thu Aug 17 17:04:58 CEST 2023 | ||
build.number=4 | ||
#Fri Aug 18 11:06:26 CEST 2023 | ||
build.number=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
source/java/src/org/lucee/extension/resource/s3/function/S3ListBuckets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.lucee.extension.resource.s3.function; | ||
|
||
import org.lucee.extension.resource.s3.S3; | ||
import org.lucee.extension.resource.s3.S3ResourceProvider; | ||
|
||
import lucee.loader.engine.CFMLEngine; | ||
import lucee.loader.engine.CFMLEngineFactory; | ||
import lucee.runtime.PageContext; | ||
import lucee.runtime.exp.PageException; | ||
import lucee.runtime.type.Query; | ||
import lucee.runtime.util.Cast; | ||
|
||
public class S3ListBuckets extends S3Function { | ||
|
||
private static final long serialVersionUID = -1304574485741405364L; | ||
|
||
public static Query call(PageContext pc, String accessKeyId, String secretAccessKey, String host, double timeout) throws PageException { | ||
|
||
CFMLEngine eng = CFMLEngineFactory.getInstance(); | ||
// for backward compatibility, when host was not existing | ||
if (eng.getDecisionUtil().isNumber(host)) { | ||
timeout = eng.getCastUtil().toDoubleValue(host); | ||
host = null; | ||
} | ||
try { | ||
S3 s3 = S3ResourceProvider.getS3(toS3Properties(pc, accessKeyId, secretAccessKey, host), toTimeout(timeout)); | ||
return s3.listBucketsAsQuery(); | ||
|
||
} | ||
catch (Exception e) { | ||
throw CFMLEngineFactory.getInstance().getCastUtil().toPageException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public Object invoke(PageContext pc, Object[] args) throws PageException { | ||
CFMLEngine engine = CFMLEngineFactory.getInstance(); | ||
Cast cast = engine.getCastUtil(); | ||
if (args.length == 4) return call(pc, cast.toString(args[0]), cast.toString(args[1]), cast.toString(args[2]), cast.toDoubleValue(args[3])); | ||
if (args.length == 3) return call(pc, cast.toString(args[0]), cast.toString(args[1]), cast.toString(args[2]), 0); | ||
if (args.length == 2) return call(pc, cast.toString(args[0]), cast.toString(args[1]), null, 0); | ||
if (args.length == 1) return call(pc, cast.toString(args[0]), null, null, 0); | ||
if (args.length == 0) return call(pc, null, null, null, 0); | ||
throw engine.getExceptionUtil().createFunctionException(pc, "S3ListBuckets", 0, 4, args.length); | ||
} | ||
} |