opa : sending mail - email

I'm trying to send an email using SmtpClient.try_send(). This code used to work before opa switch to the node.js backend :
import stdlib.web.mail.smtp.client
import stdlib.web.mail
function start()
{
Email.email from = {name:some("name"), address:{local:"contact", domain:"hello.com"}}
Email.email to = {name:some("name"), address:{local:"contact", domain:"hello.com"}}
Email.content content = {text : "This is Great!"}
SmtpClient.try_send(from, to, "subject",content, Email.default_options)
<>Hello</>
}
Server.start(
{port:8092, netmask:0.0.0.0, encryption: {no_encryption}, name:"test"},
[
{page: start, title: "test" }
]
)
But now it fails with the following error :
Test serving on http://ks3098156.kimsufi.com:8092
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: write EPIPE
at errnoException (net.js:646:11)
at Object.afterWrite [as oncomplete] (net.js:480:18)
What's wrong ?
Thanks,

Can you try with :
SmtpClient.try_send(from, to, "subject", content, { Email.default_options with to:[to] })

Related

storage.objects().compose() not working

I am using the GCS JSON API via Java. My code to insert objects, delete objects, and copy objects all works great. But for some reason I cannot get storage.objects().compose() to work. No matter what I get a 400 or 500 error. Even when I go to use the "Try it now" feature for compose on the Google website I get the same error. So there must be something basic I am missing.
Here is my code:
StorageObject metadata = new StorageObject()
.setMetadata( ImmutableMap.of("OriginalFileName", originalFileName) )
.setContentType(contentType)
.setAcl( ImmutableList.of( new ObjectAccessControl().setEntity("allUsers").setRole("READER") ) );
// list of files to concatenate
List<SourceObjects> sourceObjects = new ArrayList<SourceObjects>();
for (int i = 0; i <= chunkNumber; i++) {
sourceObjects.add( new SourceObjects().setName(objectName + ".chunk" + i) );
}
ComposeRequest composeReq = new ComposeRequest()
.setSourceObjects(sourceObjects)
.setDestination(metadata);
storage.objects().compose(bucketName, objectName, composeReq).execute();
And here is the error I am getting:
500 { "code" : 500, "errors" : [
{ "domain" : "global", "message" : "Backend Error", "reason" : "backendError" }
], "message" : "Backend Error" }

Populate a nested ObjectRef

So here's my model:
CompetitionSchema = new Mongoose.Schema
name :
type : String
required : true
required_teams :
type : Number
teams : [
_team :
type : Mongoose.Schema.ObjectId
ref : 'teams'
weight :
type : Number
min : 0
]
I would like to be able to populate a competition object in order to access competition.teams[0]._team._id for which I have tried the following:
models('Competition')
.findById id
.populate('teams._team')
.exec (error, competition) ->
if error || !competition
error_callback error
else
success_callback competition
However this has no effect. I've also tried:
models('Competition')
.findById id
.exec (error, competition) ->
if error || !competition
error_callback error
else
options = [
path : 'teams._team'
model : 'teams'
]
models('Competition')
.populate(
competition
, options
, (error, competition) ->
if error || !competition
error_callback competition
else
success_callback competition
)
Also to no effect. I find the API documentation for Model.populate to be quite confusing, so please excuse me if it's plainly obvious!
OK after soaking myself in the topic a bit more I finally came to the below:
models('Competition')
.findById id
.exec (error, competition) ->
if error || !competition
error_callback error
else
options = [
path : '_team'
model : 'teams'
]
models('Team')
.populate(
competition.teams
, '_team'
, (error, competition_teams) ->
if error || !competition_teams
error_callback competition
else
success_callback competition
)
It boils down to: Instead of calling
Competition.populate(competition, { path : 'teams._team' } , callback);
I am now calling:
Team.populate(competition.teams, '_team', callback);
This has the benefit of modifying the competition.teams array rather than returning a copy, so the original competition object receives the changes too!

