Checkstyle regexp not working for annotated lines? - regex

I try to configure a Checkstyle rule to show me Tests marked with a specific TestGroup named FIXME to identify how many of such tests there are (to keep them tracked).
A typical test method looks like this:
#Test(groups = {TestGroups.GAMEHISTORY, TestGroups.FIXME}, description = "Some descriptive text...")
public void navigateThroughGameHistory() throws Exception {
PlayerDTO player = ghHelper.createConfirmedPlayerAndPayIn(TestBase.LANGUAGE);
... some more code ...
}
I tried my very best with various CheckStyle rules (RegExp with Single & Multiline, RegExpJava etc.), but it seems the Checkstyle does not parse lines containing annotations.
The simplest way to find an occurrence of FIXME to me seems the following:
<module name="Regexp">
<property name="severity" value="warning"/>
<property name="format" value=".*FIXME.*"/>
<property name="illegalPattern" value="true"/>
<property name="duplicateLimit" value="-1"/>
<property name="errorLimit" value="100"/>
<property name="ignoreComments" value="false"/>
<property name="message" value="Keep track of the FIXME-Tests!"/>
</module>
However, this does not work. However, if I change the format line to
<property name="format" value=".*player.*"/>
, I get one occurrence. I believe Checkstyle doesn't check Annotated Lines of Code by default - but I could not find any evidence for it.
But maybe my RegEx is just incorrect (simple as it is)?
I am desperate, because I am sure there is a simple solution, but I just can't find it..
Any help greatly appreciated!
Thanks in advance,
Jan

Related

How to transfer multiple files to different directories at the same time

I have created a file transfer service using wso2 integration studio. This service works with a file connector. I have it working from one directory to another, however I want to change this method to work with multiple directories. Initially, I had 2 sequences and a task to do this process, namely, " "FileListenerSeq" sequence, "FileReadSeq" sequence and "FileTask" scheduled task.
I have now created 2 extra sequences and a new task to do the same process. Namely, "FileReplyListenerSeq" sequence, "FileReplyReadSeq" sequence and "ReplyTask" scheduled task.
I want these sequences to work at the same time but even after creating the new sequences and task, the micro-integrator only reads the first initial process. I tried adding the same process twice in one sequence and it works but works only after the first one is done (which makes sense)
Is there a way to do this concurrently with multiple sequences that work at the same time?
environment specs:
Integration studio : 8.1.0
wso2 micro integrator : 7.1.0
file connector : 4.0.11
process flow from directory to directory:
LOCATION 1: FOLDERA --> LOCATION 2: FOLDERB ( This is the process that was created initially and works)
LOCATION 1: FOLDERC --> LOCATION 2: FOLDERD ( This is the new process I want to work with the initial process)
Any assistance will be greatly appreciated.
FileReadSeq source code:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="FileReadSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property description="file name" expression="//file/text()" name="FILE_TO_READ" scope="default" type="STRING"/>
<log level="custom">
<property expression="$ctx:FILE_TO_READ" name="Files to read"/>
</log>
<file.read configKey="LocalFolderAConnection">
<path>{fn:concat('/OUTGOING/' , $ctx:FILE_TO_READ)}</path>
<readMode>Complete File</readMode>
<startLineNum>0</startLineNum>
<endLineNum>0</endLineNum>
<lineNum>0</lineNum>
<contentType>application/binary</contentType>
<includeResultTo>Message Body</includeResultTo>
<enableStreaming>true</enableStreaming>
<enableLock>false</enableLock>
</file.read>
<file.write configKey="LocalFolderBConnection">
<filePath>{$ctx:FILE_PATH}</filePath>
<mimeType>Automatic</mimeType>
<compress>false</compress>
<writeMode>Overwrite</writeMode>
<enableStreaming>true</enableStreaming>
<appendNewLine>false</appendNewLine>
<enableLock>false</enableLock>
<includeResultTo>Message Body</includeResultTo>
<updateLastModified>true</updateLastModified>
</file.write>
<file.read configKey="LocalFolderCConnection">
<path>{fn:concat('/Incoming/' , $ctx:FILE_TO_READ)}</path>
<readMode>Complete File</readMode>
<startLineNum>0</startLineNum>
<endLineNum>0</endLineNum>
<lineNum>0</lineNum>
<contentType>application/binary</contentType>
<includeResultTo>Message Body</includeResultTo>
<enableStreaming>true</enableStreaming>
<enableLock>false</enableLock>
</file.read>
<file.write configKey="LocalFolderDConnection">
<filePath>{$ctx:FILE_PATH}</filePath>
<mimeType>Automatic</mimeType>
<compress>false</compress>
<writeMode>Overwrite</writeMode>
<enableStreaming>true</enableStreaming>
<appendNewLine>false</appendNewLine>
<enableLock>false</enableLock>
<includeResultTo>Message Body</includeResultTo>
<updateLastModified>true</updateLastModified>
</file.write>
<filter regex="true" source="//writeResult/success/text()">
<then>
<log description="Status Log " level="custom">
<property expression="$ctx:FILE_TO_READ" name="files successfully moved"/>
</log>
</then>
<else>
<log description="Failed log">
<property name="message" value="Files failed to move"/>
</log>
</else>
</filter>
</sequence>
I think the best solution for the requirement would be to use file inbound endpoints[1]. You can create multiple inbound endpoints for each file location from where you need to process files. The inbound endpoint will be listening to the defined transport.vfs.FileURI location and the files will be processed parallelly from multiple inbound endpoints. Since the requirement is to transfer the files, you can set the transport.vfs.ActionAfterProcess parameter to MOVE and set the destination file location using the transport.vfs.MoveAfterProcess parameter.
Please refer to the documentation here[1] for more details.
[1] https://ei.docs.wso2.com/en/latest/micro-integrator/use-cases/examples/inbound_endpoint_examples/file-inbound-endpoint/

