Commit graph

31 commits

Author SHA1 Message Date
DJP
333f62c9e6 Extract Final Assets folder ID when getting master assets
When user clicks 'Get Master Assets', now also:
- Finds Final Assets folder in campaign
- Stores folder ID in session
- Shows in success message

This folder ID is passed to Box upload → stored in database upload_directory column.

Later used for A2→A3 upload workflow to know where to upload files back to DAM.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 17:06:48 -04:00
DJP
cc92a088a8 Pass Final Assets folder ID through Box upload workflow to database
Workflow now:
1. Get Master Assets → Also finds Final Assets folder
2. Download & Upload to Box → Passes upload folder ID
3. Database stores upload_directory = Final Assets folder ID

This ensures each asset record has the DAM upload target folder stored for later use in A2→A3 workflow.

UI shows upload folder ID in success message.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 17:06:21 -04:00
DJP
6dac3f8d6b Enhance Box upload results UI - show DB status and tracking ID source
Box upload results now display:
- Tracking ID with green highlight
- Clickable Box link with icon
- Database storage status ( Stored or  Failed)
- ID source (database_direct, random, etc.)

Makes it clear when database integration is working.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 15:39:55 -04:00
DJP
d8e542a569 Add PostgreSQL database integration and Box metadata template
Database Integration:
- IDGenerator now connects to PostgreSQL (localhost:5433)
- Generates tracking IDs with uniqueness check against master_assets table
- Fallback to random if database unavailable
- Direct PDO connection to ferrero_tracking database

DatabaseClient:
- Stores master assets in PostgreSQL
- Records: tracking_id, opentext_id, Box links, full metadata JSON
- Updates on conflict (upsert pattern)
- Stores box_file_id and box_url for reference

Box Metadata Enhancement:
- Uses Box metadata template API (enterprise/ferreroDAMMetadata)
- Stores full DAM metadata JSON in 'Ferrero-DAM-Metadata' field
- Fallback to file description if template not configured
- Handles template conflicts (updates existing)

Box Upload Results Now Show:
- Unique tracking ID (from database)
- Box file links (clickable)
- Database storage status
- ID source (database_direct, random, etc.)

Complete workflow: DAM → Download → Generate ID → Upload to Box → Store in DB

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 15:39:32 -04:00
DJP
0c799aebe7 Implement proper Box JWT authentication with RSA signing
Box now uses JWT (JSON Web Token) authentication:
- Signs JWT with RSA private key from config
- Uses RS256 algorithm
- Enterprise-level access
- No expiring developer tokens

JWT Flow:
1. Create JWT header with publicKeyID
2. Create claims with enterprise ID
3. Sign with encrypted private key + passphrase
4. Exchange JWT for access token
5. Token auto-refreshes as needed

Config loaded from: Box-config.json (complete JWT config)

This is the proper production-ready authentication method.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 14:07:52 -04:00
DJP
fd3676e8d0 Use Box developer token for now - OAuth app not configured
Box OAuth requires app to be configured for client credentials grant.
Using developer token as fallback (valid 60 minutes).

User needs to:
1. Go to https://app.box.com/developers/console
2. Generate new Developer Token
3. Update token in code (expires hourly)

OR configure Box app for OAuth 2.0 client credentials grant.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 13:51:57 -04:00
DJP
c4ccbae765 Fix Box to use OAuth 2.0 client credentials instead of developer token
Box now uses proper OAuth flow:
- Client ID: l2atwxxq4xna7phcjr2uifm4mbah69qp
- Client Secret: 6XcuCQ6akpk9daE0UHaGSv3mSxWaER4l
- Enterprise ID: 43984435
- Grant type: client_credentials with box_subject_type

Loads credentials from Box-config.json for security.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 13:30:28 -04:00
DJP
61d7835ee8 Add Box connection test and debug logging
Added:
- Box connection test before upload
- Debug logging for troubleshooting
- Better error messages
- Fixed downloadDetails reference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 13:21:45 -04:00
DJP
36d45ae188 Add Box.com integration for asset storage with unique ID tracking
New Box Integration Features:
- BoxClient class for Box API operations
- IDGenerator for 6-character unique IDs (A-Z a-z 0-9)
- Auto-create campaign folders in Box
- Rename files with unique ID suffix (filename_ID.ext)
- Upload metadata JSON to Box custom fields
- Track Box file IDs and URLs

Download Workflow Enhancement:
- New button: '📥📦 Download & Upload to Box'
- Downloads from DAM → Uploads to Box
- Each file gets unique 6-char ID
- Creates campaign folder: {campaign_id}_{campaign_name}
- Results show: original → renamed filename with ID

Box Configuration:
- Developer Token: e7Q1kS6rOM1tH2ezzCg4KgRfcyNW2JHI
- Root Folder: 348304357505
- OAuth creds in Box-config.json

