Skip to content

Instantly share code, notes, and snippets.

@hdsdi3g
Created August 13, 2016 00:47
Show Gist options
  • Save hdsdi3g/2992a69804f1c7f239744584c475a6e3 to your computer and use it in GitHub Desktop.
Save hdsdi3g/2992a69804f1c7f239744584c475a6e3 to your computer and use it in GitHub Desktop.
import java.io.IOException;
import java.net.URL;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import com.avid.interplay.ws.assets.AssetDescriptionType;
import com.avid.interplay.ws.assets.Assets;
import com.avid.interplay.ws.assets.AssetsFault;
import com.avid.interplay.ws.assets.AssetsPortType;
import com.avid.interplay.ws.assets.ErrorListType;
import com.avid.interplay.ws.assets.ErrorType;
import com.avid.interplay.ws.assets.GetChildrenResponseType;
import com.avid.interplay.ws.assets.GetChildrenType;
import com.avid.interplay.ws.assets.UserCredentialsType;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class Test {
public static void main(String[] args) throws AssetsFault, IOException {
UserCredentialsType credentialsHeader = new UserCredentialsType();
credentialsHeader.setUsername("<user>");
credentialsHeader.setPassword("<password>");
URL url = new URL("http://<ip/host name WS server>/services/Assets?wsdl");
QName qname = new QName("http://avid.com/interplay/ws/assets", "Assets");
/*Assets a = new Assets();
a.getServiceName()*/
Service service = Assets.create(url, qname);
AssetsPortType assets = service.getPort(AssetsPortType.class);
GetChildrenType ctype = new GetChildrenType();
ctype.setIncludeFiles(true);
ctype.setIncludeFolders(true);
ctype.setIncludeMOBs(true);
ctype.setInterplayURI("interplay://AvidWorkgroup/");
/*AttributeListType ltype = new AttributeListType();
AttributeType atype = new AttributeType();
ltype.getAttribute().add(atype);
ctype.setReturnAttributes(ltype);*/
GsonBuilder gb = new GsonBuilder();
gb.setPrettyPrinting();
Gson gson = gb.create();
GetChildrenResponseType resp = assets.getChildren(ctype, credentialsHeader);
checkError(resp.getErrors());
// System.out.println(gson.toJson(resp));
List<AssetDescriptionType> assets_dt = resp.getResults().getAssetDescription();
assets_dt.forEach(asset -> {
System.out.println(gson.toJson(asset));
});
}
public static void checkError(ErrorListType errors) throws IOException {
if (errors == null) {
return;
}
List<ErrorType> e_type = errors.getError();
if (e_type == null) {
return;
}
if (e_type.isEmpty()) {
return;
}
/*e_type.forEach(error -> {
error.getMessage()
});*/
throw new IOException(e_type.get(0).getMessage() + ". " + e_type.get(0).getDetails());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment