pkinuk Buler

Ranch Hand
+ Follow
since May 22, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by pkinuk Buler

Hi all,

I know the title means nothing, but what i want is, e.g. :

Given I have three sets. They have the same size (e.g. 100, indeed the size is not important). I want to get 100 objects from the three sets, but the number of each set needs to be close, e.g. set1 33, set2 33 and set3 34.

Is there any mathematical model can achieve above scenario?

9 years ago
HI all,

I dont' know if 'Spring' is the correct group to ask my question. I'm new to the AspectJ. I have the following code:



I'm using the Aspecj annotation to declare the pointcut. The following is my code:


However, the method pointCutTest is never called when the method executeBatch is called in its implementation class. How can i set the pointcut for the method executeBatch in the implementation of PointCutIWantToSet?

Victor M. Pereira wrote:I'm not sure if I fully understand what you want, but it seems that your regex is missing a couple of things.

First, the regex you wrote is telling me that the String must begin with "SchemaValidationException" or it must not have Caused By ...

I believe that you are seeking something like: ([a-Z]|[0-9])*(SchemaValidationException|!(Caused by: org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'NonEmptyString'.))+([a-Z]|[0-9])*

I recommend trimming the String since spaces complicate the regex and one missing space might ruined your method.

That would be with regex however from your test case seems that indexOf would be easier to apply.



Thank you for your reply. As I said I had to use one regex to finish the following checking:

1. Check if the string contains A
2. If the string contains A then check if the string doesn't contain B

I've simpified the example. Hopefully someone can fixed the problem.

Thank you in advance

12 years ago

Winston Gutkowski wrote:

pkinuk Buler wrote:Can anyone help me to write the regex?


Yes. DON'T.

Regexes were designed for (originally) string patterns contained in a single line and, although they've been expanded to include multi-line matches, I'd suggest that whatever regex you come up with is likely to be unwieldly.

Seems to me that you are searching for two patterns in a multi-line block, so my pseudo-code would look something like:but I'm quite sure there are other solutions.

Winston

[Edit] @pkinuk: Above is not quite right. You shouldn't read a new line in the outer loop if a match on the 1st string was already found; I leave it to you to correct.



thank you for your reply, I wished I could use the yr pseudo-code do check the string. It was one of the requirements from our client: we have to use one regex to check the following conditions:

1. Check if the string contains ‘A’
2. If above condition return true, then check if the string doesn't contain the 'B'

12 years ago

Henry Wong wrote:

pkinuk Buler wrote:Hi all,

I've gone through a lots of examples in JavaRanch/Other websites, but I still can't write a regex to finish : include a text but exclude another text in the one regex

I have an example: [tt]haha.hello.common.exceptions.SchemaValidationException: Validated XML message - message invalid. [Error Code cegst01_350]\r\n\n\tat haha.hello.common.util.XMLUtility.validateMessage(XMLUtility.java:257)\n\tat haha.hello.mama.papa.release2.socketxml.readers.InputReaderBaseImpl.a(InputReaderBaseImpl.java:7)\n\tat haha.hello.mama.papa.release2.socketxml.readers.InputReaderBaseImpl.<init>(InputReaderBaseImpl.java:1)\n\tat the String is a little bit too long, but it was an log message. What I planned to do in one regex is:
1. Check if the text contains
2. Make sure the text doesn't contain

The Matcher.find() will return true only if the text fulfill above conditions.

Can anyone help me to write the regex?

Thank you in advance



The easiest way to do this is to have a negative look-ahead (generally from the beginning of the regex) attached to the regex search for the item that you want. With the negative look-ahead, the regex will always fail, if it finds the component that it doesn't want.

Using look aheads is pretty advanced, so I suggest that you start there, but don't be surprised if you run into trouble and have to backtrack to learn other parts of regex first.

Henry



Hi Henry, thank you for your quick reply. I did apply the negative look-ahead, but it failed, the Matcher.find() returned true. The following is my code:

The regex i used is

SchemaValidationException(?(?!\QCaused by: org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'NonEmptyString'.\E).)*(?:\s)*)*



However, the Matcher.find() returned true, while the Matcher.group() is

SchemaValidationException: Validated XML message - message invalid. [Error Code cegst01_350]\r\n\n\tat com.qxlva.common.util.XMLUtility.validateMessage(XMLUtility.java:257)\n\tat com.qxlva.nhs.api.release2.socketxml.readers.InputReaderBaseImpl.a(InputReaderBaseImpl.java:7)\n\tat com.qxlva.nhs.api.release2.socketxml.readers.InputReaderBaseImpl.<init>(InputReaderBaseImpl.java:1)\n\tat com.qxlva.nhs.api.release2.socketxml.readers.InputReaderWithSSODataImpl.<init>(InputReaderWithSSODataImpl.java:11)\n\tat com.qxlva.nhs.api.release2.socketxml.readers.GetRolesReaderImpl.<init>(GetRolesReaderImpl.java:4)\n\tat com.qxlva.nhs.api.release2.socketxml.CoreInputReaderFactoryImpl.newInputReader(CoreInputReaderFactoryImpl.java:85)\n\tat com.qxlva.nhs.api.release2.socketxml.CoreInputReaderFactoryImpl.newInputReader(CoreInputReaderFactoryImpl.java:14)\n\tat com.qxlva.nhs.api.release2.socketxml.CoreInputReaderFactoryImpl.newInputReader(CoreInputReaderFactoryImpl.java:52)\n\tat com.qxlva.nhs.api.socket.protocols.NewlineDelimitedAPIBridge.process(NewlineDelimitedAPIBridge.java:108)\n\tat com.qxlva.nhs.api.socket.protocols.NewlineDelimitedAPIBridge.process(NewlineDelimitedAPIBridge.java:20)\n\tat com.qxlva.nhs.api.socket.SocketConnection.d(SocketConnection.java:29)\n\tat com.qxlva.nhs.api.socket.SocketConnection.run(SocketConnection.java:172)\n\tat com.qxlva.nhs.api.socket.SocketThreadManager$SocketThread.run(SocketThreadManager.java:7)\n



