Overwriting default Hibernate Validator messages - hibernate-validator

I want to overwrite the default Hibernate Validator messages in a server faces web app, so I read this part of the documentation: https://docs.jboss.org/hibernate/validator/5.0/reference/en-US/html/chapter-message-interpolation.html#section-message-interpolation
I created two files inside the src/ folder: ValidationMessages.properties and ValidationMessages_de_DE.properties. The file contents are:
javax.validation.constraints.AssertFalse.message = must be false
javax.validation.constraints.AssertTrue.message = must be true
javax.validation.constraints.DecimalMax.message = must be less than ${inclusive == true ? 'or equal to ' : ''}{value}
javax.validation.constraints.DecimalMin.message = must be greater than ${inclusive == true ? 'or equal to ' : ''}{value}
javax.validation.constraints.Digits.message = numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected)
javax.validation.constraints.Future.message = must be in the future
javax.validation.constraints.Max.message = must be less than or equal to {value}
javax.validation.constraints.Min.message = must be greater than or equal to {value}
javax.validation.constraints.NotNull.message = may not be null
javax.validation.constraints.Null.message = must be null
javax.validation.constraints.Past.message = must be in the past
javax.validation.constraints.Pattern.message = must match "{regexp}"
javax.validation.constraints.Size.message = size must be between {min} and {max}
org.hibernate.validator.constraints.CreditCardNumber.message = invalid credit card number
org.hibernate.validator.constraints.Email.message = not a well-formed email address
org.hibernate.validator.constraints.Length.message = length must be between {min} and {max}
org.hibernate.validator.constraints.NotBlank.message = may not be empty
org.hibernate.validator.constraints.NotEmpty.message = may not be empty
org.hibernate.validator.constraints.Range.message = must be between {min} and {max}
org.hibernate.validator.constraints.SafeHtml.message = may have unsafe html content
org.hibernate.validator.constraints.ScriptAssert.message = script expression "{script}" didn't evaluate to true
org.hibernate.validator.constraints.URL.message = must be a valid URL
org.hibernate.validator.constraints.br.CNPJ.message = invalid Brazilian corporate taxpayer registry number (CNPJ)
org.hibernate.validator.constraints.br.CPF.message = invalid Brazilian individual taxpayer registry number (CPF)
org.hibernate.validator.constraints.br.TituloEleitor.message = invalid Brazilian Voter ID card number
I am using a german version of Windows, so the messages are by default in german. After creating the files they should be in english, but they are still in german.
What am I doing wrong?

Okay, the correct folder is /src/main/java/.

Related

rkafka.read() doesn't return a message (Returns double quotes only)

Trying to return a message through rkafka library in R.
Followed the same rkafka documentation # https://cran.r-project.org/web/packages/rkafka/vignettes/rkafka.pdf
Output returns "" without the actual message in it. Kafka tool confirms that the message is sent by the producer.
CODE:
prod1=rkafka.createProducer("127.0.0.1:9092")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing once")
rkafka.closeProducer(prod1)
consumer1=rkafka.createConsumer("127.0.0.1:2181","test")
print(rkafka.read(consumer1))
Output:
[1] ""
Desired Output would return "Testing once".
In order to read the messages of a topic that have already been written to the topic (before the consumer has been started) you need to set offset value to the smallest possible (equivalent to --from-beginning). According to rkafka docs autoOffseetReset argument defaults to largest
autoOffsetReset
smallest : automatically reset the offset to the
smallest offset largest : automatically reset the offset to the
largest offset anything else: throw exception to the consumer
Required:Optional Type:String default:largest
In order to be able to consume messages you need to set autoOffsetReset to "smallest".
consumer1=rkafka.createConsumer("127.0.0.1:2181","test", autoOffsetReset="smallest")
Update: This Code Works:
library(rkafka)
prod1=rkafka.createProducer("127.0.0.1:9092")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing once")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing twice")
rkafka.closeProducer(prod1)
consumer1=rkafka.createConsumer("127.0.0.1:2181","test",groupId = "test-consumer-
group",zookeeperConnectionTimeoutMs = "100000",autoCommitEnable = "NULL",
autoCommitInterval = "NULL",autoOffsetReset = "NULL")
print(rkafka.read(consumer1))
print(rkafka.readPoll(consumer1))
rkafka.closeConsumer(consumer1)
The key is to restart Kafka after deleting the logs it generates.

setup bosun snmp scollector to monitor CPU memory keep get error

i am trying to run scollector from bosun.
after I run the scolector, It cannot show me the memory information, but CPU information was right.
this CODE:
Host = "http://localhost:8070"
DisableSelf = true
Freq = 60
Filter = ["snmp-generic", "snmp-ifaces"]
[[SNMP]]
Community = "test"
Host = "name"
MIBs = [ "devicename"]
[Tags]
product = "fw"
[MIBs]
[MIBs.fw]
BaseOid = ".1.3.6.1.4.1.2620"
[[MIBs.fw.Metrics]]
Metric = "os.cpu"
Oid = ".1.6.7.2.4.0"
Unit = "percent"
RateType = "gauge"
[[MIBs.fw.Metrics]]
Metric = "os.mem.used"
Oid = ".1.6.7.4.5.0"
Unit = "bytes"
RateType = "gauge"
THIS IS LOG
**2016/11/07 17:24:42 error: interval.go:64: snmp-generic-name-fw: asn1: structure error: tags don't match (2 vs {class:0 tag:4 length:11 isCompound:false}) {optional:false explicit:false application:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} #2**
2016/11/07 17:24:43 info: queue.go:90: {"metric":"os.cpu","timestamp":1478539482,"value":2,"tags":{"host":"name","product":"fw"}}
It looks to me like this is an issue converting data types. The error is from deep in the bowels of the asn1 library we are using but I think it boils down to: cpu is represented as an integer, while memory is a string.
Our snmp collector attempts to parse all values into a big.Int, but apparently the string value is not able to be coerced into that by our asn1 library.
Unfortunately I don't see a good way to make this work, except perhaps look for an oid that returns an integer type. Without knowing what device you are using, that is as good as I can offer I'm afraid.

