Where should I store custom permissions for my web app - configuration

I'm wondering where is the ideal place to store custom permissions in my web applications.
For example I have the following permissions:
AdminPermission
ReadPermission
WritePermission
At the moment I store these in the static utilities class as the constant string type objects.
Thank you

Somehow I guess you are talking about a Java app. You could try to externalize these resource in files, like in Tomcat (e.g. tomcat-users.xml).

Decided to go for a database approach with enums referencing records in xml config.

Related

How to save data with JSON in a Xamarin app?

Good day dear developers, I really need your help. I want to make an app in Xamarin. In which I added some text data, and it is saved in this application. I need this information to be in the application, and I could get it without the Internet. I understand that you need to use JSON. I really want you to at least give a little hint on how I can store information using JSON in my Xamarin application. Thanks a lot!)
I tried to find information on Google, but there is a lot of superfluous and inappropriate
Depending on your data an easy way could be to use Preferences from Xamarin.Essentials which allows you to store key/value pairs: link to description
Another option would be to save files with JSON as you mentioned already. You create a class which holds your data and then serialize/deserialze the objects to files and from files. For this you can use the Newtonsoft.Json which is a nuget package that you can install.
If you have a MyData class and an data object it would look like this:
Serialize:
File.WriteAllText("fileName", JsonConvert.SerializeObject(data));
Deserialze:
var myData = JsonConvert.DeserializeObject<MyData>(File.ReadAllText("fileName"));
Different platforms has their own file system. For example, iOS limits our access to the file system, which is called Application sandbox. To save or load files, you could learn some basic info first:
for iOS, refer to File system access in Xamarin.iOS.
for Android, refer to File Storage and Access with Xamarin.Android
Xamarin forms provides several ways to use Xamarin forms local data storage. First is use File Handling just as Mario K mentioned. For Serializing JSON, you could refer to Serializing JSON.
Another is that you could use SQLite database engine which allows Xamarin.Forms applications to load and save data objects in shared code. More info, you could refer to Xamarin.Forms Local Databases.
I think you could first check these documentation and decide which method you prefer to use. If you still have questions, feel free to ask.
Hope it works for you.

Storing database json file in optimal way for react native app

I’m using react native, redux and firebase and I have a 1 MB database export that contains food nutritional information from the Canadian Nutrition File database.
This data will never change and is used in a FlatList users can search and import from.
What’s the optimal way for me to store this for my users to access as fast as possible when searching?
I am thinking of simply including the json file with my other source files and calling it from there using require.
But since I have firebase and redux all setup I wondered if it made more sense for whatever reason to consider those options instead.
Thanks in advance for any input.
Since you are already using redux, i'd go for adding the json content to the store on app init/mount so you can get it easily from everywhere.
Another options i'd consider:
Import, parse & render the JSON file stactically on runtime (as it never changes);
Use the AsyncStorage to make it available in local database but outsite the redux store thing.

How to get list of controller in frontend from backend in Yii2 Advanced Template?

I use metadata class to retrieve data but just only in frontend or backend. i don't know how to get data across from backend to frontend. Thank you very much.
You can use components. It can work for an app (component folder in backend or frontend) or also you can create in common folder, so you could use for both. It's a good way to get maintainable code.
More info: http://www.bsourcecode.com/yiiframework2/how-to-create-custom-component-in-yii2-0-framework/

Add API documentation to website using Swagger document

I have a basic webpage built, and a Swagger document JSON file of my API. I am unsure of how to actually add the data from the document to the website so that it can be browsed.
I want to build hosted documentation for the API.
This is the example given by Swagger: http://petstore.swagger.wordnik.com/#!/pet/addPet
Do I just download Swagger UI and use it in conjunction with the JSON file.
But I am unsure on to achieve this. Any advice on how to go about creating something like this would be very helpful.
Swagger-ui is basically a set of static files you can host on your server to display your API.
Unless you may any major changes, you just need to copy the contents of the /dist folder to your server and host it as part of your application (or static website, doesn't matter).
The SwaggerUi object can be customized to your needs, including the URL of the spec you're hosting.
Keep in mind that if you don't host the ui and spec on the same server, (that is, same host and same port), you need to enable CORS.

Save Json to online database GAE or Firebase

I am new to JSON and online databases. I have learned the basics of using .js files and manipulation on them. But I have no clue how to save them onto GAE or Firebase databases.
1)My question is, are every online databases uses JSON differently when they store them?
I have no idea what it looks like storing onto an online database so
2)Can you give me an example of JSON stored in Firebase or GAE. Links to tutorials are also helpful.
Firebase is a true "online database" in a sense that you can save/retrieve/query data to it, without actually writing any code on the server. As such, it is close to Backend as a Service offerings, such as Parse, Kinvey, etc.. Search the web to find more services and compare features that you need.
OTOH, GAE is an application platform - you will need to write server-side code to create any functionality.
As for examples: please RTFM.
GAE's ndb datastore API has a JsonProperty:
https://cloud.google.com/appengine/docs/python/ndb/properties
It's easy to store a JSON object as a StringProperty, using json.loads, json.dumps to parse. For a simple list, you can use a StringProperty, and giving it the repeated=True tag:
https://cloud.google.com/appengine/docs/python/ndb/properties#repeated