// Path: src/main/java/io/pivio/view/app/feed/serverresponse/FeedItem.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class FeedItem {
// 
//     public String document;
//     public int order;
//     public Date timestamp;
//     public List<Field> fields = new ArrayList<>();
// 
//     public FeedItem() {
//     }
// 
//     public Map<String, List<Field>> getUniquePath() {
//         Map<String, List<Field>> result = new HashMap<>();
//         for (Field field : fields) {
//             String uniquePath = field.path.split("/")[1];
//             if (!result.containsKey(uniquePath)) {
//                 result.put(uniquePath, new ArrayList<>());
//             }
//             result.get(uniquePath).add(field);
//         }
//         return result;
//     }
// 
// }
// 
// Path: src/main/java/io/pivio/view/app/overview/detail/ServiceIdShortName.java
// public class ServiceIdShortName {
// 
//     public Service service;
//     public String id;
//     public String short_name;
// 
//     public ServiceIdShortName() {
//     }
// 
//     public ServiceIdShortName(Service service, String id, String short_name) {
//         this.service = service;
//         this.id = id;
//         this.short_name = short_name;
//     }
// 
//     public boolean hasDependencies() {
//         return service != null && service.depends_on != null;
//     }
// 
//     @Override
//     public String toString() {
//         return "ServiceIdShortName{" +
//                 "service=" + service +
//                 ", id='" + id + '\'' +
//                 ", short_name='" + short_name + '\'' +
//                 '}';
//     }
// }
// 
// Path: src/main/java/io/pivio/view/app/overview/detail/serverresponse/Document.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Document {
// 
//     public String owner;
//     public String data_format_version;
//     public String description;
//     public String type;
//     public String vcsroot;
//     public String name;
//     public String short_name;
//     public String id;
//     public String contact;
//     public String created;
//     public String lastUpload;
//     public String lastUpdate;
//     public String status;
//     public String product_context;
//     public List<String> tags = new ArrayList<>();
//     public Map<String, String> links = new HashMap<>();
// 
//     public Runtime runtime = new Runtime();
//     public List<SoftwareDependency> software_dependencies = new ArrayList<>();
//     public Service service = new Service();
//     public Context context = new Context();
// 
//     @Override
//     public String toString() {
//         return "Document{" +
//                 "owner='" + owner + '\'' +
//                 ", data_format_version='" + data_format_version + '\'' +
//                 ", description='" + description + '\'' +
//                 ", type='" + type + '\'' +
//                 ", vcsroot='" + vcsroot + '\'' +
//                 ", name='" + name + '\'' +
//                 ", short_name='" + short_name + '\'' +
//                 ", id='" + id + '\'' +
//                 ", contact='" + contact + '\'' +
//                 ", created='" + created + '\'' +
//                 ", lastUpload='" + lastUpload + '\'' +
//                 ", lastUpdate='" + lastUpdate + '\'' +
//                 ", status='" + status + '\'' +
//                 ", product_context='" + product_context + '\'' +
//                 ", tags=" + tags +
//                 ", links=" + links +
//                 ", runtime=" + runtime +
//                 ", software_dependencies=" + software_dependencies +
//                 ", service=" + service +
//                 ", context=" + context +
//                 '}';
//     }
// 
//     public boolean ofTypeService() {
//         return type.equalsIgnoreCase("service");
//     }
// 
// }
// 
// Path: src/main/java/io/pivio/view/app/overview/list/serverresponse/Overview.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Overview implements Comparable {
// 
//     public String name;
//     public String short_name;
//     public String description;
//     public String lastUpload;
//     public String lastUpdate;
//     public Context context;
//     public String id;
//     public String owner;
//     public String type;
// 
//     @Override
//     public int compareTo(Object o) {
//         return this.name.compareTo(((Overview) o).name);
//     }
// }
// 
// Path: src/main/java/io/pivio/view/configuration/ServerConfig.java
// @Component
// public class ServerConfig {
//     public List pages = new ArrayList<>(); // show nothing for default
//     public String apiAddress = "http://localhost:9123"; // default
//     public String mainUrl = "http://localhost:8080"; // needs to be determined later to match the host with the 'main' app.
//     public String jsApiAddress = "http://localhost:9123/"; // If your webbrowser needs access to the API, the address is a different one.
// 
//     @Override
//     public String toString() {
//         return "ServerConfig{" +
//                 "pages=" + pages +
//                 ", apiAddress='" + apiAddress + '\'' +
//                 ", mainUrl='" + mainUrl + '\'' +
//                 ", jsApiAddress='" + jsApiAddress + '\'' +
//                 '}';
//     }
// }


import io.pivio.view.app.feed.serverresponse.FeedItem;
import io.pivio.view.app.overview.detail.ServiceIdShortName;
import io.pivio.view.app.overview.detail.serverresponse.Document;
import io.pivio.view.app.overview.list.serverresponse.Overview;
import io.pivio.view.configuration.ServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import static java.util.Collections.sort;
package io.pivio.view;




@Component
public class PivioServerConnector {

    private final Logger log = LoggerFactory.getLogger(PivioServerConnector.class);

