As Mass Metadata updating cannot be done with
Repository Manager and
Archiver can be arduous the following Java Class can be used instead. (Change the
red text to suit your circumstances)
public class MassUpdater {
private
static IdcClientManager manager = new IdcClientManager();
private
static IdcClient idcClient;
private
static IdcContext userContext;
public static boolean massUpdate() {
DataBinder binder = idcClient.createBinder();
binder.putLocal("IdcService", "GET_SEARCH_RESULTS");
binder.putLocal("QueryText",
"dSecurityGroup <matches> `Public`");
binder.putLocal("searchFormType", "standard");
binder.putLocal("SearchQueryFormat", "UNIVERSAL");
binder.putLocal("ftx", "");
binder.putLocal("AdvSearch", "True");
binder.putLocal("folderChildren", "");
binder.putLocal("ResultCount", "200");
binder.putLocal("SortField", "dInDate");
binder.putLocal("SortOrder", "Desc");
try {
ServiceResponse response =
idcClient.sendRequest(userContext, binder);
DataBinder serverBinder = response.getResponseAsBinder();
DataResultSet resultSet =
serverBinder.getResultSet("SearchResults"); // loop over the results
int z = 0;
for (DataObject dataObject : resultSet.getRows()) {
singleUpdate(dataObject.get("dDocName"),dataObject.get("dID"),dataObject.get("dRevLabel"),dataObject.get("dSecurityGroup"), "UCMMETADATAFIELD", "UCMMETADATAVALUE");
z++;
System.out.println(dataObject.get("dDocTitle")+"----"+z+"/"+resultSet.getRows().size());
}
return true;
} catch (Exception ex) {
System.out.println(ex);
}
return false;
}
public static boolean singleUpdate(String
dDocName, String dID,
String dRevLabel,
String dSecurityGroup, String field, String value) {
DataBinder binder = idcClient.createBinder();
binder.putLocal("IdcService", "UPDATE_DOCINFO");
binder.putLocal("dDocName", dDocName);
binder.putLocal("dID", dID);
binder.putLocal("dRevLabel", dRevLabel);
binder.putLocal("dSecurityGroup", dSecurityGroup);
binder.putLocal(field, value);
try {
ServiceResponse response =
idcClient.sendRequest(userContext, binder);
DataBinder serverBinder = response.getResponseAsBinder();
//System.out.println(serverBinder.getLocalData().get("dStatus"));
return true;
} catch (Exception ex) {
System.out.println(ex);
}
return false;
}
public static void init() {
try {
String ucmServer = "ucmServerURL";
MassUpdater.idcClient =
MassUpdater.manager.createClient("idc://" + ucmServer +
":4444");
MassUpdater.idcClient.getConfig().setSocketTimeout(30000);
// 30 seconds
MassUpdater.idcClient.getConfig().setConnectionSize(20);
userContext = new IdcContext("sysadmin");
} catch (Exception ex) {
System.out.println(ex);
}
}
}
You may want to extend this to take a Map
of Metadata/Value pairs if you want to achieve true re usability.
You should also Paginate your results depending on your MaxQueryRows / ResultCount