ID Generation:
- Phase 1: Random 6-char (current)
- Phase 2: PostgreSQL DB via REST API (ready to integrate)

Metadata Storage:
- Stored in Box file description (custom metadata field later)
- Full DAM metadata JSON preserved
- Includes: asset_id, campaign info, all metadata fields

Ready for testing! Download workflow now stores assets in Box with tracking.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 13:11:49 -04:00
DJP
a1e6dc6ab0 🎉 BREAKTHROUGH: Upload working! Use AssetUploaderSimple everywhere
TEST UPLOAD SUCCESSFUL! Asset ID: 214659

The simplified uploader works! Now using it for:
- Test uploads 
- Regular workflow uploads 

Key success factors:
- Only 5 metadata fields (not 17)
- Proper filename handling (not temp php names)
- Exact standalone script structure
- Cookie jar for JSESSIONID

Regular upload workflow now ready for testing!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 09:17:52 -04:00
DJP
45b4067150 Create simplified uploader matching exact standalone script
AssetUploaderSimple - exact copy of standalone logic:
- Only 5 metadata fields (not 17)
- Same field order and structure
- Same cURL options
- Produces ~1200 byte payload like standalone

Test upload now uses AssetUploaderSimple for exact match.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 09:12:51 -04:00
DJP
cbdf3f60a7 Simplify standalone test - accept token as argument + show token in UI
Standalone test now accepts token as command line argument instead of
trying to get new token (credentials may have changed).

UI now shows OAuth token in expandable section for copying to standalone test.

Usage: php test_upload_standalone.php "eyJraWQiOiI0Y..."

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 08:39:25 -04:00
DJP
26500422ee Fix test upload to use full metadata structure
Test upload was passing null for master asset, causing it to use
minimal structure instead of the full Postman metadata.

Now passes dummy master asset to trigger buildAssetRepresentationFromMasterAsset()
which contains all 17 required metadata fields.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 08:33:17 -04:00
DJP
c4eec014a4 Add test upload feature for direct folder testing
New test upload panel in Upload workflow:
- Upload directly to any folder ID (bypasses campaign selection)
- Pre-filled with test folder: e96080ba0cd1427d253a28a87504b6665eaa02cb
- Folder ID can be edited for testing different folders
- Shows success/failure with full error details
- Uses same upload mechanism as regular workflow

Use case:
- Test if specific folders allow uploads
- Bypass campaign workflow for testing
- Verify folder permissions
- Isolate upload issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 13:12:25 -04:00
DJP
1058525c3f Add metadata JSON download for master assets
New feature in Download workflow (A1→A2):
- Added '💾 JSON' button next to each master asset
- Downloads complete asset metadata as JSON file
- Filename format: {assetname}_metadata.json
- Pretty-printed JSON for readability

Use case:
- Inspect full metadata structure
- Reference for upload field requirements
- Debug metadata field values
- Documentation of master asset data

Buttons per asset:
- 📥 Download (file)
- 💾 JSON (metadata)
- 📋 View (toggle metadata display)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 11:39:36 -04:00
DJP
289d34bf2b Re-enable master asset fetching + Upload troubleshooting document
Master Asset Fetching:
- Re-enabled with better error handling
- Stores only lightweight data: asset_id, name, mime_type, model_id, security_policies
- Avoids storing massive metadata structure that causes crashes
- Graceful error handling if fetch fails

Upload Troubleshooting Document (UPLOAD_TROUBLESHOOTING.md):
- Comprehensive summary of upload blocking issue
- Details of all 5 upload approaches tested
- Technical specifications of API requests
- Error messages and HTTP codes
- Questions for Ferrero DAM support team
- Comparison of working downloads vs blocked uploads
- Recommended next steps

Ready for client to share with Ferrero support team to resolve API upload permissions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 11:24:39 -04:00
DJP
0ebdf5c755 Disable master assets fetching in upload - causes PHP crashes
Upload workflow issues:
- Master asset metadata structures too large for PHP to process
- Causes session storage crashes and HTTP 500 errors
- Temporarily disabled master assets fetching
- Upload folder finding still works

Current upload status:
- ALL file extensions (.tif, .jpg, .png) rejected by API
- Error: "Cannot import asset having restricted file extension"
- Tested with minimal payloads (just manifest + folder + file)
- Suggests server-level restrictions or account permissions issue

Awaiting client confirmation on:
- API upload permissions for user account
- Allowed file extensions for API uploads
- Alternative upload methods if API is restricted

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 11:17:26 -04:00
DJP
3a41a4f964 Add debug and reset features to Rework workflow (A5→A6)
Rework Workflow Enhancements:
- Add "Debug: Load ALL Campaigns" button to Rework tab
- Display all campaigns with their Content Scaling Status
- Add "Reset to A5" button for each campaign in debug view
- Show OAuth status and API response details
- Expandable campaign cards with full metadata view
- Session clearing when resetting campaigns

