This feed does not validate.
... Dmytro)</author><thr:total>6</thr:total><georss:featurename>Copenhagen, ...
^
... int>55.6760968 12.5683372</georss:point><georss:box>27.365862963821158 - ...
^
In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/200 ...
^
<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/200 ...
^
line 7, column 0: (335 occurrences) [help]
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizin ...
line 105, column 0: (2 occurrences) [help]
HashMap<String, Object> tags = new HashMap<String, Object>();
line 169, column 0: (3 occurrences) [help]
</description><link>https://dpastov.blogspot.com/2022/09/java-freemarker-wit ...
line 169, column 0: (3 occurrences) [help]
</description><link>https://dpastov.blogspot.com/2022/09/java-freemarker-wit ...
... </author><thr:total>3</thr:total></item></channel></rss>
^
<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-34728599</atom:id><lastBuildDate>Wed, 06 Mar 2024 01:58:11 +0000</lastBuildDate><category>lotus script</category><category>Java</category><category>lotus approach</category><category>lotus features</category><category>lotus notes</category><category>Domino</category><category>lotus news</category><category>web</category><category>javascript</category><category>me</category><category>lotus issues</category><category>lotus and java</category><category>notes api</category><category>DSAPI</category><category>Development</category><category>lotus formula</category><category>Play Framework</category><category>lotus integration</category><category>Google</category><category>lotus community</category><category>xPages</category><category>GitHub</category><category>SEO</category><category>LS2J</category><category>PDF</category><category>Velocity</category><category>lotus fun</category><category>lotus perfomance</category><category>Certificate</category><category>XML-XSL</category><category>Drupal</category><category>Jenkins</category><category>Node.js</category><category>XFDF</category><category>locale</category><category>Algorithms</category><category>Analytics</category><category>CSS</category><category>CloudFlare</category><category>DDE</category><category>FDF</category><category>FreeMarker</category><category>JSON</category><category>Jira</category><category>LS</category><category>Mongodb</category><category>RSS</category><category>SOAP</category><category>Scala</category><category>Typesafe</category><category>XPath</category><category>XSS</category><category>htmlminifier</category><category>iText</category><category>notes.ini</category><category>sqwish</category><category>uglifyjs</category><category>views</category><title>Find the best way</title><description>I write about Java, HCL Notes Domino, Web</description><link>https://dpastov.blogspot.com/</link><managingEditor>noreply@blogger.com (Dmytro)</managingEditor><generator>Blogger</generator><openSearch:totalResults>274</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-4321492353083690763</guid><pubDate>Thu, 02 Nov 2023 10:36:00 +0000</pubDate><atom:updated>2023-11-02T11:41:43.350+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Domino</category><title>Configuring Entitlement Tracking in Domino 12</title><description><p>In the realm of HCL Domino Server 12.0, the feature of "Entitlement Tracking" has become a vital component for organizations.</p>
<p>While comprehensive information regarding Entitlement Tracking is available through HCL, I needed to know some practical management aspects, such as disabling the feature and adjusting intervals etc.</p>
<h2>Disabling Entitlement Tracking:</h2>
<p>To disable entitlement tracking, add the following entry and restart the server:</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">DISABLE_ENTITLEMENT_TRACKING=1
</code></pre>
<h2>Debugging for Entitlement Tracking Issues:</h2>
<p>Debug settings can be incredibly useful for troubleshooting any issues related to Entitlement Tracking. Here's how to configure debugging options:</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">DEBUG_ENTITLEMENT_AGGREGATOR_INTERVAL=60
DEBUG_UPDATE_ENTITLEMENT_TRACKING=2
ES_OPT_TIMING=1
DEBUG_DIRCAT=3
</code></pre>
<p>Hope that will help somebody.</p></description><link>https://dpastov.blogspot.com/2023/11/configuring-entitlement-tracking-in.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-1274580201345768280</guid><pubDate>Fri, 27 Oct 2023 11:46:00 +0000</pubDate><atom:updated>2023-10-27T13:46:12.479+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Domino</category><category domain="http://www.blogger.com/atom/ns#">Java</category><title>Overcoming Domino's Agent Scheduling Limitations with JavaAddin</title><description><p style="text-align: justify;">If you're frustrated with Domino's limitations on scheduling agents to run more frequently than once every 5 minutes, you're not alone. As a programmer, you understand the need for flexibility and control in your applications. In this article, we'll discuss a practical solution: creating a JavaAddin for Domino that can trigger agents at shorter intervals, allowing you to gain more fine-grained control over your scheduled tasks.</p><h3 style="text-align: left;">Understanding the Domino Agent Scheduler</h3><div><br /></div><div>Domino provides a robust environment for running scheduled agents. However, it imposes a minimum time gap of 5 minutes between consecutive runs of the same agent. This limitation can be a roadblock for applications that require more frequent execution.<h3 style="text-align: left;"><br /></h3><h3 style="text-align: left;">The Power of JavaAddins</h3></div><div><br /></div><div>JavaAddins offer a way to extend Domino's functionality using Java code. This opens up a world of possibilities, including overcoming the 5-minute scheduling restriction. Here's how you can do it:</div><div><br /></div><div><b>1. Setting Up Your JavaAddin</b></div><div><br /><div>To get started, you'll need to create a JavaAddin. This involves writing Java code to interface with Domino. The code should enable you to trigger agents at shorter intervals than what Domino's native scheduling allows.</div><b><div><b><br /></b></div>2. Utilizing Timers</b><div><br /></div><div>One of the most effective ways to bypass the 5-minute limitation is to use timers in your JavaAddin. With timers, you can execute your agent at precise intervals, even down to seconds. Here's a simplified example of how this could look in your Java code:</div><div>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">import lotus.domino.*;
public class CustomScheduler extends JavaServerAddin {
public void runNotes() {
try {
Session session = NotesFactory.createSession();
Database database = session.getDatabase("", "YourDatabase.nsf");
Agent agent = database.getAgent("YourAgent");
// Set the execution interval in milliseconds
int interval = 30000; // 30 seconds
while (true) {
agent.runWithDocumentContext(null);
sleep(interval);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}</code></pre>
</div></div><div>This code defines a Java thread that runs your specified agent every 30 seconds, effectively bypassing Domino's 5-minute restriction.</div><div><br /></div><b>3. Deploying Your JavaAddin</b><div><br /></div><div>Once you've created your JavaAddin, you need to deploy it within your Domino environment. Ensure that the necessary permissions and access controls are in place.</div><div><br /></div><div><b>4. Monitoring and Maintenance</b></div><div><br /></div><div>Regularly monitor the execution of your custom scheduling solution. Ensure that it's working as expected and doesn't place undue stress on your Domino server.<h3 style="text-align: left;"><b><br /></b></h3><h3 style="text-align: left;"><b>Conclusion</b></h3><div><b><br /></b></div>By creating a JavaAddin for Domino that can trigger agents more frequently, you can take control of your scheduling needs. This solution empowers you to run your agents at shorter intervals, achieving the level of precision your applications require. While this approach requires some development effort, the benefits of fine-grained agent scheduling can greatly enhance your Domino-based applications.<br /><br />In summary, if you're tired of being constrained by Domino's 5-minute scheduling limitation, consider the power of JavaAddins to break free and gain control over your scheduled agents.<br /><br />I have also created a bit more advanced setup which you can get on github: <a href="https://github.com/dpastov/DominoAgentsHelper/" target="_blank">DominoAgentsHelper</a>&nbsp;<div><br /></div><div>Stay tuned for more technical insights, delivered directly to the point, in future articles.</div></div></description><link>https://dpastov.blogspot.com/2023/10/overcoming-dominos-agent-scheduling.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-1597830296760357664</guid><pubDate>Mon, 25 Sep 2023 09:35:00 +0000</pubDate><atom:updated>2023-09-25T12:10:42.287+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">lotus script</category><category domain="http://www.blogger.com/atom/ns#">notes api</category><title>Change Database ReplicaID programmatically</title><description><p>Here is a solution that change ReplicaId of NotesDatabase. Since native capabilities of LotusScript/Java classes do not allow such operation (at least yet), there is a way to do it using C Notes API. Our envrionment consists of both: Windows and Linux servers therefore I had to make a solution that cover both OS.</p>
<h4>Declare</h4>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Public Const W32_LIB = {nnotes.dll}
Public Const LINUX_LIB = {libnotes.so}
Type TIMEDATE
Innards(0 to 1) As Long
End Type
Type DBREPLICAINFO
ID As TIMEDATE 'ID that is same for all replica files
Flags As Integer 'Replication flags
CutoffInterval As Integer 'Automatic Replication Cutoff
Cutoff As TIMEDATE 'Replication cutoff date
End Type
Declare sub W32_OSCurrentTimeDate Lib W32_LIB Alias "OSCurrentTIMEDATE"(Ret As TIMEDATE)
Declare Function W32_NSFDbOpen Lib W32_LIB Alias "NSFDbOpen" (ByVal dbName As String, hdb As Long) As Integer
Declare Function W32_NSFDbClose Lib W32_LIB Alias "NSFDbClose" (ByVal hdb As Long) As Integer
Declare Function W32_NSFDbReplicaInfoGet Lib W32_LIB Alias "NSFDbReplicaInfoGet" (ByVal hdb As Long, hdbr As DBREPLICAINFO) As Integer
Declare Function W32_NSFDbReplicaInfoSet Lib W32_LIB Alias "NSFDbReplicaInfoSet" (ByVal hdb As Long, hdbr As DBREPLICAINFO) As Integer
Declare Sub LINUX_OSCurrentTimeDate Lib LINUX_LIB Alias "OSCurrentTIMEDATE"(Ret As TIMEDATE)
Declare Function LINUX_NSFDbOpen Lib LINUX_LIB Alias "NSFDbOpen" (ByVal dbName As String, hdb As Long) As Integer
Declare Function LINUX_NSFDbClose Lib LINUX_LIB Alias "NSFDbClose" (ByVal hdb As Long) As Integer
Declare Function LINUX_NSFDbReplicaInfoGet Lib LINUX_LIB Alias "NSFDbReplicaInfoGet" (ByVal hdb As Long, hdbr As DBREPLICAINFO) As Integer
Declare Function LINUX_NSFDbReplicaInfoSet Lib LINUX_LIB Alias "NSFDbReplicaInfoSet" (ByVal hdb As Long, hdbr As DBREPLICAINFO) As Integer</code></pre>
<h4>Code C API (main part of it)</h4>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">'GET CURRENT TIMEDATE (TO BUILD NEW REPLICAID): OSCurrentTimeDate
If IS_WINDOWS Then
Call W32_OSCurrentTimeDate(ReplicaID)
Else
Call LINUX_OSCurrentTimeDate(ReplicaID)
End If
ReplicaInfo.ID = ReplicaID
'SET NEW REPLICAID: NSFDbReplicaInfoSet
If IS_WINDOWS Then
rc = W32_NSFDbReplicaInfoSet(hDb, replicaInfo)
Else
rc = LINUX_NSFDbReplicaInfoSet(hDb, replicaInfo)
End If</code></pre>
<p>You can find all solution on GitHub: <a href="https://github.com/dpastov/DominoChangeDatabaseReplicaID" target="_blank">DominoChangeDatabaseReplicaID</a></p></description><link>https://dpastov.blogspot.com/2023/09/here-is-solution-that-change-replicaid.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-7456492786871285795</guid><pubDate>Thu, 08 Sep 2022 12:27:00 +0000</pubDate><atom:updated>2022-09-08T14:28:25.009+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Domino</category><category domain="http://www.blogger.com/atom/ns#">FreeMarker</category><category domain="http://www.blogger.com/atom/ns#">Java</category><title>Java Freemarker with Domino</title><description>There are plenty of different Java template engines but for last years I used to stick to <a href="https://freemarker.apache.org/">FreeMarker</a>. It's open sourced and licensed under the Apache License, Version 2.0.<div><br /></div><div>Here I only want to demonstrate how to integrate it with Domino nicely as it requires to write TemplateLoader class.</div><div><br /></div>
Build result based on tempalte "page"
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Configuration cfg = new Configuration(Configuration.VERSION_2_3_31);
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setLogTemplateExceptions(false);
Get the template (uses cache internally)
DominoTemplateLoader dominoLoader = new DominoTemplateLoader(getDatabase());
cfg.setTemplateLoader(dominoLoader);
Template template = cfg.getTemplate("page");
/* Merge data-model with template */
HashMap<String, Object> tags = new HashMap<String, Object>();
tags.put("title", "hellow world");
tags.put("description", "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.");
Writer out = new StringWriter();
template.process(tags, out);
String html = out.toString();
</code></pre>
The most important part was actually to build DominoTemplateLoader class and below you can see it
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">public class DominoTemplateLoader implements TemplateLoader {
private View m_view;
public DominoTemplateLoader(Database database) throws NotesException {
m_view = database.getView("($Template)");
}
public void closeTemplateSource(Object templateSource) throws IOException {
Document doc = (Document) templateSource;
try {
doc.recycle();
} catch (NotesException e) {
e.printStackTrace();
}
}
public Object findTemplateSource(String id) throws IOException {
try {
return m_view.getDocumentByKey(id, true);
} catch (NotesException e) {
e.printStackTrace();
}
return null;
}
public long getLastModified(Object templateSource) {
Document doc = (Document) templateSource;
try {
return doc.getLastModified().toJavaDate().getTime();
} catch (NotesException e) {
e.printStackTrace();
}
return 0;
}
public Reader getReader(Object templateSource, String encoding) throws IOException {
if (templateSource == null) return null;
Document doc = (Document) templateSource;
try {
return doc.getFirstItem("Body").getReader();
} catch (NotesException e) {
e.printStackTrace();
}
return null;
}
}
</code></pre>
As you can see the Loader class get document form a view and simply get data from item Body.
</description><link>https://dpastov.blogspot.com/2022/09/java-freemarker-with-domino.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-8131522236122546237</guid><pubDate>Fri, 10 Dec 2021 11:42:00 +0000</pubDate><atom:updated>2021-12-10T12:50:24.979+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Domino</category><category domain="http://www.blogger.com/atom/ns#">Java</category><title>Journalize email from Exchange to Domino using Addin</title><description><p style="text-align: justify;">One of my customer moves to Office 365 and also wants to move to to Exchange/Outlook 356 during next year while keeping Domino app running as it is of now.</p><p style="text-align: justify;">They have customized mail boxes with few actions which allow to journalize emails into their Domino applications and that is quite critical functionality so that would need to be mirrored.</p><p style="text-align: justify;">We have decided to built Outlook Add-in (works in web, client and also with mobile devices).</p><p style="text-align: justify;">Here are a few advises to those who would need to developer similar functionality.</p><h2 style="text-align: left;">1. Create a outlook add-in project and define manifest</h2><p style="text-align: justify;">You would have to create a project with manifest and needed html, css, js elementets. You can easily find information how to do that on MS sites (not going to provide any links as they could change in future). That will allow you to define UI, see my example.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEh_4esBXJv79zol54gBm-sz2zOkSw29dSNOmGsmW0ox5bjrBYmYszxWcYzQAtgl9ylpUkwBHIT7PR6EQJ-ck03Agm6p_iCvJ_9AwZ7CS-vXjifEdpVARjPMycKFi3XTYls2BPFhwccfSA0Gc94tLBYEmSuwp1AtwhVutGzPTkleTwAM4hPHJQ=s1154" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="487" data-original-width="1154" height="169" src="https://blogger.googleusercontent.com/img/a/AVvXsEh_4esBXJv79zol54gBm-sz2zOkSw29dSNOmGsmW0ox5bjrBYmYszxWcYzQAtgl9ylpUkwBHIT7PR6EQJ-ck03Agm6p_iCvJ_9AwZ7CS-vXjifEdpVARjPMycKFi3XTYls2BPFhwccfSA0Gc94tLBYEmSuwp1AtwhVutGzPTkleTwAM4hPHJQ=w400-h169" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><h2 style="clear: both; text-align: left;">2. Send memo ID to Domino</h2>
<p>We need to get information about email from Outlook Add in and send those items to Domino (you would have to build REST API on Domino side that can receive data from Outlook).</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Office.context.mailbox.getCallbackTokenAsync(function(result) {
...
var token = result.value;
var ewsurl = Office.context.mailbox.restUrl;
var ewsItemId = Office.context.mailbox.item.itemId;
const itemId = Office.context.mailbox.convertToRestId(ewsItemId,Office.MailboxEnums.RestVersion.v2_0);
// send token, ewsurl and itemId to Domino endpoint
...
}
</code></pre>
<p>Having those keys (token url and itemId) you can pull email in Mime format</p>
<h2>3. Convert Mime to Notes email</h2>
<p style="text-align: justify;">So at this point Domino received data from Add in and can finally do another request to Exchange server (using token, ewsurl and itemId) to read the memo MIME</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Dim http As NotesHTTPRequest
Dim enpoint As string
Set http = m_app.NotesSession.Createhttprequest()
Call http.Setheaderfield("Authorization", "Bearer " + token)
enpoint = ewsurl + |/v2.0/me/messages/| + itemId + |/$value|
getItemMIME = http.get(enpoint)</code></pre>
<p style="text-align: justify;">There is no native Domino LS/Java Mime Parser however I found working example by Stephan: <a href="https://notessensei.com/blog/2012/04/importing-eml-files-into-notes-lots-of-them.html">Importing EML files into Notes (lots of them)</a>. It worked well, but seems it does not handle inline images (need to do more testing etc).
</p><p style="text-align: justify;">Alternatively I was told that there is <a href="https://github.com/OpenNTF/XPagesExtensionLibrary/blob/master/extlib/lwp/product/runtime/eclipse/plugins/com.ibm.domino.commons/src/com/ibm/domino/commons/mime/MimeMessageParser.java">MimeMessageParser.java</a> that writes MIME to a Notes document. This class is part of the XPages Extension Library. So it has sense to compare them.</p>
<p></p></description><link>https://dpastov.blogspot.com/2021/12/journalize-email-from-exchange-to.html</link><author>noreply@blogger.com (Dmytro)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEh_4esBXJv79zol54gBm-sz2zOkSw29dSNOmGsmW0ox5bjrBYmYszxWcYzQAtgl9ylpUkwBHIT7PR6EQJ-ck03Agm6p_iCvJ_9AwZ7CS-vXjifEdpVARjPMycKFi3XTYls2BPFhwccfSA0Gc94tLBYEmSuwp1AtwhVutGzPTkleTwAM4hPHJQ=s72-w400-h169-c" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-4002131272119632850</guid><pubDate>Mon, 22 Nov 2021 09:10:00 +0000</pubDate><atom:updated>2021-11-22T10:24:03.256+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DSAPI</category><title>Alter user during authentication using DSAPI</title><description><div style="text-align: justify;">I had a need to alter user during web-authentication process on fly (skipping password validation).
Initially the task looked impossible but I managed to solve it using DSAPI filter.</div>
<div style="text-align: justify;">Though the solution looks quite unsecure it could be very useful in some cases (by high level administrators) who needs to 'signin' as a user in their organization to do some checks.</div>
<p>Here are few most important snippets how to do that:</p><p>
</p><h4>1. Subscribe for the event kFilterAuthenticate</h4>
<p>That means that our dsapi filter only intercepts one specific event: kFilterAuthenticate), as there are other 10-15 other events which we do not wanna touch.</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">EXPORT unsigned int FilterInit(FilterInitData* filterInitData) {
STATUS error = NOERROR;
filterInitData-&gt;appFilterVersion = kInterfaceVersion;
filterInitData-&gt;eventFlags = kFilterAuthenticate;
// other logic
// ...
}</code></pre>
<h4>2. Catch the authenticate event and process it</h4>
<p>Get our event and associate it with a C function</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">EXPORT unsigned int HttpFilterProc(FilterContext* context, unsigned int eventType, void* eventData) {
/* Include only those events we want to handle */
switch (eventType) {
case kFilterAuthenticate:
return Authenticate(context, (FilterAuthenticate *) eventData);
default:
break;
}
return kFilterNotHandled;
} // end HttpFilterProc</code></pre>
<h4>3. Finally set a desired username</h4>
<p>Below I only show the key moment - replace user name with another name</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">unsigned int Authenticate(FilterContext* context, FilterAuthenticate* authData) {
/* logic that calculate username */
// .................................
// char[] fullName = "CN=T5 Tester5/O=DmytroDev";
// .................................
/* Copy the canonical name for this user that dsapi requires. */
strncpy ((char *)authData-&gt;authName, fullName, authData-&gt;authNameSize);
authData-&gt;authNameSize = strlen(alterAuthToken);
authData-&gt;authType = kAuthenticBasic;
authData-&gt;foundInCache = TRUE;
return kFilterHandledEvent;
}
</code></pre>
<p style="text-align: justify;">In order to improve security I have built an application on Domino side that generates tokens which have to be set in cookie and then DSAPI filter reads the cookie and get username from database. Tokens could be generated only by certain people are will be deleted by schedule agents after some time.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK85lHFLoCOQDcGUz6PrsAY6Y4iKo059Z5apPuifaFqKsJZMKu_zmMxcxIyAx3yD13p_zzDikqBeTHowmsM9HEyvQuIMA7wRMO_A0fOIWyx5u2VB9qleNAnmA1fqtZXoc-80Pj/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="208" data-original-width="552" height="121" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK85lHFLoCOQDcGUz6PrsAY6Y4iKo059Z5apPuifaFqKsJZMKu_zmMxcxIyAx3yD13p_zzDikqBeTHowmsM9HEyvQuIMA7wRMO_A0fOIWyx5u2VB9qleNAnmA1fqtZXoc-80Pj/" width="320" /></a></div><br /><br /><p></p><p style="text-align: justify;">On the screenshot below you can see that I signed in as a "T5 Tester5" using my custom token AlterAuthToken while I am Anonymous.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpRKdnunl09_7rE2Dt9z2Sh06MCN_MG_RbB2LWvC3oPQ5svmJm0wXm7gVdOSzFQU7J5Zkl2Kqc1bG9OhOsOi6KgcQDiGLS91c3rqNnT7DY5Ll8lRgcUgA-Yblxdk6PbZCa29Vc/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="446" data-original-width="921" height="194" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpRKdnunl09_7rE2Dt9z2Sh06MCN_MG_RbB2LWvC3oPQ5svmJm0wXm7gVdOSzFQU7J5Zkl2Kqc1bG9OhOsOi6KgcQDiGLS91c3rqNnT7DY5Ll8lRgcUgA-Yblxdk6PbZCa29Vc/w400-h194/image.png" width="500" /></a></div><br /><br /><p></p><p></p><p></p></description><link>https://dpastov.blogspot.com/2021/11/alter-user-during-authentication-using.html</link><author>noreply@blogger.com (Dmytro)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK85lHFLoCOQDcGUz6PrsAY6Y4iKo059Z5apPuifaFqKsJZMKu_zmMxcxIyAx3yD13p_zzDikqBeTHowmsM9HEyvQuIMA7wRMO_A0fOIWyx5u2VB9qleNAnmA1fqtZXoc-80Pj/s72-c" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-1308867666822181335</guid><pubDate>Fri, 12 Nov 2021 09:29:00 +0000</pubDate><atom:updated>2023-09-25T11:36:50.787+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">lotus script</category><category domain="http://www.blogger.com/atom/ns#">notes api</category><title>Clear database replication history programatically</title><description><p>Recently I had a need to make a solution that can periodically clean replication history for list of databases.</p><p>Native LotusScript/Java classes do not allow that, but there is an C API for that.</p><p>Here is a cross platform solution (works for Windows/Linux)</p>
<h4>Declare</h4>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Public Const W32_LIB = {nnotes.dll}
Public Const LINUX_LIB = {libnotes.so}
Declare Function W32_NSFDbOpen Lib W32_LIB Alias {NSFDbOpen} (ByVal dbName As String, hDb As Long) As Integer
Declare Function W32_NSFDbClose Lib W32_LIB Alias {NSFDbClose} (ByVal hDb As Long) As Integer
Declare Function W32_NSFDbClearReplHistory Lib W32_LIB Alias {NSFDbClearReplHistory} (ByVal hDb As Long, flags As Integer) As Integer
Declare Function LINUX_NSFDbOpen Lib LINUX_LIB Alias {NSFDbOpen} (ByVal dbName As String, hDb As Long) As Integer
Declare Function LINUX_NSFDbClose Lib LINUX_LIB Alias {NSFDbClose} (ByVal hDb As Long) As Integer
Declare Function LINUX_NSFDbClearReplHistory Lib LINUX_LIB Alias {NSFDbClearReplHistory} (ByVal hDb As Long, flags As Integer) As Integer</code></pre>
<h4>Using C API functions</h4>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">// get a handler to database
If IS_WINDOWS Then
rc = W32_NSFDbOpen(Server &amp; "!!" &amp; FileName, hDb)
Else
rc = LINUX_NSFDbOpen(Server &amp; "!!" &amp; FileName, hDb)
End If
// clear replication history
If IS_WINDOWS Then
rc = W32_NSFDbClearReplHistory(hDb, 0)
Else
rc = LINUX_NSFDbClearReplHistory(hDb, 0)
End If
// close datababase (be sure you always close hDb if you opened it, otherwise memory leak).
If IS_WINDOWS Then
rc = W32_NSFDbClose(hDb)
Else
rc = LINUX_NSFDbClose(hDb)
End If
</code></pre>
<p>Be sure that you always close hDb handler if you opened the database, otherwise it would lead to memory leak)</p>
<p>See the full solution on GitHub: <a href="https://github.com/dpastov/DominoReplicationHistoryCleaner" target="_blank">DominoReplicationHistoryCleaner</a></p></description><link>https://dpastov.blogspot.com/2021/11/clear-database-replication-history.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-6990268371903179935</guid><pubDate>Thu, 08 Apr 2021 10:27:00 +0000</pubDate><atom:updated>2021-04-08T12:40:27.650+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">lotus script</category><category domain="http://www.blogger.com/atom/ns#">notes api</category><title>Checking if database is encrypted with LotusScript (C API)</title><description><p>
Since it's not possible to identify encryption status and level using native
LotusScript/Java classes here is a way to do that. The solution is based on
Notes CAPI (within LotusScript) but it works for both Linux/Windows
environment.
</p>
<p>
I will omit&nbsp;NSFDbOpen and NSFDbClose since it's easy to find out and
focus instead on the main function: NSFDbLocalSecInfoGetLocal.</p>
<p><b>Declaration</b></p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Const NNOTES ="nnotes.dll"
Const LIBNOTES ="libnotes.so"
Declare Public Function WIN_NSFDbLocalSecInfoGetLocal Lib NNOTES Alias "NSFDbLocalSecInfoGetLocal"(ByVal hDb As Long, state As Long, strength As Long) As Integer
Declare Public Function LIN_NSFDbLocalSecInfoGetLocal Lib LIBNOTES Alias "NSFDbLocalSecInfoGetLocal"(ByVal hDb As Long, state As Long, strength As Long) As integer</code></pre>
<p><b>Function check encryption status</b></p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">public Function NSFDbLocalSecInfoGetLocal(hDB As Long, state As Long, strength As long) As Integer
If isDefined("WINDOWS") Then
NSFDbLocalSecInfoGetLocal = WIN_NSFDbLocalSecInfoGetLocal(hDb, state, strength)
ElseIf isDefined("LINUX") Then
NSFDbLocalSecInfoGetLocal = LIN_NSFDbLocalSecInfoGetLocal(hDb, state, strength)
End If
End Function</code></pre>
<p><b>Example how to use it</b></p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px; text-align: left;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Private Function calcEncryption(database As NotesDatabase, doc As notesdocument)
Dim sDb As String
Dim hDb As Long
Dim state As Long
Dim encrypt As Long
Dim rc As Integer
sDb = database.server &amp; "!!" &amp; database.filepath
rc = NSFDbOpen(sDb, hDb)
If rc &lt;&gt; 0 Then Exit function
rc = NSFDbLocalSecInfoGetLocal(hDB, <b>state</b>, <b>encrypt</b>)
If rc &lt;&gt; 0 Then
Error 9001, "Impossible to read encryption. Error code: " &amp; CStr(rc)
End If
rc = NSFDbClose(hDb)
End Function</code></pre><ul><li><b>
state</b>: 0 (not encrypted), 1 (encrypted) or 2 (will be encrypted after compact)
</li><li><b>encrypt</b>: 1 (easy), 2 (middle), 3 (strong)</li></ul><p></p>
</description><link>https://dpastov.blogspot.com/2021/04/checking-if-database-is-encrypted-with.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-5623655571788393425</guid><pubDate>Wed, 20 Jan 2021 11:25:00 +0000</pubDate><atom:updated>2021-01-20T12:31:35.005+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">lotus script</category><category domain="http://www.blogger.com/atom/ns#">LS2J</category><category domain="http://www.blogger.com/atom/ns#">web</category><title>How to post attachments using form to agent </title><description><p>I have a form with some text fields and I also needed to send attachments within same form.</p>
<p>Form is printed by agent and is processed by another agent written in LotusScript.</p>
<p>I spent some time working on solution and here it is.</p>
<p>The idea is to convert selected files to base64 on client side and then post data on submission and agent that process submission will conver base64 to file.</p>
<p>Here is a form, note that we run some logic when files are added</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">&lt;form name="formName" method="post" action="agentName?openagent"&gt;
&lt;input name="title" value="xxx"&gt;
&lt;input type="file" name="files" multiple onchange="toBase64()"&gt;
&lt;/form&gt;</code></pre>
<p>Here is how we convert selected files to base64 and how we results as text fields to form (JS is not optimal, it can be done without jQuery)</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">function toBase64() {
var files = document.querySelector('input[type=file]').files;
var form = $("form");
form.find("input[name^='filebase64']").remove(); // replace
function readAndSave(file, index) {
var reader = new FileReader();
reader.addEventListener("load", function() {
form.append("<input name="filebase64_&quot;+index + &quot;" type="hidden" value="&quot;+this.result+&quot;" />");
form.append("<input name="filename_&quot;+index + &quot;" type="hidden" value="&quot;+file.name+&quot;" />");
}, false);
reader.readAsDataURL(file);
}
if (files) {
[].forEach.call(files, readAndSave);
}
}</code></pre>
<p>Once form is submitted we have to read base64 items and convert them to file. There are at least 2 solutions: pure LS or Java/LS2J</p>
a) LotusScript using NotesMIMEHeader
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Private Function saveBase64AsFile(base64 As String, filePath As string) As Boolean
On Error GoTo ErrorHandler
Dim stub As NotesDocument
Dim stream As NotesStream
Dim item As NotesMIMEEntity
Dim header As NotesMIMEHeader
Dim emb As NotesEmbeddedObject
Dim fileName As String
Dim contentType As string
Dim base64File As String
fileName = StrRightBack(filePath, "\")
contentType = StrRight(Strleft(base64, ";"), ":")
base64File = StrRight(Base64, ",")
Call scriptLog.loginfo(fileName)
Call scriptLog.loginfo(contentType)
Set stub = db.Createdocument()
Set item = stub.CreateMIMEEntity("Body")
Set header = item.createHeader("Content-Disposition")
Call header.setHeaderVal({attachment; filename="} &amp; fileName &amp; {"})
Set stream = app.NotesSession.CreateStream()
Call stream.WriteText(base64File)
Call item.SetContentFromText(stream, contentType, ENC_BASE64)
Call stream.Truncate
Call stream.Close
Call stub.Closemimeentities(True)
Set emb = stub.Getattachment(fileName)
Call emb.Extractfile(filePath)
Exit Function
ErrorHandler:
Error Err, Error
End Function</code></pre>
b) Java with LS2J using native classses.
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">import java.util.Base64;
import java.io.IOException;
import java.nio.file.*;
public class Base64ToFile{
public boolean convert(String base64String, String filePath) {
try {
byte[] decodedImg = Base64.getDecoder().decode(base64String.getBytes());
Path destinationFile = Paths.get(filePath);
Files.write(destinationFile, decodedImg);
return true;
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
}</code></pre>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">UseLSX "*javacon"
Use "Base64ToFile"
Class Base64ToFile
Private jSession As JavaSession
Private jClass As Javaclass
Private jObject As JavaObject
Private jError As JavaError
Sub New()
Set jSession = New JavaSession
Set jClass = jSession.GetClass("Base64ToFile")
Set jObject = jClass.Createobject()
End Sub
Public Function convert(base64 As String, filePath As String) As Boolean
convert = jObject.convert(base64, filePath)
End Function
End Class</code></pre></description><link>https://dpastov.blogspot.com/2021/01/how-to-post-attachments-using-form-to.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-610147718484182841</guid><pubDate>Tue, 20 Oct 2020 09:32:00 +0000</pubDate><atom:updated>2020-10-21T14:55:53.957+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Domino</category><category domain="http://www.blogger.com/atom/ns#">Java</category><title>JavaServerAddin in Domino - constructor and schedule</title><description><p>In this article we will improve our java addin 'DemoAddin' with following features:</p>
<ol style="text-align: left;"><li>Constructor that accepts parameters when we load java addin from console.</li><li>We will schedule output to console amount of registered person in names.nsf (every 33 seconds).</li><li>Define destructor.</li><li>Load (with parameter) and Unload addin from console</li></ol>
<h4>Constructor</h4>
<p>We will define 2 constructor, one that can accept parameters and one in case if we load addin without any parameters. It is pretty obvious how it works.</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">// we expect our first parameter is dedicated for secondsElapsed
public DemoAddin(String[] args) {
this.secondsElapsed = Integer.parseInt(args[0]);
}
// constructor if no parameters
public DemoAddin() {}</code></pre>
<p>Means if we run command like below it will run using constructor with parameters</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">load runjava org.demo.DemoAddin 33</code></pre>
<h4>Schedule worker</h4>
<p>There is a method (it works but deprecated, however I have not found what should be use instead). The snippet below run constant loop, open names.nsf, read amount of users in the view People and output it to console. The main line here is <strong>this.addInRunning()</strong>, it keeps loop running forever (until we change it to <strong>this.stopAddin()</strong> or unload addin from console)</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">session = NotesFactory.createSession();
String server = session.getServerName();
while (this.addInRunning()) {
/* gives control to other task in non preemptive os*/
OSPreemptOccasionally();
if (this.AddInHasSecondsElapsed(secondsElapsed)) {
ab = session.getDatabase(server, "names.nsf");
long count = ab.getView("People").getAllEntries().getCount();
logMessage("Count of persons: " + Long.toString(count));
ab.recycle();
}
}</code></pre>
<h4>Destructor</h4>
<p>Keep in mind that we need to be careful with Notes object, we have to release memory (recycle) after we no longer use them. So it's a good idea to create own terminate method that release memory for all Notes object you delcared and use it when addin unloads. There is also built-in method <strong>finalize</strong> so you can put code there, but I prefer to have own method and use it in places I need</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">private void terminate() {
try {
if (this.ab != null) {
this.ab.recycle();
}
if (this.session != null) {
this.session.recycle();
}
logMessage("UNLOADED (OK)");
} catch (NotesException e) {
logMessage("UNLOADED (**FAILED**)");
}
}</code></pre>
<h4>Load (with parameter) and Unload addin from console</h4>
<p> In order to run addin with parameter simply add it after name of Addin, use space as a separator when you need more than 1 parameter</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">load runjava org.demo.DemoAddin 33</code></pre>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">[1098:0002-23A0] 10/20/2020 11:15:00 AM JVM: Java Virtual Machine initialized.
[1098:0002-23A0] 10/20/2020 11:15:00 AM RunJava: Started org/demo/DemoAddin Java task.
[1098:0004-3984] 10/20/2020 11:15:00 AM DemoAddin: version 2
[1098:0004-3984] 10/20/2020 11:15:00 AM DemoAddin: build date 2020-10-19 11:00 CET
[1098:0004-3984] 10/20/2020 11:15:00 AM DemoAddin: java 1.8
[1098:0004-3984] 10/20/2020 11:15:00 AM DemoAddin: seconds elapsed 33
[1098:0004-3984] 10/20/2020 11:15:33 AM DemoAddin: Count of persons: 11
[1098:0004-3984] 10/20/2020 11:16:06 AM DemoAddin: Count of persons: 11
[1098:0004-3984] 10/20/2020 11:16:39 AM DemoAddin: Count of persons: 11
[1098:0004-3984] 10/20/2020 11:17:12 AM DemoAddin: Count of persons: 11</code></pre>
<p>When you want to unload addin using console here is a command</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">tell runjava unload org.demo.DemoAddin</code></pre>
<p>And you should be see confirmation on console if everything went fine</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">[1098:0004-3984] 10/20/2020 11:26:55 AM DemoAddin: UNLOADED (OK)
[1098:0002-23A0] 10/20/2020 11:26:55 AM RunJava: Finalized org/demo/DemoAddin Java task.
[1098:0002-23A0] 10/20/2020 11:26:56 AM RunJava shutdown.</code></pre>
<p>If you are interested in this topic I can recommend at least two more sources
<a href="https://www.nsftools.com/tips/JavaAddinTest.java">NSFTools.com JavaAddinTest</a> and <a href="https://github.com/AndyBrunner/Domino-JAddin">AndyBrunner / Domino-JAddin</a> or wait for new articles in my blog :-). Also feel free to ask questions if you are uncertain.</p>
<p>Full version of DemoAddin class is hosted on github: <a href="https://github.com/dpastov/DominoJavaAddin">DominoDemoAddin</a></p>
<strong>All articles in series</strong><br>
<ol>
<li><a href="https://dpastov.blogspot.com/2020/10/javaserveraddin-in-domino-introduction.html">JavaServerAddin in Domino - introduction</a></li>
<li><a href="https://dpastov.blogspot.com/2020/10/javaserveraddin-in-domino-constructor.html">JavaServerAddin in Domino - constructor and schedule</a></li>
</ol>
</description><link>https://dpastov.blogspot.com/2020/10/javaserveraddin-in-domino-constructor.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-1941771492360303198</guid><pubDate>Wed, 14 Oct 2020 07:00:00 +0000</pubDate><atom:updated>2020-10-20T11:51:25.792+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Domino</category><category domain="http://www.blogger.com/atom/ns#">Java</category><title>JavaServerAddin in Domino - introduction</title><description><p style="text-align: justify;">I will show how to build, register and load simple JavaAddin for Domino. I'm not entirely sure if lotus.notes.addins.JavaServerAddin is supported by HCL, so use that for your own sake.</p>
<h3>1) Java class</h3>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">import lotus.notes.addins.JavaServerAddin;
public class DemoAddin extends JavaServerAddin {
public void runNotes() {
AddInLogMessageText("Hello world", 0);
}
}</code></pre>
<h3>2) JAR - from project</h3>
<p style="text-align: justify;">Export/build JAR file from the DemoAddin project (we are going to put jar file in the Domino folder).</p>
<h3>3) Register JavaAddin</h3>
<p style="text-align: justify;">Place JAR file under Domino, f.x. path could be (DemoAddin is a folder and it could be just any name, DemoAddin-1.jar is our JAR file we built earlier)</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">C:\IBM\Domino\DemoAddin\DemoAddin-1.jar</code></pre>
<p style="text-align: justify;">and then register it in server's notes.ini using variable <b>JAVAUSERCLASSES</b>. In case if there are other addin registered there use semicolon as a separator for Windows and a colon for Linux</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">JAVAUSERCLASSES=addin-1;.\DemoAddin\DemoAddin-1.jar;addin-2</code></pre>
<p style="text-align: justify;"><strong>Alternatively</strong> simply put JAR file into the folder \jvm\lib\ext, but personally I prefer to keep customization separately instead of mixing core JAR files with customization. Additionally I'm not sure what happens to custom JAR file when is upgradet.</p>
<h3>4) Load JavaAddin</h3>
<p style="text-align: justify;">It's time to run our DemoAddin. From console run following command</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">load runjava DemoAddin</code></pre>
<p style="text-align: justify;">Take into account if your include your class into a package, f.x. package org.demo; than you should add that into run command</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">load runjava org.demo.DemoAddin</code></pre>
<p style="text-align: justify;">If everything went fine you should see 3 lines</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">RunJava: Started DemoAddin Java task.
Hello world
RunJava: Finalized DemoAddin Java task.</code></pre>
<h3>Possible error</h3>
<p style="text-align: justify;">If you registered JAR file incorrectly, the error could be like this. In such case just make sure you followed steps properly.</p>
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">RunJava: Can't find class DemoAddin1 or lotus/notes/addins/demoaddin1/DemoAddin1 in the classpath. Class names are case-sensitive.</code></pre>
<p style="text-align: justify;">If I find time, I will make few more posts about this topic. It's really just a tip of the iceberg.</p>
<strong>All articles in series</strong><br>
<ol>
<li><a href="https://dpastov.blogspot.com/2020/10/javaserveraddin-in-domino-introduction.html">JavaServerAddin in Domino - introduction</a></li>
<li><a href="https://dpastov.blogspot.com/2020/10/javaserveraddin-in-domino-constructor.html">JavaServerAddin in Domino - constructor and schedule</a></li>
</ol>
</description><link>https://dpastov.blogspot.com/2020/10/javaserveraddin-in-domino-introduction.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>6</thr:total><georss:featurename>Copenhagen, Denmark</georss:featurename><georss:point>55.6760968 12.5683372</georss:point><georss:box>27.365862963821158 -22.587912799999998 83.986330636178849 47.7245872</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-3749560390882886022</guid><pubDate>Wed, 26 Feb 2020 23:06:00 +0000</pubDate><atom:updated>2020-02-27T00:10:39.196+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><title>NotesRichText to HTML native within Domino 10</title><description>Just realized that Domino 10+ came with possibility to convert RichTextItem to HTML almost in 1 line.<br />
<br />
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">RichTextItem rt = (RichTextItem) doc.getFirstItem("Body");
String html = rt.convertToHTML(null);
</code></pre><br />
Finally all these tricky transformation of RichText to HTML can be removed, same goes to custom JSON and HTTPRequest libraries.<br />
<br />
I wonder what other useful improvements I missed?</description><link>https://dpastov.blogspot.com/2020/02/notesrichtext-to-html-native-from-10.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-4869138124769123073</guid><pubDate>Mon, 17 Feb 2020 22:24:00 +0000</pubDate><atom:updated>2020-02-17T23:31:39.455+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CloudFlare</category><category domain="http://www.blogger.com/atom/ns#">DSAPI</category><title>Rewrite URL with CloudFlare for Domino</title><description><div>
Years ago I created few solutions for Domino using DSAPI:</div>
<ol>
<li>remove last slash in URL served by Domino.</li>
<li>rewrite URL.</li>
<li>better control over 404/500 error pages.</li>
</ol>
<br />
<div>
It was quite complicated solution (DSAPI is not easy topic).</div>
<div>
Today another client asked similar features (remove last slash and rewrite url).</div>
<div>
I started to recall how DSAPI works but then I reminded myself that the client stick with CloudFlare in front of their Domino servers.</div>
<br />
<div>
Cloudflare has 'page rules' which allow to solve issue with last trailing slash. Just matter of configuration.</div>
<br />
<div>
And about rewriting URL it's actually possible to achieve with workers! You can see below how to rewrite URL.</div>
<div>
In example below I changed url like<br />
domain.com/section/page?param1=aaa&amp;param2=bbb<br />
=&gt;<br />
domain.com/router?openagent&amp;req=section/page&amp;param1=aaa&amp;param2=bbb</div>
<br />
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">addEventListener('fetch', event =&gt; {
const url = new URL(event.request.url);
const pathname = url.pathname.substr(1);
if (pathname.startsWith("design") || pathname.startsWith("files") || pathname.startsWith("api")) {
return;
}
event.respondWith(handleRequest(event.request));
})
/**
* Rewrite URL and makes query param available
* @param {Request} request
*/
async function handleRequest(request) {
let url = new URL(request.url);
let pathname = url.pathname.substr(1);
url.pathname = "?openagent&amp;req="+pathname;
var query = url.search;
if (query!="") {
url.pathname += "&amp;" + query.substr(1);
}
const newRequest = new Request(url, new Request(request));
return await fetch(newRequest)
}
</code></pre>
</description><link>https://dpastov.blogspot.com/2020/02/rewrite-url-with-cloudflare-for-domino.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-4083845564953667170</guid><pubDate>Wed, 25 Sep 2019 10:46:00 +0000</pubDate><atom:updated>2019-09-25T12:46:26.807+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JSON</category><title>JSON Reader in LotusScript</title><description>For those who are still running Domino v9 (or below) here is a LotusScript library that can parse JSON into something useful. I implemented it some time ago and since that time almost had no issues with it. Since many customers that did not migrate to v10 (and probably won't do that in near future) it could be very useful to them.<br />
<br />
You can download my realization on github: <a href="https://github.com/dpastov/jsonparser-ls">jsonparser-ls</a><br />
<br />
See example below how it works<br />
<br />
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Dim parser As JSONParser
Dim jsonObj As JSONObject
Dim jsonArr As JSONArray
Dim jsonString As String
Set parser = New JSONParser
'object
jsonString = |{"array":[1, 2 , 300.56 ] , "boolean":true,"null":null,"number":123,"object":{"a":"b","c":"d","arr":["12","23",34.56],"e":"f","ho":true},"string":"Hello World"}|
Set jsonObj = parser.parse(jsonString)
'test
Print jsonObj.HasItem("array") 'true
Print jsonObj.HasItem("array1") 'false
print jsonObj.GetItem("array").Items(2) '300.56
print IsNull(jsonObj.GetItem("null")) 'true
print jsonObj.GetItem("number") '123
print jsonObj.GetItem("object").getItem("c") 'd
print jsonObj.GetItem("object").getItem("ho") 'true
print jsonObj.GetItem("object").getItem("arr").Items(2) '34.56
'array
jsonString = |[{a:1,b:true,_dd:null},12,"13",true,{}]|
Set jsonArr = parser.parse(jsonString)
'test
print jsonArr.Items(0).getItem("b") 'true
print jsonArr.Items(1) '12
print jsonArr.Items(2) '13
print jsonArr.Items(3) 'true
print TypeName(jsonArr.Items(4)) '"JSONOBJECT"</code></pre>
<br /></description><link>https://dpastov.blogspot.com/2019/09/json-reader-in-lotusscript.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-6711847220246992020</guid><pubDate>Tue, 24 Sep 2019 12:02:00 +0000</pubDate><atom:updated>2019-09-24T14:03:13.800+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">LS2J</category><title>Create Excel files with LotusScript without Excel installed</title><description><div style="text-align: justify;">
One of my customer asked me to find a solution to create Excel files using LotusScript on server without Excel on it (well who wants to do install Excel and other tools on Server). Took some time but I have made a proof of concept using&nbsp;<a href="https://poi.apache.org/">Apache POI</a> and it worked very very nice. I have also made a LS2J cover so it's more easily for people who are not familiar with Java to create Excel files.</div>
<br />
I put demo on my github account with some explanation so feel free to have a look on it: <a href="https://github.com/dpastov/excel-apache-ls">excel-apache-ls</a>&nbsp;but if you wonder how it works, see snippet below:<br />
<br />
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Option Public
Option Declare
UseLSX "*javacon"
Use "Apache.Excel"
Sub Initialize
Dim jSession As JavaSession
Dim jClass As Javaclass
Dim jObject As JavaObject
Dim filepath As String
Dim row As Integer
Set jSession = New Javasession
Set jClass = jSession.GetClass("explicants.office.Excel")
Set jObject = jClass.Createobject()
Call jObject.createSheet("sheet A-100")
Call jObject.createSheet("sheet B-100")
Call jObject.createSheet("sheet C-100")
Call jObject.getSheet("sheet A-100")
row = row + 1
Call jObject.setCellValueString("lorem", row, 0)
Call jObject.setCellValueString("ipsum", row, 1)
Call jObject.setCellValueDouble(55, row, 2)
row = row + 1
Call jObject.setCellValueString("hello", row, 0)
Call jObject.setCellValueString("world", row, 1)
Call jObject.setCellValueDouble(200.50, row, 2)
row = row + 1
Call jObject.setCellValueString("gurli gris", row, 0)
Call jObject.setCellValueString("george", row, 1)
Call jObject.setCellValueDouble(0.505, row, 2)
filepath = Environ("Temp") &amp; Join(Evaluate({@Unique})) &amp; ".xls"
Call jObject.saveAsFile(filepath)
MsgBox filepath
End Sub</code></pre>
<br /></description><link>https://dpastov.blogspot.com/2019/09/create-excel-files-with-lotusscript.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-8696763436701578120</guid><pubDate>Tue, 03 Sep 2019 12:49:00 +0000</pubDate><atom:updated>2019-09-29T10:00:55.955+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">LS</category><title>Formatting NotesDatetime as Java SimpleDateFormat</title><description><div style="text-align: justify;">Recently I had to made proper formatting of NotesDateTime object (using LotusScript) with respect to different locale. I had written a cover in LS2J for Java SimpleDateFormat class that works independently (without Java library), so copy/paste and go on.</div><br />
Here is an example how it works<br />
<pre style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">Dim jdtr As New jDateTimeRich
Dim dt As New NotesDateTime("15-10-2017 10:20:30")
MsgBox jdtr.SimpleDateFormat(dt, "dd-MM-yyyy", "", "") ' "15-10-2017"
MsgBox jdtr.SimpleDateFormat(dt, "d-MMM-yy", "ru", "RU") ' "15-окт-17"
MsgBox jdtr.SimpleDateFormat(dt, "EEEEE MMMMM yyyy HH:mm:ss.SSSZ", "da", "DK") ' "søndag oktober 2017 11:20:30.000+0200")
</code></pre><div><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;"><br />
</code></div><div><div style="text-align: justify;"><div style="text-align: left;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 13.6px; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">The beautiful part of it - is translation of months and days according to Locale.</code></div></div></div><div></div><div><div style="text-align: justify;">I have uploaded source/class on github. Feel free to re-use it: <a href="https://github.com/dpastov/jdatetimerich-ls"><b>jDatetimeRich-LS</b></a>&nbsp;and report issues of course.</div></div></description><link>https://dpastov.blogspot.com/2019/09/formatting-notesdatetime-as-java.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-6610518483329320203</guid><pubDate>Tue, 17 Jul 2018 11:51:00 +0000</pubDate><atom:updated>2018-09-13T10:28:12.661+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Domino</category><category domain="http://www.blogger.com/atom/ns#">Java</category><title>Domino with Java 6 and TSL 1.2</title><description>Recently I have faced an issue where one of our provider changed SSL and they disabled supporting of TLS 1.0 (as far as I understand it's non secure ourdays) and TLS 1.2 should be used instead. As a result our java agents (which used HttpsURLConnection) could not connect anymore to provider.<br />
<br />
Error message looked like this:<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">Caused by: java.security.AccessControlException: Access denied (<a href="http://javax.net/">javax.net</a>.ssl.SSLPermission setHostnameVerifier)</span></pre>I have found 2 possible solutions:<br />
<br />
<h3>Enable TLS 1.2 on Domino (applicable only for 9.0.1 FP3 IF2 and higher)</h3><br />
The Domino JVM is based on Java 1.6 and default settings configured in a way to use TLS 1.0. Luckily our Domino servers had version 9.0.1 FP4 (and TSL 1.2 support has been added since FP3 IF2). So our version was capable to work with 1.2 (in theory) but it took some time to make it work.<br />
<br />
In order to configure Domino JVM to use TLS 1.2 you need to:<br />
<ol><li>Create JVM settings file, f.x. C:\Domino\jvmOptions.ini</li>
<li>Add parameter in jvmOptions.ini<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">https.protocols=TLSv1.2</span></pre></li>
<li>Add path to jvmOptions.ini file in notes.ini<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">JavaUserOptionsFile=C:\Domino\jvmOptions.ini</span></pre></li>
</ol>After you added settings don't forget to restart Domino server. Keep in mind that setting is global meaning all agents that will start to use TLS1.2 therefore it is definitely worth to verify everything before and after this fix.<br />
<br />
<h3>Java library solution</h3><br />
If that is not a way you can go with (f.x. Domino has lower version or something won'f work if you switch to TLS 1.2) then it's still possible to make custom Java Library that will make it possible, see link: <a href="https://stackoverflow.com/questions/33364100/how-to-use-tls-1-2-in-java-6">How to use TLS 1.2 in Java 6</a>.<br />
<br />
It worked for me as well, but it requires to give permission in java policy on Domino server.</description><link>https://dpastov.blogspot.com/2018/07/domino-with-java-6-and-tsl-12.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-4574629473821550347</guid><pubDate>Wed, 08 Mar 2017 14:31:00 +0000</pubDate><atom:updated>2017-03-09T09:38:33.960+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Play Framework</category><title>View.html.index cannot be resolved to a type</title><description><div style="text-align: justify;">If your play project in eclipse says that it can't resolve a type (see message below), but you are certain that everything should be fine</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ View.html.index cannot be resolved to a type
</span></pre><div style="text-align: justify;">try to make a clean compile</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ activator clean compile eclipse</span></pre><div style="text-align: justify;">It helped me to resolve my issue.</div></description><link>https://dpastov.blogspot.com/2017/03/viewhtmlindex-cannot-be-resolved-to-type.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-1670596980056503904</guid><pubDate>Thu, 12 Jan 2017 12:08:00 +0000</pubDate><atom:updated>2017-01-12T13:08:49.000+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Play Framework</category><title>Kill Play Framework process</title><description><div style="text-align: justify;">When we run application in DEV mode (using command activator run) the process normally will be killed when terminal is closed. It's pretty easy since PID is started/closed automatically and therefore we do not care about it at all.</div><div style="text-align: justify;">Once we start application in PROD mode there is a file RUNNING_PID is created (./target/universal/stage/RUNNING_PID). There is a command (since version 2.4) in activator (stopProd) which will close PID</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ activator stopProd</span></pre><div style="text-align: justify;">Alternatively you can just kill process 'manually'<br />
</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ kill $(cat target/universal/stage/RUNNING_PID)</span></pre></description><link>https://dpastov.blogspot.com/2017/01/kill-play-framework-process.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-802839450719715223</guid><pubDate>Thu, 12 Jan 2017 09:31:00 +0000</pubDate><atom:updated>2017-01-12T15:18:18.096+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Play Framework</category><title>Play Framework project in production - Building process</title><description><div style="text-align: justify;">We want to deploy our Play project to production environment.</div><br />
<h3>Create a binary version of application</h3><div style="text-align: justify;">There are two commands that can help you to make a build. Simply run <b>dist</b> (it invokes universal:packageBin) or <b>universal:packageZipTarball</b> in Play console and wait</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ dist</span></pre><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ universal:packageZipTarball</span></pre><div style="text-align: justify;">Result will be a ZIP or TGZ file located in target/universal folder with everything needed for you project (it means you do not need to install SBT or Activator on your server, just pure Java). Once you extract ZIP you will find 2 runner files in bin folder (one for unix and one for windows). Just run it and your server will up</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ path/to/hellow-world/bin/hello-world-app
[info] play.api.Play - Application started (Prod)
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000</span></pre><div style="text-align: justify;">Make sure you have rights to run server, sometimes you need to give rights (see example below)</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ chmod +x /path/to/bin/project-name</span></pre><div style="text-align: justify;">To run process in background<br />
</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">$ sudo nohup target/universal/stage/bin/eqa-app -Dhttp.port=80 -Dplay.crypto.secret="secret_token_123" </dev/null >/dev/null 2>&1 &</span></pre></description><link>https://dpastov.blogspot.com/2017/01/play-project-production-building-process.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-6201891631946620722</guid><pubDate>Thu, 12 Jan 2017 07:00:00 +0000</pubDate><atom:updated>2017-01-12T10:32:58.600+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Play Framework</category><title>Play Framework project in production - Application Secret</title><description><div style="text-align: justify;">I am going to make series of articles about how to deploy <a href="https://www.playframework.com/">Play Framework</a>&nbsp;(version 2.5) application on <a href="https://www.centos.org/">centOS</a>&nbsp;together with build system <a href="https://jenkins.io/">Jenkins</a>. I'm doing this first time and want to document everything for myself and at the same time I hope it can be useful for somebody else as well.<br />
<br />
Before I wrote few articles how to setup hello-world project on centOS or macOS however now I'm going to work on production setup. I assume you already have you hello-world project and clean centOS environment.<br />
<br />
Let's have a look on important moment.<br />
</div><br />
<h1>Application secret</h1><br />
<div style="text-align: justify;">Each play application has secret key which is used for signing session and some other important stuff. It is not possible to run play project in production mode in case if secret is not set or if it is set to default value 'changeme'. Secret key is stored in application.conf file /path/to/hello-word/conf/application.conf in variable play.crypto.secret (see below).</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">## Secret key
# http://www.playframework.com/documentation/latest/ApplicationSecret
# ~~~~~
# The secret key is used to sign Play's session cookie.
# This must be changed for production, but we don't recommend you change it in this file.
play.crypto.secret = "changeme"</span></pre><div style="text-align: justify;">Of course we should not share our secret key and therefore it has to be used/stored on production side only.<br />
</div><br />
There are at least 3 ways how we can use secret key on production side.<br />
<br />
<h3>1. Secret key as a parameter</h3>It is fine if you have simple application on 1 server, but I would not really recommend that for bigger project.<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">/path/to/hello-world -Dplay.crypto.secret="secret_token_123"
</span></pre><h3>2. Environment variables</h3>That would read variable from OS environment, otherwise default value will be used (actually the last defined one, in example below it is "chagneme").<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">play.crypto.secret="changeme"
play.crypto.secret=${?APPLICATION_SECRET}</span></pre><h3>3. Use separate configuration file</h3>Separate configuration is probably the best way to go.<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">include "application"
play.crypto.secret="QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241AB`R5W:1uDFN];Ik@n"
</span></pre><div style="text-align: justify;">They include config while running application.<br />
</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">/path/to/hello-word/bin/yourapp -Dconfig.file=/path/to/production.conf</span></pre><h3>Secret tools<br />
</h3><div style="text-align: justify;">There are few already builtin function that can help you deal with secrets: playGenerateSecret (generate secret) and playUpdateSecret (generate and update into config).<br />
</div><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">$ playGenerateSecret
[info] Generated new secret: G28Dze]Z4lr@Or_9DCoz;tT_yCj6opKkkIh27K>[0l_NT9lZaFfs?=zx[Wulz>cX
[success] Total time: 0 s, completed Jan 11, 2017 6:24:12 PM
</span></pre><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">$ playUpdateSecret
[info] Generated new secret: QmJ?udauJgDj34AYifbprJvbT5I8^Vw1MY0WmbYRscZmAOotkalbhXbIs^48_Uc9
[info] Updating application secret in /Users/dpa/git/eqa-app/conf/application.conf
[info] Replacing old application secret: changeme
[success] Total time: 0 s, completed Jan 11, 2017 9:22:06 PM
</span></pre></description><link>https://dpastov.blogspot.com/2017/01/play-project-production-application-secret.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-5478261138628991011</guid><pubDate>Sun, 25 Dec 2016 18:55:00 +0000</pubDate><atom:updated>2016-12-25T19:58:08.765+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Play Framework</category><title>HTTP Routing in Play Framework</title><description><p>We are going to check how Play connect http requests with our code. F.x. when user hits http://localhost:9000/ what happens?</p><h3>HTTP Routing</h3><p>There is already built in http router in Play Framework. It allows to connect incoming requests with <a href="https://dpastov.blogspot.dk/2016/12/actions-in-play-framework-25.html" title="Action in Play Framework">Play Action</a> and therefore with public method in a controller class.</p><h3>Configuring HTTP Routing</h3><p>Normally the configuration for HTTP routing is located in conf/routes. See example:</p><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;"># Static path
GET /clients/all controllers.Clients.list()
# Dynamic path
GET /clients/:id controllers.Clients.show(id: Long)
GET /files/*name controllers.Application.download(name)
# Dynamic parts with regexp
GET /items/$id<[0-9]+> controllers.Items.show(id: Long)
</span></pre><p>If there are few routes are matched for the same request then the first one in a configuration file will be used.</p></description><link>https://dpastov.blogspot.com/2016/12/http-routing-in-play-framework.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-3485099017221828262</guid><pubDate>Fri, 23 Dec 2016 07:00:00 +0000</pubDate><atom:updated>2016-12-23T08:00:32.463+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">javascript</category><title>Template literals</title><description><p>I have to follow up with changes to ES6. Today I noticed template literals (there is also tagged template literals but that I will check later).<br />
I am really happy with that, it is simple and helps a lot.</p><p>Template literals are a new feature in ES6 that provide us string template things!</p><p>Let's have a look on real example</p><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: &quot;verdana&quot; , sans-serif;">var a = "Apples";
var b = 10;
console.log(`I would like to buy ${b+b} ${a}.`);
// I would like to buy 20 Apples.</span></pre></description><link>https://dpastov.blogspot.com/2016/12/template-literals.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-75119149454015195</guid><pubDate>Thu, 22 Dec 2016 15:13:00 +0000</pubDate><atom:updated>2016-12-22T16:37:22.869+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Play Framework</category><title>Actions in Play Framework 2.5</title><description><p>Requests that come to application based on Play usually are processed by thing which is called action.</p><p><strong>Action</strong> it is just a method that processes parameters of requests and sends result back to web client</p><p>Let's look on example below</p><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">package controllers;
import play.mvc.*;
/**
* This controller contains an action to handle HTTP requests
* to the application's home page.
*/
public class HomeController extends Controller {
/**
* An action that renders an HTML page with a welcome message.
* The configuration in the <code>routes</code> file means that
* this method will be called when the application receives a
* <code>GET</code> request with a path of <code>/</code>.
*/
public Result index() {
return ok("Hello World!");
}
}</span></pre><p>We see an action index that return Result (HTTP response which we send to web client).</p></description><link>https://dpastov.blogspot.com/2016/12/actions-in-play-framework-25.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34728599.post-4810745915189334794</guid><pubDate>Wed, 21 Dec 2016 11:06:00 +0000</pubDate><atom:updated>2016-12-21T12:06:29.565+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Play Framework</category><category domain="http://www.blogger.com/atom/ns#">Typesafe</category><title>Hello World on Play Framework 2.5 on OSX</title><description><h2>Today we are going to make Hello World project based on Play Framework 2.5 on OS X</h2><p>I'm getting back to <a href="https://www.playframework.com/">Play Framework</a> again and I'm going to build simple start project.</p><h3>1. Checking if Java is installed</h3><p>Make sure you have java installed.</p><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">java -version</span></pre><p>If java is installed you will see message like that:</p><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
</span></pre><h3>2. Installing Typesafe activator (current version is 1.3.12)</h3><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">brew install typesafe-activator</span></pre><h3>3. Let's create a new project</h3><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">activator new hello-world
</span></pre><p>Activator will ask you what template you want to use for new project? (I used play-java).<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;"> 1) minimal-akka-java-seed
2) minimal-akka-scala-seed
3) minimal-java
4) minimal-scala
5) play-java
6) play-scala
</span></pre><p>That will create a java project for us</p><p>Now let's run it. Go into newly create project and run activator</p><pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 97%;"><span style="font-family: Verdana, sans-serif;">activator run
</span></pre><p>That will run our project and up server as well. You can access project by localhost:9000</p></description><link>https://dpastov.blogspot.com/2016/12/hello-world-on-play-framework-25-on-osx.html</link><author>noreply@blogger.com (Dmytro)</author><thr:total>3</thr:total></item></channel></rss>