I have a properties file whose content would be like below
myprop=key1:value1,key2:value2
myprop2=key21:value21,key22:value22
second set
myprop3=key31:value31,key32:value32
How can I show the content on a web page and make it editable, so that, if I change the value of key2 to "value 444", it just changes that and everything else remains intact?
Apache commons configuration looks helpful but not sure how above can be accomplished
I solved it using Apache commons library.
Get Builder object.
Get Configuration object from Builder.
Iterate through all the keys and their values and you can return it as a JSON response to a web page (using controller class).
Make them editable their.
When you update one value of a key; click on save will call another method end point wherein input param would be config key and updated value. which will do config.setProperty and will do builder.save();.
By this, my property file would be updated.
Related
In api automation, let's consider below code to hit the api and get response.
Response res= given().
formParam("email", "value").
formParam("password", "value").
formParam("action", "login").
header("token","value").
when().post("MyResource").then().assertThat().statusCode(200).extract().response();
Actually in the above code we're just building an api with formParams, header and resource with post request right!
so, there we have created 3 formParm manually and passed the values right? now i want that to added automatically based on no of parameters that we have from an excel sheet.
Thing is these parameters can be deleted or new parameters gets added in future, so that's why i want to add those dynamically from an excel sheet data.
how i can do that? any suggestions?
If i've understood you right, you want to have the parameters on the spreadsheet to use dynamically and on runtime.
To do that, you'll need to:
Read the spreadsheet file and get the parameters contained in a data structure such as a Map<String,String>, in which, the key is the field and the value is... the value :P
Iterate upon the data structure selected and set the formParam generically
final RequestSpecification given = given();
for(final Map.Entry<String,String> entry : map.entrySet()) {
given.formParam(entry.getKey(), entry.getValue());
}
final Response res = given.other_things() ...
I hope it helps, but keep in mind the use of Map is not necessary. Choose the data structure more appropriate to your situation!
I have the following issue:
I'm using Spring-MVC with JSPs.
On my page I want to put a couple of links(with urls) in the content area. I'm getting the names of the links plus the description from a properties file via spring:messages.
Now the question is, what is the best-practice or most elegant way to put the link-urls on the page. Should I hardcode them in the jsp? Should they come from the properties file where I have stored the text which goes on the page, should they come from the controller (where they would be stored in static variables) or should they be passed through all the way using a service and a bean etc.?
I would appreciate your opinion!
I have created advanced workflow(Example:- Client name, client code,employees) ,User use the workflow store data's into alfresco database,Now I want get all stored from alfresco once get the data i need use the another workflow drop-down control
In workflow form configuration file,there must be an ftl file reference which will be responsible for drop down.You need to customize that freemarker template file.
In customized free marker template you need to call one webscript which will return data from database.
For the reference you can refer below link.
http://docs.alfresco.com/5.0/tasks/forms-custom-formcontrol.html
My scenario is to read a file from a file endpoint which contains only key value paris like a property file and take a few data from it based on the key .
Any idea how to do them other that using a custom bean or java component.
I would like to know if this is possible any way in Mule or Camel.
Thanks in advance.
If you want to use a Camel route, to pickup files, then something like this
from("file:inbox")
.convertBodyTo(Properties.class)
.log("The foo value is {${body[foo]}")
.log("The bar value is {${body[bar]}")
What we then need is a type converter from java.io.File -> java.util.Properties. Which we could add to camel-core out of the box.
I logged a ticket to add that type converter out of the box in Camel: https://issues.apache.org/jira/browse/CAMEL-7312
I think to this problem explained, the very easy solution is to use java.util.Properties class. Load the file using Properties class which maintains key value pair only.
I'm trying to read the property values from a bar file created by message broker.
I want to do this via java. The api is here: http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fbe43410_.htm
However, I can only figure out how to get the names of the properties NOT THEIR VALUES by using the deployment descriptor. I can see how to override the value that a property has, but once again, not how to retrieve the value. Another words I can see only how to write to the property not read from it. I want to do both! Call me greedy ;)
If I use the command line based utility: http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Faf03900_.htm
I can get the property values no problem.
But I want to get them via java if at all possible.
Thanks in advance for any help on this!
The problem was I was misunderstanding how the deployment descriptor worked. I thought that when the java API referred to overridden properties it meant ones that were over ridden in my java code. But it actually meant all the properties that had a value in the bar file.
That being said getting the values is not strait forward. You have to get all the identifiers and then pass them to getOverride();
BarFile b = BarFile.loadBarFile("C:\\BarParamTest\\myBar.bar");
DeploymentDescriptor d = b.getDeploymentDescriptor();
Enumeration<String> properties = d.getPropertyIdentifiers();
while(properties.hasMoreElements())
{
String p = properties.nextElement();
System.out.println(p + " = " + d.getOverride(p));
}
or use the following to only list properties that have values
Enumeration<String> properties = d.getOverriddenPropertyIdentifiers();
For some reason settings are not written to file, if they are not overriden or not changed.(the reason is the lack of necessity to keep the property's default value:) ) so the way to get the properties is to know their default values. But I would recommend you to use com.ibm.mq.jar library if you're able to connect to broker to read properties using method
java.util.Properties MessageFlowProxy.Node.getProperties()
from already deployed .bar.