request.setAttribute is not working with chain.doFilter - servlet-filters

I have two servlet ReplayFilter and VideoReplayServlet. From ReplayFilter, I am calling VideoReplayServlet using chain.doFilter. I am able to call VideoReplayServlet from ReplayFilter but I am not able to get userId variable from request object in VideoReplayServlet, which I have already set in request object before calling chain.doFilter. You can find my code below -
In ReplayFilter -
request.setAttribute("userId", userId);
request.setAttribute("uname", "mari");
chain.doFilter(request, response);
In VideoReplayServlet -
String uname = request.getParameter("uname");
String user_Id = request.getParameter("userId");
In VideoReplayServlet replay, I am getting both uname and user_Id null.
Can anybody help me?

I think the issue here is that you are setting it as an attribute and expecting it as a parameter which is contradicting.
Try the below code instead
request.getAttribute("userId", userId); //Note the getAttribute() instead of getParameter()

Related

Jira Rest API - Problems to set custom fields

I try to set the field for Testcases in a Testplan. The value I get when reading it is JSONArray.
But when I write the very same JSONArray I extract to a new created Testplan, I get an error message.
Exception in thread "main" com.atlassian.jira.rest.client.api.domain.input.CannotTransformValueException: Any of available transformers was able to transform given value. Value is: org.codehaus.jettison.json.JSONArray: ["SBNDTST-361","SBNDTST-360","SBNDTST-358","SBNDTST-359"]
at com.atlassian.jira.rest.client.api.domain.input.ValueTransformerManager.apply(ValueTransformerManager.java:83)
at com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder.setFieldValue(IssueInputBuilder.java:134)
My method to set the field is this:
public void updateIssue(String issueKey, String fieldId, Object fieldValue) {
IssueInput input = new IssueInputBuilder()
.setFieldValue(fieldId, fieldValue)
.build();
restClient.getIssueClient()
.updateIssue(issueKey, input)
.claim();
The value for the fieldId is "customfield_17473". There is very little documentation on this. Does anyone have an idea how to proceed?
I found the solution by trial and error.
When I send an ArrayList it works.

GetMatchingProductSample AMAZON API

Im try to Get Product details with GetMatchingProductSample.php
request param look correctly:
$request->setSellerId(MERCHANT_ID);
$request->setMarketplaceId(my ID);
$request->setASINList(my ASIN);
when i try to execute i receve always this error:
Fatal error: Call to a member function _toQueryParameterArray() on a non-object
I've look a method but i dont see any error
When i type request-> i have only these methods:
setASINlist
setSellerId
setMWSAuthToken
Finally i found a way to do a right call.
Obviously they lacked the parameters and if someone can serve this is the correct call:
$asins = array('B06Y16RL4W', 'B071DQ128D');
$request = new
MarketplaceWebServiceProducts_Model_GetMatchingProductRequest();
$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$request->setSellerId(MERCHANT_ID);
$request->setMarketplaceId(MARKETPLACE_ID);
$asin_list->setASIN($asins);
$request->setASINList($asin_list);

Get Sitefinitys Generated Password Reset URL

I am trying to get the URL from the password reset which I receive via email of the sitefinity frontend login.
I need to send the URL with the username which is enterd in the form to a server to send the email.
I already tried to override the SendResetPasswordEmail of the LoginFormModel but that only gives me the URL where the reset is located at. (localhost/login/resetpassword)
It looks like the URL is generated in the method SendRecoveryPasswordMail of the Telerik.Sitefinity.Security.UserManager which is not overridable.
Is there a way to get the generated recovery URL to use it in a custom method?
Thanks in advance
Since you already have the URL of the reset password page, I guess your issue is getting the proper query string to pass to that page.
Looking at the source code with JustDecompile, the query string is made up of this:
?vk=userValidationKeyEncoded&cp=pr
The cp=pr seems to be hardcoded, so we leave it as is, the question is how the userValidationKeyEncoded is made.
Again, looking in the code, it is this line:
string userValidationKeyEncoded = UserManager.GetUserValidationKeyEncoded(userByEmail);
And finally:
private static string GetUserValidationKeyEncoded(User user)
{
object[] providerName = new object[] { user.ProviderName, ',', user.Id, ',', DateTime.UtcNow };
string str = string.Format("{0}{1}{2}{3}{4}", providerName);
return SecurityManager.EncryptData(str).UrlEncode();
}
You can use the above code to manually generate the validationKey.

How to get error or success result from Acumatica Web service api?

//LoginResult loginResult = context.Login("user","pass");
//if (loginResult.Code != ErrorCode.OK)
//Get Schema
//Insert
//Add fields values
//....
O301000.Actions.CopyOrder,
O301000.Actions.Save,
O301000.OrderSummary.OrderNbr
Submitresult = O301000.context.Submit(cmds);
How do I know if there was an error when inserting/saving the Order (or any other file)?
I just can find a value 'Submitresult.ErrorCode' like in the Login Result.
Mean while a have solve the issue, when inserting, by looking for the 'O301000.OrderSummary.OrderNbr' not null value.
But that does not works when updating a record.
You should always use a
try{Submitresult = O301000.context.Submit(cmds);}
catch(Exception ex){Console.WriteLine(ex.Message);}
when making these calls. If the SOAP calls returns an error, than the message is passed to the Exception object.

WCF service taking userPincipleNname instead of passed in string as argument

This is a weird issue. I am passing in strings into my service, and that string would be the username of the person logged into my website (via windows authorization). I get the string from my website using
HttpContext.User.Identity.Name.ToString()
I parse it from the domain and just get the user Identity. And then I call a wcf service whose contract is similar to this...
generalWCFContractImplementation(string userID);
Now, you would think it would pass in the string that I sent it... However, that is indeed not the case. After doing some debugging, I found out that the string that is being passed in is the userPrincipleName that I am using to setup the WCF connection! Now why on earth would it do that? I am checking all throughout my code to see if accidentally change the userID in some way, but I check as soon as I enter the function what the value of the ID is, and it is the userPrincipleName! I am extremely confused about what is going on here. Does anybody have any idea why that would occur? and how can I remedy that?
Thanks.
UPDATED with code
public string GetOwnedPopulations(string userID)
{
Log.TraceEvent(System.Diagnostics.TraceEventType.Information, string.Format("Entered Method GetOwnedPopulations() CallerNameOnly: {0}, userID: {1} CallerNameOnly==userID {2}", CallerNameOnly, userID, CallerNameOnly == userID), "General");
this.CallerFullDomain = userID;
this.CallerNameOnly = userID;// this.CallerFullDomain.Substring(this.CallerFullDomain.IndexOf('\\') + 1);
string ans;
Log.TraceEvent(System.Diagnostics.TraceEventType.Information, string.Format("Entered Method GetOwnedPopulations() CallerNameOnly: {0}, userID: {1} CallerNameOnly==userID {2}", CallerNameOnly , userID, CallerNameOnly==userID), "General");
searchPopulationbyOwner oReq = new searchPopulationbyOwner();
oReq.ownerName = this.CallerNameOnly;
try
{
StringBuilder sbBuffer = new StringBuilder();
PopulationManagementClient client = UPMC.ISD.EADIS.PopulationManagement.PopManSvc.Utils.GetClient(this.CallerNameOnly);
searchPopulationbyOwnerResponse resp = client.searchPopulationbyOwner(oReq);
Log.TraceEvent(System.Diagnostics.TraceEventType.Information, string.Format("Getting Null Values?: {0}", (resp == null ? ans="yes" : ans="no")), "General");
XmlSerializer xs = new XmlSerializer(typeof(Population[]));
System.IO.StringWriter sw = new System.IO.StringWriter(sbBuffer);
xs.Serialize(sw, resp.populationList);
string sPopulationtXML = sbBuffer.ToString();
return sPopulationtXML;// client.searchPopulationbyOwner(oReq);
}
catch
{
throw;
}
}
As you can see, I pass in the username, and I then set the object that I am going to pass in equal to the user ID. The thing is, userID is either the applicationPoolID, but I am guessing more than likely it is the userPrincipleName (which would happen to be the same as the applicationPoolIdentity... I am not sure if they have to be the same or not). But this is very weird. I have know idea why on earth that would be passed in and not the actual username... And yes, I have looked at my site to see what is being passed in, and it is indeed, the userID... When it hits the service however, it is the userPrincipleName.
Confused?????