Cloudinary list all images not implemented exception - java

I m trying to list all images from cloudinary using the below code but I get "Not implemented Exception"
Map config = ObjectUtils.asMap(
"cloud_name", Config.CLOUDINARY_CLOUD_NAME,
"api_key", Config.CLOUDINARY_API_KEY,
"api_secret", Config.CLOUDINARY_API_SECRET);
Cloudinary cloudinary = new Cloudinary(config);
Api api = cloudinary.api();
Map result;
try {
result = api.resources(ObjectUtils.emptyMap());
} catch (Exception e) {
e.printStackTrace();
}
Which seems to be coming from
public ApiResponse callApi(HttpMethod method, Iterable<String> uri, Map<String, ? extends Object> params, Map options) throws Exception {
throw new Exception("not implemented");
}
// function parameter values
this = {ApiStrategy#4487}
api = {Api#4499}
shadow$_klass_ = {Class#4338} "class com.cloudinary.android.ApiStrategy"
shadow$_monitor_ = -2091658589
method = {Api$HttpMethod#4395} "GET"
name = {String#4396} "GET"
ordinal = 0
shadow$_klass_ = {Class#4382} "class com.cloudinary.Api$HttpMethod"
shadow$_monitor_ = -2098674761
uri = {ArrayList#4505} size = 2
0 = {String#4400} "resources"
1 = {String#4374} "image"
params = {HashMap#4516} size = 0
options = {Collections$EmptyMap#4371} size = 0

Since Android is a client-side environment and the Admin-API is designated to serve on the server-side, its methods are not implemented for native Android.
Having said that, you can build the HTTP request on your own, using the ADMIN-API endpoint, and issue it in order to collect the information you require.
For more info regarding end points and constructing of the HTTP request, see Cloudinary's docs: http://cloudinary.com/documentation/admin_api

Related

Draw WFS with latlong coordinates to canvas in Java

I am very new to Java programming, I would appreciate any kind of help.
So I want to display a set of lat-long coordinates (more than 50 coordinates) in Java-based canvas (e.g JFrame, Processing) from a WFS server. I have managed to parse lat-long value and print it to the console. Now I'm stuck in how to bring the lat-long coordinates to the screen coordinates (I'd like to draw it on 1000x500 size). I've tried to search for the reference but couldn't find the simplest one for a beginner like me. Here is the current part of my code :
String[] splitc = coord.split(",");
String lon = splitc[0];
String lat = splitc[1];
//parse string to float
float loncoord=Float.parseFloat(lon);
float latcoord=Float.parseFloat(lat);
Can I transfer the coordinates from the WFS to screen coordinates using world2screen.translate of Geotools library as in https://docs.geotools.org/latest/userguide/library/referencing/axis.html ?
In processing, there is a map() function (https://processing.org/reference/map_.html) to transfer from a range to another. I've tried it but it didn't work on my IDE.
One super noob question, I'm trying to store the WFS connection in a function so I can call it in another class, should I store it in static void or use "return"?
If someone can provide an example of a similar task, that would be very helpful. Thanks (Sara)
You can use this formula instead:
float x = ((WIDTH/360.0) * (180 + loncoord));
float y = ((HEIGHT/180.0) * (90 - latcoord));
It should work... Note that it returns a float and takes 5 arguments of the form:
map(input, inputMin, inputMax, outputMin, outputMax)
You only want to create the connection once, so you're left with two viable options: defining the connection as a static variable of a static class, or defining the connection as an instance variable of a class following the singleton pattern.
Assuming you chose the former approach, the method that returns the connection variable should therefore be static but not void:
public static connectionType getConnection() {
return connectionObject;
}
... where connectionType is the datatype of the connection.
The easiest way is to create a GeoTools WFSDataStore, this code builds up the getCapabilities string if the user has given just a URL to the service endpoint and handles authentication if needed. The datastore is stored in a field of the class:
public FetchWFS(String url, String user, String passwd) throws IOException, URISyntaxException {
if (!user.isEmpty()) {
auth = true;
}
baseURL = new URL(url);
List<NameValuePair> nvp = URLEncodedUtils.parse(baseURL.toURI(), "UTF-8");
NameValuePair service = new BasicNameValuePair("service", "wfs");
NameValuePair request = new BasicNameValuePair("request", "getCapabilities");
NameValuePair version = new BasicNameValuePair("version", "2.0.0");
HashMap<String, NameValuePair> parts = new HashMap<>();
parts.put(service.getName(), service);
parts.put(request.getName(), request);
parts.put(version.getName(), version);
for (NameValuePair part : nvp) {
if (part.getName().equalsIgnoreCase("SERVICE")) {
// We don't care what they think this should be
} else if (part.getName().equalsIgnoreCase("REQUEST")) {
// This must be getCapabuilities so we ignore them
} else if (part.getName().equalsIgnoreCase("VERSION")) {
System.out.println("Changing version to " + part.getValue());
parts.put(version.getName(), part);
} else {
parts.put(part.getName(), part);
}
}
URIBuilder builder = new URIBuilder();
builder.setScheme(baseURL.getProtocol());
builder.setHost(baseURL.getHost());
builder.setPort(baseURL.getPort());
builder.setPath(baseURL.getPath());
List<NameValuePair> p = new ArrayList<>();
p.addAll(parts.values());
builder.setParameters(p);
// builder.addParameter("viewparams", "q:\"mySolrQuery\"");
URI uri = builder.build();
System.out.println(uri);
baseURL = uri.toURL();
// fetch the DataStore
Map<String, Object> params = new HashMap<>();
params.put(WFSDataStoreFactory.URL.key, baseURL);
// params.put(WFSDataStoreFactory.WFS_STRATEGY.key, "mapserver");
if (auth) {
params.put(WFSDataStoreFactory.USERNAME.key, user);
params.put(WFSDataStoreFactory.PASSWORD.key, passwd);
}
// params.put(WFSDataStoreFactory.WFS_STRATEGY.key, "mapserver");
datastore = DataStoreFinder.getDataStore(params);
}
Once you have a DataStore (of any type) you can get a list of available
featureTypes and then add one (or more) of them to a map:
JMapFrame frame = new JMapFrame();
MapContent map = new MapContent();
String[] names = datastore.getNames();
featureSource = store.getFeatureSource(names[0]); //fetch first featureType
schema = featureSource.getSchema();
Style style = SLD.createSimpleStyle(schema);
this.layer = new FeatureLayer(featureSource, style);
map.addLayer(layer);
frame.enableToolBar(true);
frame.setMinimumSize(new Dimension(800, 400));
frame.setVisible(true);
The GeoTools Quickstart Tutorial will help you get started with simple mapping, and the Map Styling tutorial will allow you to generate a prettier map when you want more than a simple black and white default map.

How to get more than 1000 search results with Github eclipse java API

I am trying to search a large number of repositories with "searchRepository" method in https://github.com/eclipse/egit-github/tree/master/org.eclipse.egit.github.core
However, there is a limitation to get more than 1000 results
https://developer.github.com/v3/search/#about-the-search-api
Since it will throw an exception "Only the first 1000 search results are available (422)" (based on the code example below)
A solution is presented in github search limit results
My question is how can I split up the search into segments by the date (as mentioned in the thread), or is there a another way to do this with the Java GitHub API.
int countRepos = 0;
Map<String, String> searchQuery = new HashMap<String, String>();
searchQuery.put("language", "java");
List<SearchRepository> searchRes = null;
GitHubClient client = new GitHubClient();
client.setCredentials("xxx", "xxxxx");
RepositoryService service = new RepositoryService(client);
for(int page = 1 ; page <12 ; page++){
try {
searchRes = service.searchRepositories(searchQuery,page);
} catch (IOException e) {
e.printStackTrace();
}
for(SearchRepository repo : searchRes){
System.out.println("Repository"+countRepos+": "+repo.getOwner()+"/"+repo.getName());
countRepos++;
}
}
System.out.println("Total number of repositories are="+countRepos);
Thanks in advance.

NetSuite SOAP API (SuiteTalk) to dump General Ledger

Can anyone give me advice on how to read the general ledger using SuiteTalk, the SOAP API from NetSuite?
For example, if you look at an account or a transaction on the NetSuite UI, there is an option to select "GL Impact". This produces a list of relevant general ledger entries.
However, I couldn't figure out a way to get the same list using SuiteTalk. One initially promising SOAP operation I tried calling was getPostingTransactionSummary(), but that is just a summary and lacks detail such as transaction dates. Another way is to call search() passing a TransactionSearchBasic object. That returns too many types of transaction and I'm not sure which of those actually have an impact on the general ledger.
I'm using Java and Axis toolkit for the SOAP operations, but examples in any language whatsoever (or raw SOAP XML) would be appreciated.
you are on the right track with your transaction search.
You are looking for posting is true and where the line has an account.
However I'd set this up in the saved search editor at least until you've figured out how you are going to filter to manageable numbers of lines. Then use TransactionSearchAdvanced with savedSearchId to pull that info via SuiteTalk
I am able to search GL transaction with below code, this could help you.
public void GetTransactionData()
{
DataTable dtData = new DataTable();
string errorMsg = "";
LoginToService(ref errorMsg);
TransactionSearch objTransSearch = new TransactionSearch();
TransactionSearchBasic objTransSearchBasic = new TransactionSearchBasic();
SearchEnumMultiSelectField semsf = new SearchEnumMultiSelectField();
semsf.#operator = SearchEnumMultiSelectFieldOperator.anyOf;
semsf.operatorSpecified = true;
semsf.searchValue = new string[] { "Journal" };
objTransSearchBasic.type = semsf;
objTransSearchBasic.postingPeriod = new RecordRef() { internalId = "43" };
objTransSearch.basic = objTransSearchBasic;
//Set Search Preferences
SearchPreferences _searchPreferences = new SearchPreferences();
Preferences _prefs = new Preferences();
_serviceInstance.preferences = _prefs;
_serviceInstance.searchPreferences = _searchPreferences;
_searchPreferences.pageSize = 1000;
_searchPreferences.pageSizeSpecified = true;
_searchPreferences.bodyFieldsOnly = false;
//Set Search Preferences
try
{
SearchResult result = _serviceInstance.search(objTransSearch);
List<JournalEntry> lstJEntry = new List<JournalEntry>();
List<JournalEntryLine> lstLineItems = new List<JournalEntryLine>();
if (result.status.isSuccess)
{
for (int i = 0; i <= result.recordList.Length - 1; i += 1)
{
JournalEntry JEntry = (JournalEntry)result.recordList[i];
lstJEntry.Add((JournalEntry)result.recordList[i]);
if (JEntry.lineList != null)
{
foreach (JournalEntryLine line in JEntry.lineList.line)
{
lstLineItems.Add(line);
}
}
}
}
try
{
_serviceInstance.logout();
}
catch (Exception ex)
{
}
}
catch (Exception ex)
{
throw ex;
}
}

How to perform Amazon Cloud Search with .net code?

I am learning Amazon Cloud Search but I couldn't find any code in either C# or Java (though I am creating in C# but if I can get code in Java then I can try converting in C#).
This is just 1 code I found in C#: https://github.com/Sitefinity-SDK/amazon-cloud-search-sample/tree/master/SitefinityWebApp.
This is 1 method i found in this code:
public IResultSet Search(ISearchQuery query)
{
AmazonCloudSearchDomainConfig config = new AmazonCloudSearchDomainConfig();
config.ServiceURL = "http://search-index2-cdduimbipgk3rpnfgny6posyzy.eu-west-1.cloudsearch.amazonaws.com/";
AmazonCloudSearchDomainClient domainClient = new AmazonCloudSearchDomainClient("AKIAJ6MPIX37TLIXW7HQ", "DnrFrw9ZEr7g4Svh0rh6z+s3PxMaypl607eEUehQ", config);
SearchRequest searchRequest = new SearchRequest();
List<string> suggestions = new List<string>();
StringBuilder highlights = new StringBuilder();
highlights.Append("{\'");
if (query == null)
throw new ArgumentNullException("query");
foreach (var field in query.HighlightedFields)
{
if (highlights.Length > 2)
{
highlights.Append(", \'");
}
highlights.Append(field.ToUpperInvariant());
highlights.Append("\':{} ");
SuggestRequest suggestRequest = new SuggestRequest();
Suggester suggester = new Suggester();
suggester.SuggesterName = field.ToUpperInvariant() + "_suggester";
suggestRequest.Suggester = suggester.SuggesterName;
suggestRequest.Size = query.Take;
suggestRequest.Query = query.Text;
SuggestResponse suggestion = domainClient.Suggest(suggestRequest);
foreach (var suggest in suggestion.Suggest.Suggestions)
{
suggestions.Add(suggest.Suggestion);
}
}
highlights.Append("}");
if (query.Filter != null)
{
searchRequest.FilterQuery = this.BuildQueryFilter(query.Filter);
}
if (query.OrderBy != null)
{
searchRequest.Sort = string.Join(",", query.OrderBy);
}
if (query.Take > 0)
{
searchRequest.Size = query.Take;
}
if (query.Skip > 0)
{
searchRequest.Start = query.Skip;
}
searchRequest.Highlight = highlights.ToString();
searchRequest.Query = query.Text;
searchRequest.QueryParser = QueryParser.Simple;
var result = domainClient.Search(searchRequest).SearchResult;
//var result = domainClient.Search(searchRequest).SearchResult;
return new AmazonResultSet(result, suggestions);
}
I have already created domain in Amazon Cloud Search using AWS console and uploaded document using Amazon predefine configuration option that is movie Imdb json file provided by Amazon for demo.
But in this method I am not getting how to use this method, like if I want to search Director name then how do I pass in this method as because this method parameter is of type ISearchQuery?
I'd suggest using the official AWS CloudSearch .NET SDK. The library you were looking at seems fine (although I haven't look at it any detail) but the official version is more likely to expose new CloudSearch features as soon as they're released, will be supported if you need to talk to AWS support, etc, etc.
Specifically, take a look at the SearchRequest class -- all its params are strings so I think that obviates your question about ISearchQuery.
I wasn't able to find an example of a query in .NET but this shows someone uploading docs using the AWS .NET SDK. It's essentially the same procedure as querying: creating and configuring a Request object and passing it to the client.
EDIT:
Since you're still having a hard time, here's an example. Bear in mind that I am unfamiliar with C# and have not attempted to run or even compile this but I think it should at least be close to working. It's based off looking at the docs at http://docs.aws.amazon.com/sdkfornet/v3/apidocs/
// Configure the Client that you'll use to make search requests
string queryUrl = #"http://search-<domainname>-xxxxxxxxxxxxxxxxxxxxxxxxxx.us-east-1.cloudsearch.amazonaws.com";
AmazonCloudSearchDomainClient searchClient = new AmazonCloudSearchDomainClient(queryUrl);
// Configure a search request with your query
SearchRequest searchRequest = new SearchRequest();
searchRequest.Query = "potato";
// TODO Set your other params like parser, suggester, etc
// Submit your request via the client and get back a response containing search results
SearchResponse searchResponse = searchClient.Search(searchRequest);

Call Yellowfin Business Intelligence services with C#

I'm trying to use Yellowfin services from my C# code. They are written on Java, so I've enabed JAX services as they recommend.
So JAX services are running at "localhost:8083/webservices/LegacyReportService?wsdl", and I cannot make them work as specified (I'm running RUNDASHBOARDREPORT method of the ReportService)
That's how I use it:
Web References to the YF services running on my localhost:
Here I call the service
public static reportServiceResponse RunDashboardReport(Int32 reportId, Int32 tabId)
{
var rq = CreateYfRequest("RUNDASHBOARDREPORT");
rq.reportId = reportId;
rq.dashboardTabId = tabId;
using (var srv = new LegacyReportServiceService())
{
var resp = srv.remoteReportCall(rq); // there is no "remoteAdministrationCall" as in the doc
return resp;
}
}
private static reportServiceRequest CreateYfRequest(String command)
{
var rq = new reportServiceRequest
{
loginId = "admin#yellowfin.com.au",
password = "test",
orgId = 1, // This is the primary organization
reportRequest = command
};
return rq;
}
And I get "An exception of type 'System.InvalidOperationException' occurred in System.Xml.dll "
when creating
new LegacyReportServiceService()
I've also tried to add it as a Service Reference, but the result is the same.
The YF team sais "We do have clients that are using .net and C# to develop their integration code. ...The support team has confirmed example code provided in development folder in the Yellowfin directory and WSDL code are accurate and are unable to replicate the errors you’ve identified in your original email."
Please help me to find out, what I'm doing wrong
I've found out that VS generates classes for the web service access from "localhost:8083/webservices/LegacyReportService?xsd=1" and it does that improperly. It makes String[] from original String type.
So editing the generated Reference.cs of the Web Reference did the thing.At least, I've got the response with errorCode 25 "Not authorized".
Try the following code to get rid of response code 25.
rsr.orgId = 1;
rsr.orgIdSpecified = true;
rsr.dashboardTabId = 11111;
rsr.dashboardTabIdSpecified = true;
rsr.reportId = 22222;
rsr.reportIdSpecified = true;
Certain parameters for yellowfin need to explicitly told to read.
Check if this works
reportServiceRequest rq = new reportServiceRequest();
rq.loginId = "admin#xxxxx.com";
rq.password = "xxxxxxx";
rq.orgId = 1;
rq.reportRequest = "RUNDASHBOARDREPORT";
rq.reportId = reportId;
rq.orgIdSpecified = true;
rq.dashboardTabId = 11111;
rq.dashboardTabIdSpecified = true;
rq.reportIdSpecified = true;
rq.dashboardTabId = tabId;
using (var srv = new ServiceReference2.LegacyReportServiceClient())
{
YellowFinIntegrationWithDotNet.ServiceReference2.reportServiceResponse resp = null;
try
{
resp = srv.remoteReportCall(rq); // there is no "remoteAdministrationCall" as in the doc
}
catch (System.Exception ex)
{
MessageBox.Show(ex.InnerException.ToString());
return resp;
}
return resp;
}

Categories