Now for the hard part, write the script. The following bit of code will iterate over all assets in a catalog, if you only want certain items in a catalog you can modify the searcher to fit your needs.
import org.openedit.data.Searcher;
import com.openedit.hittracker.SearchQuery;
import com.openedit.hittracker.HitTracker;
public void init()
{
catalogid = context.getPageValue("catalogid");
log.info("Auto rotating assets in " + catalogid);
mediaArchive = context.getPageValue("mediaarchive");
int count = 0;
//load xml file that contains what libraries have special permissions
searcherManager = mediaArchive.getSearcherManager();
//search for all of the assets in the catalog
Searcher targetsearcher = mediaarchive.getAssetSearcher();
SearchQuery q = targetsearcher.createSearchQuery();
q.addMatches("category", "index");
HitTracker hits = targetsearcher.search(q);
//loop through every asset in the catalog
for (Iterator iterator = hits.iterator(); iterator.hasNext();)
{
hit = iterator.next();
}
}
init();
In this case I only want the assets that contain 'portrait' in the title so I change:
q.addMatches("category", "index");
to:
q.addMatches("assettitle", "portrait");
Next in the for loop we need to load the asset object and set it's rotation. Which is accomplished with the following code:
//load the asset
asset = mediaArchive.getAssetBySourcePath(hit.get("sourcepath"));
//set the rotation 8 is the value for 90 degrees see
asset.set("imageorientation", "8");