本文整理汇总了Java中org.mule.api.annotations.param.Optional类的典型用法代码示例。如果您正苦于以下问题:Java Optional类的具体用法?Java Optional怎么用?Java Optional使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Optional类属于org.mule.api.annotations.param包,在下文中一共展示了Optional类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveApplicationLogs
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Get application log
*
* @param domain
* @param endDate
* @param startDate
* @param limit
* @param offset
* @param priority
* @param search
* @param tail
* @param worker
* @return LogResults, POJO that contains the requested logs
*/
@Processor
public LogResults retrieveApplicationLogs(String domain, @Optional String endDate, @Optional String startDate, @Default("100") Integer limit, @Optional Integer offset,
@Optional LogPriority priority, @Optional String search, @Optional Boolean tail, @Optional String worker) {
Map<String, String> queryParams = new HashMap<String, String>();
addToMapIfNotNull("endDate", endDate, queryParams);
addToMapIfNotNull("startDate", startDate, queryParams);
addToMapIfNotNull("limit", limit, queryParams);
addToMapIfNotNull("offset", offset, queryParams);
addToMapIfNotNull("priority", priority, queryParams);
addToMapIfNotNull("search", search, queryParams);
addToMapIfNotNull("tail", tail, queryParams);
addToMapIfNotNull("worker", worker, queryParams);
return client().connectWithDomain(domain).retrieveApplicationLog(queryParams);
}
示例2: connect
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Connect to the Anaplan API using an issued certificate. The certificate
* path is provided and the file is loaded into a Java Keystore and loaded
* into a X509Certificate object for use.
*
* @param certificatePath Filepath to certificate on local filesystem
* @param url API URL.
* @param proxyHost Proxy username if behind firewall.
* @param proxyUser Proxy username to get through firewall.
* @param proxyPass Proxy password to get through firewall.
* @throws org.mule.api.ConnectionException Whenever the connection to API
* fails due to expired certificate or invalid API endpoint or proxy
* details.
*/
@Connect
@TestConnectivity
public synchronized void connect(
@ConnectionKey @Path String certificatePath,
@Default("https://api.anaplan.com/") String url,
@Optional @Default("") String proxyHost,
@Optional @Default("") String proxyUser,
@Optional @Default("") String proxyPass)
throws org.mule.api.ConnectionException {
logger.info("Initiating certificate connection...");
if (apiConn == null) {
// create the connection strategy using certificate path.
apiConn = new AnaplanConnection(true, certificatePath, url,
proxyHost, proxyUser, proxyPass);
// Establish connection using new connection object and verify
// service parameters
connectToApi();
}
}
示例3: connect
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Connect to the Anaplan API via basic authentication using provided
* username and password.
*
* @param username User's username to login to Anaplan API.
* @param password User's password to login to Anaplan API.
* @param url API URL.
* @param proxyHost Proxy URL if behind firewall.
* @param proxyUser Proxy username to get past firewall.
* @param proxyPass Proxy password to get past firewall.
* @throws org.mule.api.ConnectionException Whenever the connection to
* Anaplan API fails using provided credentials.
*/
@Connect
@TestConnectivity
public synchronized void connect(
@ConnectionKey String username,
@Password String password,
@Default("https://api.anaplan.com/") String url,
@Optional @Default("") String proxyHost,
@Optional @Default("") String proxyUser,
@Optional @Password @Default("") String proxyPass)
throws org.mule.api.ConnectionException {
logger.info("Initiating basic connection...");
if (apiConn == null) {
// create the connStrategy object using credentials provided.
apiConn = new AnaplanConnection(false, username, password, url,
proxyHost, proxyUser, proxyPass);
// Establish connection using new connection object and verify
// service parameters
connectToApi();
}
}
示例4: queryAndFetch
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Runs a NXQL Query against repository, result is returned as a list of
* pages of Records
*
* {@sample.xml ../../../doc/Nuxeo-connector.xml.sample
* nuxeo:query-and-fetch}
*
* @param query the NXQL Query
* @param page the page number
* @param pageSize the page size
* @param queryParams the query parameters if any
* @param sortInfo sort columns
* @return a batched list of Records
* @throws Exception if operation can not be executed
*/
@Category(name = "Query", description = "execute a queryAndFetch")
@Processor
public RecordSet queryAndFetch(@Placement(group = "operation parameters")
String query, @Placement(group = "operation parameters")
@Optional
@Default("0")
Integer page, @Placement(group = "operation parameters")
@Optional
@Default("20")
Integer pageSize, @Placement(group = "operation parameters")
@Optional
@FriendlyName("Query parameters")
List<String> queryParams, @Placement(group = "operation parameters")
@Optional
@FriendlyName("Sort columns")
List<String> sortInfo) throws Exception {
return (RecordSet) execPageProvider(null, query, page, pageSize,
queryParams, sortInfo, true);
}
示例5: pageProvider
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Runs a Page Provider (named query) against repository, result is returned
* as a list of pages of Document
*
* {@sample.xml ../../../doc/Nuxeo-connector.xml.sample nuxeo:page-provider}
*
* @param pageProviderName the name if the PagteProvider to run
* @param page the page number
* @param pageSize the page size
* @param queryParams the query parameters if any
* @param sortInfo sort columns
* @return a batched list of Documents
* @throws Exception if operation can not be executed
*/
@Processor
@Category(name = "Query", description = "execute a PageProvider")
public Documents pageProvider(@Placement(group = "operation parameters")
String pageProviderName, @Placement(group = "operation parameters")
@Optional
@Default("0")
Integer page, @Placement(group = "operation parameters")
@Optional
@Default("20")
Integer pageSize, @Placement(group = "operation parameters")
@Optional
@FriendlyName("Query parameters")
List<String> queryParams, @Placement(group = "operation parameters")
@Optional
@FriendlyName("Sort columns")
List<String> sortInfo) throws Exception {
return (Documents) execPageProvider(pageProviderName, null, page,
pageSize, queryParams, sortInfo, false);
}
示例6: setBlob
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Attach a Blob to a Document
*
* {@sample.xml ../../../doc/Nuxeo-connector.xml.sample nuxeo:set-blob}
*
* @param doc reference to the target Document
* @param blob Blob to attach
* @param xpath Xpath of the target property
* @throws Exception if operation can not be executed
*/
@Processor
public void setBlob(@Placement(group = "operation parameters")
String doc, @Placement(group = "operation parameters")
NuxeoBlob blob, @Optional
@Default("")
@Placement(group = "operation parameters")
String xpath) throws Exception {
OperationRequest req = session.newRequest(docService.SetBlob).setInput(
blob).set("document", doc);
if (xpath != null) {
req.set("xpath", xpath);
}
req.setHeader(Constants.HEADER_NX_VOIDOP, "true");
req.execute();
}
示例7: resizePicture
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* resize the input Blob Picture
*
* {@sample.xml ../../../doc/Nuxeo-connector.xml.sample
* nuxeo:resize-picture}
*
* @param blobOrDoc blob or document that contains the picture
* @param maxWidth target maximum Width in pixels
* @param maxHeight target maximum Height in pixels
*
* @return the resized Picture
*
* @throws Exception if operation can not be executed
*/
@Processor
public NuxeoBlob resizePicture(@Placement(group = "operation parameters")
Object blobOrDoc, @Placement(group = "operation parameters")
@Optional
Integer maxWidth, @Placement(group = "operation parameters")
@Optional
Integer maxHeight) throws Exception {
OperationRequest req = session.newRequest("Picture.resize").setInput(
getInput(blobOrDoc));
if (maxWidth != null) {
req.set("maxWidth", maxWidth);
}
if (maxHeight != null) {
req.set("maxHeight", maxHeight);
}
return new NuxeoBlob((Blob) req.execute());
}
示例8: importFile
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* create a Document from a file
*
* {@sample.xml ../../../doc/Nuxeo-connector.xml.sample nuxeo:import-file}
*
* @param blobOrDoc blob or document that contains the picture
* @param overwrite define if existing document should be overriden
* @param inbound inbound headers that can hold some automation Context info
*
* @return the created Document
*
* @throws Exception if operation can not be executed
*/
@Processor
public Document importFile(@Placement(group = "operation parameters")
NuxeoBlob blobOrDoc, @Placement(group = "operation parameters")
@Optional
@Default("false")
boolean overwrite, @InboundHeaders("*")
final Map<String, Object> inbound) throws Exception {
OperationRequest req = session.newRequest("FileManager.Import").setInput(
getInput(blobOrDoc));
propagateAutomationContext(inbound, req);
// XXX typo !
req.set("overwite", overwrite);
return (Document) req.execute();
}
示例9: startWorkflow
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
*
* Starts the workflow with the given model id on the input documents
*
* {@sample.xml ../../../doc/Nuxeo-connector.xml.sample
* nuxeo:start-workflow}
*
* @param docRef target Document the Workflow should be started on
* @param workflowId uuid of the workflow to be started
* @param start start flag
* @param wfVars workflow variables
*
* @return the doc
*
* @throws Exception if operation can not be executed
*/
@Processor
public Document startWorkflow(@Placement(group = "operation parameters")
String docRef, @Placement(group = "operation parameters")
String workflowId, @Placement(group = "operation parameters")
@Optional
@Default("false")
boolean start, @Placement(group = "operation parameters")
@Optional
Map<String, Object> wfVars) throws Exception {
OperationRequest req = session.newRequest("Context.StartWorkflow").setInput(
DocRef.newRef(docRef));
req.set("Id", workflowId);
req.set("start", start);
req.set("variables", MapUnmangler.unMangle(wfVars));
return (Document) req.execute();
}
示例10: completeTask
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Completes the input task document.
*
* {@sample.xml ../../../doc/Nuxeo-connector.xml.sample nuxeo:complete-task}
*
* @param docRef target Task document
* @param comment optional comment
* @param status optional status
*
* @return the task document
*
* @throws Exception if operation can not be executed
*/
@Processor
public Document completeTask(@Placement(group = "operation parameters")
String docRef, @Placement(group = "operation parameters")
@Optional
String comment, @Placement(group = "operation parameters")
@Optional
String status) throws Exception {
OperationRequest req = session.newRequest(
"Workflow.CompleteTaskOperation").setInput(
DocRef.newRef(docRef));
if (comment != null) {
req.set("comment", comment);
}
if (status != null) {
req.set("status", status);
}
return (Document) req.execute();
}
示例11: createSchedule
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Creates a scheduled command tht will execute at a specific date and time
* <p/>
* {@sample.xml ../../../doc/Hue-connector.xml.sample hue:create-schedule}
*
* @param command Representation of a command that that can be sent to the scheduling
* API to execute the command at a specific time
* i.e. 'turn the lights on in the morning at 7am'
* A command represents a resource address, the HTTP verb and the body as the data to
* send to the resource.
* @param scheduleName for the new schedule. If a name is not specified then the default name, “schedule”, is used.
* If the name is already taken a space and number will be appended by the bridge, e.g. “schedule 1”.
* @param time Time when the scheduled event will occur in ISO 8601:2004 format.
* The bridge measures time in UTC and only accepts extended format, non-recurring, local time (YYYY-MM-DDThh:mm:ss).
* Incorrectly formatted dates will raise an error of type 7. If the time is in the past an error 7 will also be raised.
* @param description Description of the new schedule. If the description is not specified it will be empty.
*
* @return a string json response with either success message. If there is an error returned then an IOExecption is thrown
* @throws IOException if there is a connection error or if the call returns an error response
*/
@Processor
public String createSchedule(@Placement(group = "Schedule", order = 1) @FriendlyName("Name") String scheduleName,
@Placement(group = "Schedule", order = 2) String time,
@Placement(group = "Schedule", order = 3) @Optional String description,
@Placement(group = "Command to Execute") Command command) throws IOException
{
Schedule s = new Schedule();
s.setCommand(command);
s.setName(scheduleName);
s.setTime(time);
s.setDescription(description);
WebResource resource = httpClient.resource(getBaseUri() + "/schedules");
String response = resource.post(String.class, mapper.writeValueAsString(s));
if (response.contains("error"))
{
throw new IOException(response);
}
return response;
}
示例12: log
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
@Processor
public Object log(MuleEvent context, @Placement(group = "Logger") @Default("") String message,
@Placement(group = "Logger") @Default("") String variables,
@Placement(group = "Logger") @Default("INFO") LogLevel level,
@Placement(group = "Logger") @Optional String loggerName) {
MuleMessage muleMessage = context.getMessage();
LogMessage logMessage = LogHelper.getBasicLogMessage(muleMessage, message);
HashSet<String> variableNames = new HashSet<String>(
Arrays.asList(variables != null ? variables.replace(" ", "").split(",") : new String[0]));
List<LogVariable> varsToBeLogged = new ArrayList<>();
LogVariable payload = new LogVariable();
if (variableNames.contains(PAYLOAD_NAME)) {
try {
payload.setName(PAYLOAD_NAME);
if (muleMessage.getPayload() != null) {
payload.setValue(muleMessage.getPayloadForLogging());
} else {
payload.setValue("NULL PAYLOAD");
}
variableNames.remove(PAYLOAD_NAME);
} catch (Exception e) {
String errorMessage = "Unable to log payload. Message: " + message + ". Exception: " + e.getMessage();
LOG.fatal(errorMessage, e);
payload.setValue(errorMessage);
}
varsToBeLogged.add(payload);
}
varsToBeLogged.addAll(LogHelper.extractVariables(muleMessage, PropertyScope.INBOUND, variableNames,
config.getLogVariableType()));
varsToBeLogged.addAll(LogHelper.extractVariables(muleMessage, PropertyScope.OUTBOUND, variableNames,
config.getLogVariableType()));
varsToBeLogged.addAll(LogHelper.extractVariables(muleMessage, PropertyScope.INVOCATION, variableNames,
config.getLogVariableType()));
logMessage.setVariables(varsToBeLogged);
log(logMessage, level, StringUtils.isNotBlank(loggerName) ? loggerName : config.getDefaultLoggerName());
return context.getMessage().getPayload();
}
示例13: logAllProperties
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
@Processor
public Object logAllProperties(MuleEvent context, @Placement(group = "Logger") @Default("") String message,
@Placement(group = "Logger") @Default("Invocation") LogPropertyScope scope,
@Placement(group = "Logger") @Default("INFO") LogLevel level,
@Placement(group = "Logger") @Optional String loggerName) {
MuleMessage muleMessage = context.getMessage();
LogMessage logMessage = LogHelper.getBasicLogMessage(muleMessage, message);
List<LogVariable> varsToBeLogged = new ArrayList<>();
if (scope == LogPropertyScope.Inbound || scope == LogPropertyScope.All) {
varsToBeLogged.addAll(LogHelper.extractVariables(muleMessage, PropertyScope.INBOUND,
muleMessage.getPropertyNames(PropertyScope.INBOUND), config.getLogVariableType()));
}
if (scope == LogPropertyScope.Outbound || scope == LogPropertyScope.All) {
varsToBeLogged.addAll(LogHelper.extractVariables(muleMessage, PropertyScope.OUTBOUND,
muleMessage.getPropertyNames(PropertyScope.OUTBOUND), config.getLogVariableType()));
}
if (scope == LogPropertyScope.Invocation || scope == LogPropertyScope.All) {
varsToBeLogged.addAll(LogHelper.extractVariables(muleMessage, PropertyScope.INVOCATION,
muleMessage.getPropertyNames(PropertyScope.INVOCATION), config.getLogVariableType()));
}
logMessage.setVariables(varsToBeLogged);
log(logMessage, level, loggerName == null ? config.getDefaultLoggerName() : loggerName);
return context.getMessage().getPayload();
}
示例14: set
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Set KissMetrics properties on a person.
*
* {@sample.xml ../../../doc/KissMetrics-connector.xml.sample kissmetrics:set}
*
* @param person The person the event relates to.
* @param timestamp The timestamp of the event (optional).
* @param properties Additional properties to record.
* @throws IOException A problem communicating with KissMetrics occurred.
*/
@Processor
public void set(String person,
@Optional Long timestamp,
Map<String,Object> properties) throws IOException {
WebTarget resource = client.target("https://trk.kissmetrics.com/s")
.queryParam("_k", apiKey)
.queryParam("_p", person);
if (timestamp != null) {
resource = resource.queryParam("_t", timestamp.toString())
.queryParam("_d", "1");
}
if (properties != null) {
for (Map.Entry<String, Object> entry : properties.entrySet()) {
Object value = entry.getValue();
if (value == null) {
value = "";
} else {
value = value.toString();
}
resource = resource.queryParam(entry.getKey(), (String)value);
}
}
Response clientResponse = resource.request().get();
if (logger.isDebugEnabled()) {
logger.debug(clientResponse.toString());
}
if (clientResponse.getStatus() == 200) {
return;
}
throw new IOException("Could not record event. Got status: " + clientResponse.getStatus());
}
示例15: copy
import org.mule.api.annotations.param.Optional; //导入依赖的package包/类
/**
* Copy a Document
*
* {@sample.xml ../../../doc/Nuxeo-connector.xml.sample nuxeo:copy}
*
* @param src reference of the source document
* @param targetParent reference of the destination document
* @param docName name of the copied document
* @return a Document Object
* @throws Exception if operation can not be executed
*/
@Processor
public Document copy(@Placement(group = "operation parameters")
String src, @Placement(group = "operation parameters")
String targetParent, @Placement(group = "operation parameters")
@Optional
@Default("")
String docName) throws Exception {
if (docName == null || docName.isEmpty()) {
return docService.copy(new DocRef(src), new DocRef(targetParent));
} else {
return docService.copy(new DocRef(src), new DocRef(targetParent),
docName);
}
}