I am trying calling readMetadata() method in java to return all instances of a metadata type in my sandbox: For example calling readMetadata("ApexClass") will return the api names of all apex classes in my org. As you can see, I am attempting to use the "*" wildcard here but that doesn't seem to work.
PS: This method works if I call metadataConnection.readMetadata("CustomObject",new String[] { "Account" });
I want to make it generic enough to be able to just provide the metadata type and get all instances of it.
public static void readData(String metadataType) {
try {
ReadResult readResult = metadataConnection.readMetadata(metadataType,new String[] { "*" });
Metadata[] mdInfo = readResult.getRecords();
for (Metadata md : mdInfo) {
if (md != null) {
//parse results into a list
} else {
System.out.println("Empty metadata.");
}
}
} catch (ConnectionException ce) {
ce.printStackTrace();
}
}