Upload Debug Improvements:
- Show uploaded filename and detected MIME type
- Display master asset being used for metadata
- Better visual separation of upload file vs master asset info

Mirrors Download workflow debug functionality for consistency across all workflow tabs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 10:09:55 -04:00
DJP
4f5ac8bfe7 Add standalone Upload workflow with master asset metadata selection
Upload Workflow Improvements:
- Fetch master assets metadata when finding upload folder (standalone workflow)
- Add UI selector to choose which master asset's metadata to copy
- Show master asset details: name, type, metadata model, security policies
- Add comprehensive upload debug output showing file/metadata info
- Add "Reset to A1" button in Upload tab for testing
- Default to first master asset if none selected

Upload Implementation Progress:
- Tried multiple approaches to bypass file extension restrictions
- Current status: All file extensions blocked by API (jpg, tif, png)
- Minimal upload attempt: manifest + security_policy + parent_folder
- Issue: "Cannot import asset having restricted file extension" for all types
- Suggests API upload restrictions or account-level permissions needed

Technical Details:
- Upload endpoint: /v6/assets (POST with multipart/form-data)
- Required fields: manifest, parent_folder_id, files, asset_representation
- Security policy ID: 1594 (from V3 collection)
- File extension restrictions appear to be server/account level

Next Steps:
- Verify API upload permissions with client
- Check allowed file extensions for API uploads
- May need different upload approach or web interface integration

Working Features:
-  Download workflow (A1 → A2) fully functional
-  Status updates working with proper locking
-  Master asset metadata fetching and selection
- 🔄 Upload blocked by file extension restrictions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 09:50:43 -04:00
DJP
156f9ae51d Fix status updates and enhance workflow with proper error handling
Major improvements to workflow_v3.php and supporting classes:

**Status Updates (A1→A2, A2→A3, A5→A6):**
- Fix StatusManager to use correct PATCH endpoint: /v6/folders/{id}
- Add lock_strategy=optimistic parameter to prevent locking errors
- Update request body structure to use edited_folder format
- Status updates now working correctly

**Status Field Extraction:**
- Fix CampaignFormatter to extract CONTENT.SCALING.STATUS field
- Handle domain values with field_value.value path
- Now correctly filters campaigns by status (A1, A2, A5, etc.)

**Error Handling:**
- Extract and display actual API error messages
- Show HTTP status codes in all error messages
- Add expandable debug panels with full API responses
- Enhanced upload error reporting with detailed diagnostics

**Campaign Search:**
- Update to use Postman collection requests directly (avoids 503 errors)
- Fix URL encoding (rawurlencode instead of urlencode)
- Add comprehensive debug output showing OAuth status and API responses
- Search now attempts Postman request first, falls back to manual query

**Upload Improvements:**
- Rewrite AssetUploader to use native PHP CURLFile for multipart uploads
- Add support for additional file types: .mov, .mp4, .avi, .zip, .txt, .doc, .xlsx
- Increase max upload size to 100MB for video files
- Simplify asset_representation to minimal structure
- Add infrastructure to inherit metadata from master assets

**Testing Features:**
- Add "Reset to A1" button for testing workflow iterations
- Add debug mode to view all campaigns and their metadata
- Show Content Scaling Status on all campaign cards
- Display filtering debug info (total vs filtered counts)

**UI Improvements:**
- Rename buttons to clarify "Content Scaling Status" terminology
- Add status badges to campaign cards showing current status
- Better visual feedback for successful/failed operations

Current Status: Workflow A1→A2 fully working. Upload A2→A3 ready for testing
once DAM server recovers from HTTP 503 errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 16:43:09 -04:00
DJP
cf71bcfd96 Complete workflow V3: Add Upload (A2→A3) and Rework (A5→A6) workflows
NEW: Upload Workflow (A2→A3)
- Load campaigns with status A2 (assets sent to agency)
- Select campaign and find upload target folder (Final Assets)
- Multi-file upload with drag-drop interface
- AssetUploader class with multipart/form-data support
- Upload files with metadata to DAM
- Update status to A3 after upload

NEW: Rework Workflow (A5→A6)
- Load campaigns with status A5 (rework needed from agency)
- Select campaign and get rework assets
- Download individual or bulk rework assets
- Beautiful metadata display
- Update status to A6 when rework assets received

Features:
- Three complete workflow tabs (Download, Upload, Rework)
- Status transitions: A1→A2, A2→A3, A5→A6
- Session-based workflow state management
- Clear workflow data button for each tab
- Campaign selection with visual feedback
- Download confirmed working (tested with real asset)
- OAuth2 auto-refresh throughout all workflows