Validate if greater then zero - using valdr-bean-validation

I would like to make sure that totalAmount is greater then 0.
I have following code to in my Java bean:
#NotNull(message = "Total amount must be entered")
#Digits(integer = 8, fraction = 2, message = "Please enter a valid amount less than 99,999,999.99")
#DecimalMin(value = "0.01", message = "Please enter a valid amount more than 0")
private BigDecimal totalAmount;
Unfortunately valdr-bean-validator (tool to use JSR-303 with AngularJS) doesn't support #DecimalMin or #DecimalMax. Is there any other way to create the rule for values greater then zero?
EDIT: please note that totalAmount is BigDecimal
This should do.
#DecimalMin(value = "0", inclusive = false)
by default incluside is true
I couldn't solve it with JSR-303. I finally implemented custom valdr validator.
It is shame that such common case (value equal to zero) is not supported.

How to display date in RDLC in another language

I want to display date in RDLC(Report Definition Language Client-side) as १०/०७/२०१० instead 10/07/2010. How can i do this?
I believe it is not possible - at least not without effort on your side. Native digits are defined in .NET FW like:
var culture = new CultureInfo("km-KH");
for (var i = 0; i < culture.NumberFormat.NativeDigits.Length; i++) {
Console.Out.WriteLine(culture.NumberFormat.NativeDigits[i]);
}
BUT native digits formatting is not supported (yet).
Reference:
http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.digitsubstitution.aspx
The DigitSubstitution property is reserved for future use. Currently,
it is not used in either parsing or formatting operations for the
current NumberFormatInfo object.
You still can manage to do it on your own - i.e. add Report->Report properties->Code
Function Khmer(value)
value = Replace(value,"0","០")
value = Replace(value,"1","១")
value = Replace(value,"2","២")
value = Replace(value,"3","៣")
value = Replace(value,"4","៤")
value = Replace(value,"5","៥")
value = Replace(value,"6","៦")
value = Replace(value,"7","៧")
value = Replace(value,"8","៨")
value = Replace(value,"9","៩")
Khmer = value
End Function
Note - report code uses vb syntax (always) - dunno why.
And in your report add expression for the field you want to encode to Khmer native digits:
=Code.Khmer(Fields!DateCreated.Value)

Getting "Microsoft VBScript runtime error '800a01a8'"

I had inherited a website to do general maintenance on. The web pages are ASP pages but the bulk of my work has been with the html/css. The site has been working fine for a number of years, that is until now. When I try to load pages that are containing VB script I receive the following error:
Microsoft VBScript runtime error '800a01a8'
Object required: '[object]'
/new_products.asp, line 12
the name of the asp page changes based on the page that is being called, but the line reference is the same.
The code that is generating the error is as follows:
Dim objXMLHTTP
Dim coordinates
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
ip = Request.ServerVariables("REMOTE_ADDR")
objXMLHTTP.Open "GET", "http://www.ippages.com/xml/?ip="&ip&"&get=country", False
objXMLHTTP.Send
Set xmldoc = objXMLHTTP.responseXML
country = xmldoc.selectSingleNode("ip_address/lookups/lookup_country").text
set objXMLHTTP=nothing
theCountry = Trim(UCASE(country))
If theCountry = "CA-CANADA" then
Bags = "13.99"
SB4Pack = "14.00"
currency_code = "CAD"
lc = "CA"
Pref = "$"
ShipType = 1
ElseIf theCountry = "US-UNITED STATES" then
Bags = "13.99"
SB4Pack = "14.00"
currency_code = "USD"
lc = "US"
Pref = "$"
ShipType = 2
Else
Bags = "8.00"
SB4Pack = "11.00"
currency_code = "GBP"
lc = "UK"
Pref = "£"
ShipType = 2
End If
With my extremely limited knowledge of VB I have done my best to try and figure out why the code has stopped working, but I am stumped. Any and all help is greatly greatly appreciated.
Since this is an environment specific issue which started to popup recently as you mentioned... No sure statement can be provided. You need to investigate it. What one can do is to suggest some thing. I believe your problem is one of this statement.
Set xmldoc = objXMLHTTP.responseXML
country = xmldoc.selectSingleNode("ip_address/lookups/lookup_country").text
Probably this value is not coming or Null or Nothing.Try to print the value of country if it's coming as Null, Nothing... Later when you try to change the case of country.... You can use tools to capture the Http request and response tools like Fidler to verify what is coming in lookup_country as a value or whether you are getting this node or not.
Also where is theCountry is declared. If it's dynamic variable then check if some one enabled OptionExplicit??

Resources