The java code is:


Would anybody tell me how to fix it?

Thank you in advance
12 years ago
Hi all,

I've gone through a lots of examples in JavaRanch/Other websites, but I still can't write a regex to finish : include a text but exclude another text in the one regex

I have an example: haha.hello.common.exceptions.SchemaValidationException: Validated XML message - message invalid. [Error Code cegst01_350]\r\n\n\tat haha.hello.common.util.XMLUtility.validateMessage(XMLUtility.java:257)\n\tat haha.hello.mama.papa.release2.socketxml.readers.InputReaderBaseImpl.a(InputReaderBaseImpl.java:7)\n\tat haha.hello.mama.papa.release2.socketxml.readers.InputReaderBaseImpl.<init>(InputReaderBaseImpl.java:1)\n\tat haha.hello.mama.papa.release2.socketxml.readers.InputReaderWithSSODataImpl.<init>(InputReaderWithSSODataImpl.java:11)\n\tat haha.hello.mama.papa.release2.socketxml.readers.GetRolesReaderImpl.<init>(GetRolesReaderImpl.java:4)\n\tat haha.hello.mama.papa.release2.socketxml.CoreInputReaderFactoryImpl.newInputReader(CoreInputReaderFactoryImpl.java:85)\n\tat haha.hello.mama.papa.release2.socketxml.CoreInputReaderFactoryImpl.newInputReader(CoreInputReaderFactoryImpl.java:14)\n\tat haha.hello.mama.papa.release2.socketxml.CoreInputReaderFactoryImpl.newInputReader(CoreInputReaderFactoryImpl.java:52)\n\tat haha.hello.mama.papa.socket.protocols.NewlineDelimitedAPIBridge.process(NewlineDelimitedAPIBridge.java:108)\n\tat haha.hello.mama.papa.socket.protocols.NewlineDelimitedAPIBridge.process(NewlineDelimitedAPIBridge.java:20)\n\tat haha.hello.mama.papa.socket.SocketConnection.d(SocketConnection.java:29)\n\tat haha.hello.mama.papa.socket.SocketConnection.run(SocketConnection.java:172)\n\tat haha.hello.mama.papa.socket.SocketThreadManager$SocketThread.run(SocketThreadManager.java:7)\nCaused by: org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'NonEmptyString'.\n\tat com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)\n\tat com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)\n\tat com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)\n\tat com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)\n\tat com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:410)\n\tat com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3165)\n\tat com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3068)\n\tat com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:2978)\n\tat com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2121)\n\tat com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:791)\n\tat com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.finishNode(DOMValidatorHelper.java:338)\n\tat com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:243)\n\tat com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:186)\n\tat com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:100)\n\tat javax.xml.validation.Validator.validate(Validator.java:127)\n\tat haha.hello.common.util.XMLUtility.validateMessage(XMLUtility.java:8)

the String is a little bit too long, but it was an log message. What I planned to do in one regex is:
1. Check if the text contains
2. Make sure the text doesn't contain

The Matcher.find() will return true only if the text fulfill above conditions.

Can anyone help me to write the regex?

Thank you in advance
12 years ago
Hi all,

I'm new to EJB. I'm reading the book 'Mastering Enterprise JavaBeans 3.0'. I tried to run the HelloWorld example in chapter 3, but I couldn't see the text 'hello()' & 'Hello World' in the eclipse console context. I also tried to open the glassfish log file, it didn't show neither. Would you please help me to solve this problem?

Thank you in advance.

The following are the source code:





Paul Clapham wrote:

pkinuk Buler wrote:Hi all,

Here is my scenario:

1. I set my application using the BASIC auth-method in the web.xml file...

... What I expected is to show the BASIC login box to user and ask them to perform the authentication when a session is created. (Logout user and ask them re-login when the session is timed out)

However, what i found was different what i expected, every time i start a Tomcat server, it allowed me to set the user name and password once. Even thought a new session is created after the current session expired, i still couldn't see the login in box to pop up again unless i closed the browser.

Could anyone give me some advices to help me solve this problem?



Then your expectation was wrong. What you describe is exactly how browsers implement the basic authentication method. They ask the user for the credentials once per browsing session and cache the credentials.

So if you want something different -- and you do -- then you can't use basic authentication.



Thank you for your reply. Does it mean I need to use FORM Authentication to achieve my goal?
13 years ago
hi Jayr Motta,

Thank you for your reply, I tried to google the topic how to remove auth header, but i couldn't find a suitable example. Could you please give me an example or a example page?

What I've done is create a Filter implementation class, in the doFilter method:


unfortunately, the login page didn't show up when the current session expired if I clicked the link again. Here is my filter setting in the web.xml file


Thank you in advance.
13 years ago
Hi all,

Here is my scenario:

1. I set my application using the BASIC auth-method in the web.xml file


2. Set the security-constraint like:


3. Set the session time out as 1 minute:


What I expected is to show the BASIC login box to user and ask them to perform the authentication when a session is created. (Logout user and ask them re-login when the session is timed out)

However, what i found was different what i expected, every time i start a Tomcat server, it allowed me to set the user name and password once. Even thought a new session is created after the current session expired, i still couldn't see the login in box to pop up again unless i closed the browser.

Could anyone give me some advices to help me solve this problem?
13 years ago