tokenize function is not reading the value from property in wso2

I need to use tokenize function in my wso2 sequence file.
I am getting the username like testuser#gmail. I need to split the string using the delimeter #. I am using the below code.
. But, It is always printing blank in logs.
Could you please some one help me.
PS:: I have enabled xslt2.0 in my synapse.properties file.
Use the substring-before function
<property name="tokentest" value="testuser#gmail" scope="default" type="STRING"/>
<property name="NEW_CONTENT_TYPE" expression="substring-before($ctx:tokentest,'#')" scope="default" type="STRING"/>
<log level="custom">
<property name="NEW_CONTENT" expression="$ctx:NEW_CONTENT_TYPE"/>
</log>
Hope this helps

WSO2 ESB, and different response types for the same call

I am using WSO2 4.9.
I have a simple endpoint defined as such
<endpoint name="someEndpoint">
<address uri="someAddress" format="soap11">
</endpoint>
This specific endpoint also requires basic HTTP auth, which I provide like this:
<property name="Authorization" description="Set-User-Pwd" expression="fn:concat('Basic ', $ctx:authorizationProperty)" scope="transport" type="STRING"/>
I make a simple call towards it like this:
<call description="Some description">
<endpoint key="someEndpoint"/>
</call>
I should note that the server which I'm attempting to call:
responds with a SOAP answer (i.e. proper XML, etc) when all is good
responds with a HTML answer when authorization errors happen
The problem I'm having concerns the situation when I'm passing it a wrong user. I'm expecting that in this scenario, my fault sequence would get invoked (the above is part of an api declaration, which also has a fault sequence).
But this doesn't happen, and I get the following error:
Caused by: com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </body>; expected </HR>.
at [row,col {unknown-source}]: [1,1054]
I suspect this is happening because WSO2 attempts to parse my HTML response as if it were XML, and fails (which is understandable). I also suspect that this happens before any error sequence gets invoked, etc, and hence my problem.
Edit1: At the beginning of my outSequence, I have a log line which isn't getting printed. So I don't think this is something caused by whatever mediators are in outSequence.
<outSequence>
<log level="custom">
<property name="message" value="OUT call!!!!!!!!!!!!!!!!!!!!!!!" />
</log>
...
</outSequence>
Edit2: Some more details about inSequence.
It contains these lines, which seem to make no difference on the error message (i.e. I get the same if I remove).
<property name="messageType" scope="axis2" value="application/xml"/>
<property name="ContentType" scope="axis2" value="application/xml"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove" />
What can I do in this situation in order to be able to catch these errors? I should note that I don't particularly care about the text in the body (I'm only interested in HTTP status code and maybe HTTP status message).