    @Autowired
// Path: src/main/java/io/pivio/view/app/feed/serverresponse/FeedItem.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class FeedItem {
// 
//     public String document;
//     public int order;
//     public Date timestamp;
//     public List<Field> fields = new ArrayList<>();
// 
//     public FeedItem() {
//     }
// 
//     public Map<String, List<Field>> getUniquePath() {
//         Map<String, List<Field>> result = new HashMap<>();
//         for (Field field : fields) {
//             String uniquePath = field.path.split("/")[1];
//             if (!result.containsKey(uniquePath)) {
//                 result.put(uniquePath, new ArrayList<>());
//             }
//             result.get(uniquePath).add(field);
//         }
//         return result;
//     }
// 
// }
// 
// Path: src/main/java/io/pivio/view/app/overview/detail/ServiceIdShortName.java
// public class ServiceIdShortName {
// 
//     public Service service;
//     public String id;
//     public String short_name;
// 
//     public ServiceIdShortName() {
//     }
// 
//     public ServiceIdShortName(Service service, String id, String short_name) {
//         this.service = service;
//         this.id = id;
//         this.short_name = short_name;
//     }
// 
//     public boolean hasDependencies() {
//         return service != null && service.depends_on != null;
//     }
// 
//     @Override
//     public String toString() {
//         return "ServiceIdShortName{" +
//                 "service=" + service +
//                 ", id='" + id + '\'' +
//                 ", short_name='" + short_name + '\'' +
//                 '}';
//     }
// }
// 
// Path: src/main/java/io/pivio/view/app/overview/detail/serverresponse/Document.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Document {
// 
//     public String owner;
//     public String data_format_version;
//     public String description;
//     public String type;
//     public String vcsroot;
//     public String name;
//     public String short_name;
//     public String id;
//     public String contact;
//     public String created;
//     public String lastUpload;
//     public String lastUpdate;
//     public String status;
//     public String product_context;
//     public List<String> tags = new ArrayList<>();
//     public Map<String, String> links = new HashMap<>();
// 
//     public Runtime runtime = new Runtime();
//     public List<SoftwareDependency> software_dependencies = new ArrayList<>();
//     public Service service = new Service();
//     public Context context = new Context();
// 
//     @Override
//     public String toString() {
//         return "Document{" +
//                 "owner='" + owner + '\'' +
//                 ", data_format_version='" + data_format_version + '\'' +
//                 ", description='" + description + '\'' +
//                 ", type='" + type + '\'' +
//                 ", vcsroot='" + vcsroot + '\'' +
//                 ", name='" + name + '\'' +
//                 ", short_name='" + short_name + '\'' +
//                 ", id='" + id + '\'' +
//                 ", contact='" + contact + '\'' +
//                 ", created='" + created + '\'' +
//                 ", lastUpload='" + lastUpload + '\'' +
//                 ", lastUpdate='" + lastUpdate + '\'' +
//                 ", status='" + status + '\'' +
//                 ", product_context='" + product_context + '\'' +
//                 ", tags=" + tags +
//                 ", links=" + links +
//                 ", runtime=" + runtime +
//                 ", software_dependencies=" + software_dependencies +
//                 ", service=" + service +
//                 ", context=" + context +
//                 '}';
//     }
// 
//     public boolean ofTypeService() {
//         return type.equalsIgnoreCase("service");
//     }
// 
// }
// 
// Path: src/main/java/io/pivio/view/app/overview/list/serverresponse/Overview.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Overview implements Comparable {
// 
//     public String name;
//     public String short_name;
//     public String description;
//     public String lastUpload;
//     public String lastUpdate;
//     public Context context;
//     public String id;
//     public String owner;
//     public String type;
// 
//     @Override
//     public int compareTo(Object o) {
//         return this.name.compareTo(((Overview) o).name);
//     }
// }
// 
// Path: src/main/java/io/pivio/view/configuration/ServerConfig.java
// @Component
// public class ServerConfig {
//     public List pages = new ArrayList<>(); // show nothing for default
//     public String apiAddress = "http://localhost:9123"; // default
//     public String mainUrl = "http://localhost:8080"; // needs to be determined later to match the host with the 'main' app.
//     public String jsApiAddress = "http://localhost:9123/"; // If your webbrowser needs access to the API, the address is a different one.
// 
//     @Override
//     public String toString() {
//         return "ServerConfig{" +
//                 "pages=" + pages +
//                 ", apiAddress='" + apiAddress + '\'' +
//                 ", mainUrl='" + mainUrl + '\'' +
//                 ", jsApiAddress='" + jsApiAddress + '\'' +
//                 '}';
//     }
// }


// Path: src/main/java/io/pivio/view/PivioServerConnector.java
import io.pivio.view.app.feed.serverresponse.FeedItem;
import io.pivio.view.app.overview.detail.ServiceIdShortName;
import io.pivio.view.app.overview.detail.serverresponse.Document;
import io.pivio.view.app.overview.list.serverresponse.Overview;
import io.pivio.view.configuration.ServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import static java.util.Collections.sort;

package io.pivio.view;




@Component
public class PivioServerConnector {

    private final Logger log = LoggerFactory.getLogger(PivioServerConnector.class);

    @Autowired
    ServerConfig serverConfig;