I am using spring integration mail (5.3.1 release)
I have a flow:
IntegrationFlows
.from(Mail
.imapIdleAdapter(imapAdapter)
)
.filter()
.filter()
...
.filter()
.handle(service1)
.get();
I want an email content to be loaded in service1.
I don't want to load email's content until it passes all filters.
My filters need to know only email headers.
I tried to use DefaultMailHeaderMapper but email's content is loaded anyway. I can see it in logs using "mail.debug"=true.
I was debugging and according to source of AbstractMailReceiver#receive, MimeMessage's content will be always loaded because e.g new IntegrationMimeMessage() uses MimeMessage(MimeMessage message) constructor that loads a content.
Is there any way to configure mail adapter to not load an email's content?
Thank you!
See docs: https://docs.spring.io/spring-integration/docs/current/reference/html/mail.html#mail-inbound. Especially this part:
tarting with version 5.2, the autoCloseFolder option is provided on the mail receiver. Setting it to false doesn’t close the folder automatically after a fetch, but instead an IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE header (see MessageHeaderAccessor API for more information) is populated into every message to producer from the channel adapter.
And then take a look into the next section: https://docs.spring.io/spring-integration/docs/current/reference/html/mail.html#mail-mapping
So, to avoid eager content loading you should abandon the header mapper and don't close the folder automatically. This way the whole MimeMessage is sent as a payload. You probably won't be able to perform your filtering logic against headers because the content of the message is not fetched therefore we don't know what headers are there in MimeMessage. However you can try to get access to them from your filters, but already against the payload - not headers.
Related
Notice: This question is not about ANGULAR's HttpClient, but the document generated by a component's template.
I want to do an old trick for a simple, yet powerful MS EXCEL export: Generate an HTML document containing one single <table>, and serve it with "Content-Type: application/xls". The user's browser will forward the document to a locally installed MS EXCEL, which detects that this is not a "real" .xls, but HTML, and converts very nicely the HTML into a spreadsheet.
My approach to implement this is straigtforward: Add a route for path, say, "/export-xls", and a new component that gets the data and renders it in its template.
However I absolutely cannot find a way to set the "Content-Type" header in the response!? I envisage that in the "Routes" array I would set "contentType: 'application/xls'", but no way.
What is the easiest and best way to generate such a document from within ANGULAR?
You can solve your problem by doing following steps
create a file containing your table in your local file system and create a URL for that file using URL.createObjectURL method
send an http request to that file
intercept the request and add contentType: 'application/xls' to response headers
after receiving your file revoke the URL using URL.revokeObjectURL method and delete the file from your local file system
I am not sure if you can do this without the creation of physical file because you need an http request because of the response content type
I have set up a HTTP Receive (req-response) adapter and the message appears to be getting to the message box. When I create an orchestration using a direct bound logical port, I am getting the message but everything I have tried to read the message body has failed (using passthrough pipeline, XML pipeline with allow unrecognized files = true) but I get exceptions any time I try to use the incoming message (message assignments, sending the message to a custom module to try to read the part(s)).
Rather than go into details on exceptions, can anyone point to instructions on what the proper way to access/use the body of the HTTP Get messages within an orchestration? To explain what I am trying to do, I want to take the query string (body) and send it verbatim to another orchestration for processing, so I simply want to extract the body (query string) from the message.
For a GET request without a body you need to use the WCF-WebHttp adapter rather than the deprecated BTSHTTPReceive.dll
With the WCF-WebHttp you can use the Variable Mapping to populate message context properties with the URI parameters.
So the answer was to NOT use the HTTP adapter for GET requests. I did not realize the HTTP adapter has effectively been deprecated. For basic GET requests I had to switch to the WCF-WebHTTP adapter and make sure to include the property in the property schema and then make sure to set the schema in the variable mapping as the property schema, not the message type schema of the incoming message. I wish the Microsoft documentation was more clear that the HTTP adapter cannot be used for very basic GET requests in which a body is not provided in the request.
I'm a programmer who is just getting started working with groovy in Jira in order to automate some tasks.
I'm trying to write a custom listener script using the inline editor in Jira, but haven't gotten past trying to get a Hello World program to work.
I don't know if the script is running, and can't see any output, and I really need some help with figuring out how to debug the script, preferably through outputs to some kind of console (or even just by reading the Jira logs if necessary), just so that I can actually start trying to learn how to use this tool.
I'm working with the information HERE as a general guideline to start learning to work with the inline editor.
For a little more context, you can see another related question that I asked HERE.
I've set the debug level to DEBUG for the event which I'm attaching the listener, as shown in this screenshot, based on the information found HERE:
Here is a screenshot of the inline editor I'm working in in JIRA. In this screenshot, I'm just trying to output 'Hello', and have just clicked the 'Preview' button:
As you can see, in the 'Result' tab at the bottom of the screen, there is nothing of interest. The 'Logs' tab is also empty, and the 'Timing' tab just says 'Elapsed: 0 ms CPU time: 0 ms', so it seems like nothing if happening.
If I check the log on the server (in the file catalina.2017-10-13.txt), I see the following output:
13-Oct-2017 07:01:50.942 WARNING [http-nio-8080-exec-6] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner-jira/latest/listeners/com.onresolve.scriptrunner.canned.jira.workflow.listeners.CustomListener/params, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using #FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
13-Oct-2017 07:02:26.740 WARNING [http-nio-8080-exec-12] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner/latest/canned/com.onresolve.scriptrunner.canned.common.StaticCompilationChecker, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using #FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
13-Oct-2017 07:02:26.974 WARNING [http-nio-8080-exec-1] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner-jira/latest/listeners/com.onresolve.scriptrunner.canned.jira.workflow.listeners.CustomListener/preview, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using #FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
This output doesn't mean a whole lot to me, but it seems apparent that it's being populated as a result of trying to preview the script.
I'm not getting any errors in the inline editor, and it's really simple code, so I don't think it's that.
The only other information I can include that I think is pertinent is that this is a test instance of Jira cloned from our production environment, and its base URL is still set to the URL of the prod environment. Not sure if that has any bearing, but I'm not really a Jira admin, just the programmer tasked with doing this, so I don't want to go fiddling around where I don't need to.
Thanks!
When using scriptrunner within jira, you'll need to import the logger to use the debugger or to output to the console. This can be done with the following:
// Enable debugger
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
And then, you'll be able to see the logged information using log.debug "hello"
To see your debug message "Hello" in the log, you must update a issue in your selected project. The Result, Logs and Timing Tabs at the bottom are useless in this view. Just trigger the Listener with a issue update in your selected project and search your debug message in the atlassian-jira.log file.
Hint: To view the Log in the browser you can use this jira app https://marketplace.atlassian.com/plugins/com.cps.lastLog/server/overview
I am testing Servicestack Rest Files service. When calling it from angularjs and asking for an html file back, the results comes back as the standard servicestack html format instead of the json format. Even when appending ?format=json, it does not work correctly. I am trying to browse for html files and are then trying to load it into ace editor. I think Servicestack is getting confused with the response type. I checked and the Content-Type is set to application/json on the client side when doing the request.
I'm assuming the request you're making is:
GET /files/myfile.html
It's returing HTML because the .html file extension is a built-in registered format in ServiceStack so it assumes you're explicitly requesting the API in the HTML Format.
You can avoid this ambiguity by specifying the file Path on the QueryString, e.g:
GET /files?Path=myfile.html
Which tells ServiceStack to send it back using the most appropriate format as specified in the Accept header. Or if you prefer you can also explicitly specify the format by adding the {.ext} at the end of the path info, e.g:
GET /files.json?Path=myfile.html
Another option, if you're not using ServiceStack's built-in HTML support is to remove the HtmlFormat Plugin, e.g:
Plugins.RemoveAll(x => x is HtmlFormat);
Whicih will make .html no longer a registered format so the .html extension will be benign.
Note: removing HtmlFormat also removes built-in HTML functionality like its auto HTML pages
What AMP extensions can be used to get a response from the server in the form of variable that can be used later, such as in a template or as a parameter to an attribute?
amp-access
The authorization endpoint of amp-access can return "a free-form JSON object":
Here’s a small list of possible ideas for properties that can be returned from the Authorization endpoint:
Metering info: maximum allowed number of views and current number of views.
Whether the Reader is logged in or a subscriber.
A more detailed type of the subscription: basic, premium
Geo: country, region, custom publication region
amp-form
amp-form "allows publishers to render the responses using Extended Templates". The response is expected to be a valid JSON Object. Try the "Hiding input fields after success" demo in the amp-form sample to see it in action.
amp-list
amp-list fetches "content dynamically from a CORS JSON endpoint and renders it using a supplied template". The response must be a JSON object that contains an array property "items".
In addition to {{variable}} substitutions in Mustache templates, you can also use AUTHDATA(variable) elsewhere.
amp-live-list (not quite)
amp-live-list is a "wrapper and minimal UI for content that updates live in the client instance as new content is available in the source document". The page will re-fetch itself, giving the server a change to send new content. If new content is found, AMP will populate a <div items> element with the new (HTML) items. You can't use that as a variable.
It's name doesn't really suggest it, but I think you want AMP-list
https://github.com/ampproject/amphtml/blob/master/extensions/amp-list/amp-list.md
Fetches content dynamically from a CORS JSON endpoint and renders it using a supplied template.