How to configure password expire time in bulk import from CSV in WSO2 Identity Server 5.3.0

Hi I am using WSO2 Identity Server 5.3.0. I want to create users by using bulk import from a CSV File. I am able to do it successfully.
Problem Statement:
Users are created successfully but in the documentation link, it is mentioned that the default password expiry for the users is 24 hours. Is there any way possible through configuration that we can turn this setting off. OR Increase the time for this password expiry.
Document Link:
I enabled the Bulk storage from user-mgt.xml file.
<Property name="MembershipAttribute">member</Property>
<Property name="BackLinksEnabled">false</Property>
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="UsernameJavaRegExViolationErrorMsg">Username pattern policy violated</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaRegExViolationErrorMsg">Password length should be within 5 to 30 characters</Property>
<Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="SCIMEnabled">true</Property>
<Property name="IsBulkImportSupported">true</Property>
<Property name="EmptyRolesAllowed">true</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="MaxUserNameListLength">500</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="kdcEnabled">false</Property>
<Property name="defaultRealmName">WSO2.ORG</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ConnectionPoolingEnabled">false</Property>
<Property name="LDAPConnectionTimeout">5000</Property>
<Property name="ReadTimeout"/>
<Property name="RetryAttempts"/>
But I cannot find any configuration here to configure this time.
One other hack would be directly removing this password expiry property for all the users from the userstore database directly. You can simply set "UM_REQUIRE_CHANGE" value for all the users to make their passwords work even after 24hours.
UPDATE UM_USER SET UM_REQUIRE_CHANGE=FALSE;
Further explained in https://stackoverflow.com/a/57944771/2910841
Currently, Identity Server does not have an out-of-box configuration option for making the password validity period to increase or to turn the setting off. However, we can accomplish your requirement of not invalidating the password by writing a custom component by extending relevant UserStoreManager. For this purpose you can write a custom userstore manager extending the default JDBCUserStoreManager which will make the password to be valid for an indefinite period. Please refer [1] for more information regarding this. In this sample extension, you need to only override the method "doAddUser()" by making requestPasswordChange variable to false in order to avoid the invalidation of the password. Sample code is as follows.
public void doAddUser(String userName, Object credential, String[] roleList,
Map<String, String> claims, String profileName, boolean requirePasswordChange)
throws UserStoreException {
super.doAddUser(userName, credential, roleList, claims, profileName, false);
}
[1] https://docs.wso2.com/display/IS530/Writing+a+Custom+User+Store+Manager

How to set session timeout at embedd jetty xml configuration?

I have that line of codes at my jetty-servlet-context.xml
<bean id="jerseyServletCtx" class="org.eclipse.jetty.servlet.ServletContextHandler">
<property name="displayName" value="Jersey Servlet Context"/>
<property name="contextPath" value="/rest"/>
<property name="sessionHandler">
<bean class="org.eclipse.jetty.server.session.SessionHandler"/>
</property>
...
How can I add an ability to set maxInactiveInterval into my xml file? Maybe I am missing something it may be anywhere else instead of that jerseyServletCtx, but it should be at jetty-servlet-context.xml. Any ideas are welcome.
PS: I don't have a web.xml
Your question is almost a year old, but in case it might help you or someone else: you may want to review webdefault.xml and check the session-timeout element within the session configuration section.