Technical:
- AssetUploader class for multipart file uploads
- Proper metadata JSON structure for uploads
- Support for multiple file formats (JPG, PNG, PDF, AI, PSD, etc.)
- Error handling for each workflow step
- Beautiful UI with color-coded status badges

Ready for testing with real campaign data!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 16:43:26 -04:00
DJP
8cfa971078 Add debug for asset_content_info structure and try all renditions 2025-10-17 15:52:44 -04:00
DJP
9bf6813575 Add fallback to preview/thumbnail renditions if original file missing 2025-10-17 15:50:59 -04:00
DJP
7bd8c30803 Fix rendition URL path - remove duplicate /otmmapi/ prefix 2025-10-17 15:49:15 -04:00
DJP
e0ec556c5e Use cached asset data from folder listing for download (has rendition URLs) 2025-10-17 15:47:36 -04:00
DJP
02c2f0343c Fix: Use load_type=full to get rendition URLs in asset_content_info 2025-10-17 15:44:59 -04:00
DJP
6ea945aabc Fix rendition URL extraction from asset_content_info 2025-10-17 15:38:51 -04:00
DJP
1f88226426 Fix download using renditions + beautiful metadata display
MAJOR FIX: Download now works!
- Extract rendition URL from asset metadata (content.url)
- Download via /v6/renditions/{id} instead of /v6/assets/{id}/contents
- Fallback to direct download if no rendition found
- Files now download successfully!

Beautiful Metadata Display:
- Color-coded sections with icons
- Basic Info (blue) - asset details
- Content Info (green) - file size, dimensions, URLs
- Custom Fields (yellow) - collapsible by category
- Permissions (red) - visual checkmarks
- Renditions (teal) - all available versions

Download Improvements:
- First fetch asset metadata to find correct download URL
- Try rendition URL from metadata
- Show download method and URL used
- Better error messages with tried URL

Metadata Features:
- Grid layout for easy reading
- Collapsible sections to reduce clutter
- Human-readable field names
- Array values displayed as comma-separated
- Shows rendition sizes and dimensions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 15:34:21 -04:00
DJP
a165bd347c Fix asset name extraction and add workflow cache clearing
Fixes:
- Extract folder/asset names from INER_NAME_GENERIC field (correct field ID)
- Add fallback to 'name' field if metadata field not found
- Fix debug_assets.php to maintain campaign_id in URL parameters
- Add "Clear Workflow Data" button to reset cached session data
- Improve error messages when files don't exist in storage
- Allow status update even if downloads fail (test environment)

Changes:
- Update extractFolderName() to check INER_NAME_GENERIC first
- Fix debug_assets.php folder and asset name extraction
- Add clear_results action to workflow_v3.php
- Show folder names correctly in debug interface
- Display clear message about test environment file availability

Working:
 OAuth2 authentication
 Campaign search by status
 Folder navigation
 Asset listing with correct IDs
 Metadata extraction
⚠️  Download fails - files don't exist in test environment storage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 15:30:32 -04:00
DJP
633c5a525e Fix workflow V3: metadata display and download error handling
Fixes:
- Metadata button now works (fixed JavaScript and element IDs)
- Display full metadata as JSON when clicked
- Detect and show proper error when files don't exist in storage
- Show detailed download error messages (HTTP 500, file not found)
- Display download success/failure with file size and path
- Use old working Postman collection with OAuth2 configured
- Update StatusManager to use working search pattern + status filter

Changes:
- Switch to Content Scaling Flow.postman_collection_Oliver(New).json
- Fix downloadAsset to detect JSON error responses
- Improve metadata display with toggle functionality
- Show clear error messages for missing files in DAM storage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 15:13:01 -04:00
DJP
a179be5da8 Add Workflow V3 with status-based campaign management
New Features:
- ConfigV3 class with test/production environment switching
- StatusManager for campaign status updates (A1→A2→A3, A5→A6)
- workflow_v3.php with tabbed interface for different workflows
- Auto-refreshing OAuth2 token (60-second buffer before expiry)
- Download workflow: Load A1 campaigns → Download master assets → Update to A2
- Metadata display for all assets
- Configurable base URLs for certificate auth and IP filtering

Status Workflow:
- A1: Ready for localization → Download assets → A2
- A2: Assets sent to agency → Upload processed → A3 (coming soon)
- A5: Rework needed → Download rework assets → A6 (coming soon)

Technical:
- Uses Content Scaling Flow V3.postman_collection.json
- Supports multiple environments (test/production)
- Session-based workflow state management
- Master Assets folder always "01. Master Assets"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 15:00:21 -04:00