Drools Expert and Workflow: Unable to resolve ObjectType

I have these validation rule in Drools Expert which I have tested and works fine:
package com.myapp.validationPackage
import com.myapp.model.*;
declare Message
type : String
text : String
end
function Message error(String text) {
Message message = new Message();
message.setType("ERROR");
message.setText(text);
return message;
}
rule "First Validation"
ruleflow-group "Entity Validation"
when
Entity( $h : history )
not ( exists EntityHistory(closeDate == null) from $h
)
then
insert( error("Entity must be open") );
end
Now I want to use this rule in a workflow but give me this error when I try to build the .rf file on Eclipse:
Unable to resolve ObjectType 'Message' : [Rule name='RuleFlow-Split-XX'] ..
How should I use the delcared type to avoid the error?
Thanks.

Getting MailSendException in Grails Mail

I am getting the following error:
ERROR
org.springframework.mail.MailSendException: Failed messages:javax.mail.MessagingException: can't determine local email address; message exceptions (1) are:
Failed message 1: javax.mail.MessagingException: can't determine local email address
CONFIG
grails.mail.host = "xx.xx.com"
grails.mail.port = 25
grails.mail.from = "xx#xx.com"
grails.mail.username = "xx#xx.com"
grails.mail.password = "xxx"
grails.mail.props = ["mail.smtp.auth": "true",
"mail.smtp.socketFactory.port": "25",
"mail.smtp.socketFactory.fallback": "false"]
CODE
try {
sendMail {
to "${params.emailTo}"
subject "${params.emailSubject}"
body "${params.emailMessage}"
}
}
catch (Exception e) {
println e
}
SOLUTION* **changed too this and it worked
sendMail {
to "${params.emailTo}"
from "xx#xx.com"
subject "${params.emailSubject}"
body "${params.emailMessage}"
}
In your CONFIG section, in the line
grails.mail.from = "example#example.com"
You forgot the word 'default'. The correct is:
grails.mail.default.from="example#example.com"
Check the port that you have mentioned in the code. Check if the mail server on your machine is sending data from that port.

Nodejs-mongoose-0.0.5 error when run app.js

/usr/local/lib/node/.npm/mongoose/0.0.5/package/lib/util.js:40
continue;
^^^^^^^^
node.js:68
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Illegal continue statement
at Module._compile (node.js:418:29)
at Object..js (node.js:429:14)
at Module.load (node.js:355:35)
at Function._load (node.js:322:14)
at require (node.js:367:23)
at Object.<anonymous> (/usr/local/lib/node/.npm/mongoose/0.0.5/package/lib/model.js:2:13)
at Module._compile (node.js:423:30)
at Object..js (node.js:429:14)
at Module.load (node.js:355:35)
at Function._load (node.js:322:14)
And the code is just:
var mongoose = require('mongoose').Mongoose;
mongoose.model('User', {
properties: ['user', 'pass', 'widgets' ],
indexes: [ { 'user' : 1 } , { unique : true } ],
});
.......
/usr/local/lib/node/.npm/mongoose/0.0.5/package/lib/util.js:40
else {
// Prevent never-ending loop
if (target === d.value) {
continue;
}
even if i comment the continue statement, causes another error log:
node.js:68
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: ECONNREFUSED, Connection refused
at Socket._onConnect (net.js:548:18)
at IOWatcher.onWritable [as callback] (net.js:165:12)
Any idea?
/usr/local/lib/node/.npm/mongoose/0.0.5/package/lib/util.js
Edit this file and change line 40 from continue; to return;
In Array.prototype.forEach, continue is not supported (you can use the example below to test return vs continue in firebug's console)
[1,2,3,4].forEach(function(val, arr) {
if(val != 1) {
console.log(val);
return;
//continue;
}
console.log('here');
});
ECONNREFUSED is because your mongod is not running - where's the connect string?