lib/daengine/teamsite_metadata_parser.rb in daengine-0.2.5 vs lib/daengine/teamsite_metadata_parser.rb in daengine-0.2.7
- old
+ new
@@ -13,11 +13,13 @@
"TeamSite/Metadata/enterprise_expiration_date"=> 'expires_at',
"TeamSite/Metadata/enterprise_guid" => 'guid',
"TeamSite/Metadata/shortSynopsis" => 'summary',
"TeamSite/Metadata/business_owner" => 'business_owner',
"TeamSite/Metadata/enterprise_product_id" => 'product_ids',
- "TeamSite/Metadata/enterprise_content_organization_id" => 'content_organization_ids'
+ "TeamSite/Metadata/enterprise_content_organization_id" => 'content_organization_ids',
+ "TeamSite/Metadata/enterprise_program_id" => 'program_ids',
+ "TeamSite/Metadata/omnitureSiteSection_codes" => 'omniture_codes'
}
@@path_tuples = {
"path" => 'path',
"TeamSite/Metadata/enterprise_last_content_update_date" => 'doc_changed_at',
"TeamSite/Metadata/enterprise_content_type_id" => 'content_type'
@@ -85,11 +87,11 @@
delete_count += 1
elsif (assets[key]['expires_at'].nil? || (assets[key]['expires_at'] < 1.minute.from_now))
DigitalAsset.where(guid: key).try :delete_all
delete_count += 1
else
- asset_docs = remove_manifest_file(assets[key]['documents_attributes'])
+ asset_docs = trim_package(assets[key]['documents_attributes'])
da = DigitalAsset.find_or_initialize_by(guid: key)
if (!asset_docs.empty?)
assets[key]['documents_attributes'] = asset_docs
creating = da.new?
da.documents = []
@@ -117,21 +119,26 @@
DigitalAsset.purge! # if the purge criteria is met, purge anything not updated
Daengine.log("TeamsiteMetadataParser: #{added_count} records added, #{update_count} updated, #{delete_count} removed", "info")
end
end
-
- def self.remove_manifest_file(asset_docs)
+ def self.trim_package(asset_docs)
docs = []
+ path = Daengine.config[:digital_assets_file_directory]
asset_docs.each do |doc|
- docs << doc unless doc['path'].match('\/manifest\/')
+ #exclude manifest_file
+ unless doc['path'].match('\/manifest\/')
+ file = File.join(path, doc['path'])
+ #exclude digital_asset_files that are not in *Teamsite Staging*
+ docs << doc if File::exist?(file)
+ end
end
docs
end
def self.time
start = Time.now
yield
self.log "elapsed time was #{Time.now - start}"
end
-end
+end
\ No newline at end of file