# 🔍 Reverse Engineering Aumentum Web Access

## 🚨 **THE PROBLEM**

- **Aumentum Web Access:** Shows correct PL11089 images ✅
- **Our Python System:** Shows PL689 images instead ❌

This means:
1. Web Access has a working discovery mechanism
2. Our implementation is missing something
3. We need to reverse-engineer how Web Access does it

---

## 🎯 **WHAT WE NEED**

The **EXACT list of 46 UUIDs** that Web Access uses for PL11089 Type 103 (Property File).

With this, we can:
- Compare to what our system returns
- Identify why we're getting different files
- Fix our discovery algorithm

---

## 📁 **FILES CREATED**

### For You to Run:

1. **`QUICK_CAPTURE_ONELINER.txt`** ⭐ START HERE!
   - Simple one-line commands for browser console
   - Fastest way to get results
   - Takes < 1 minute

2. **`reverse_engineer_web_access.js`**
   - Full JavaScript to paste in browser console
   - Searches for the pages array
   - Extracts all UUIDs

3. **`capture_web_access_api.py`**
   - Python script to query Web Access API
   - Attempts to login and fetch document details
   - Extracts UUIDs from responses

4. **`REVERSE_ENGINEER_INSTRUCTIONS.md`**
   - Detailed step-by-step instructions
   - Multiple methods to choose from
   - Explains what we're looking for

---

## 🚀 **QUICK START (2 MINUTES)**

### Method: Browser Console (EASIEST)

1. **Open Web Access:**
   ```
   http://10.10.10.3:8080/lrswa
   Login: admin / admin
   ```

2. **Search for PL11089** and open Type 103 (Property File)

3. **Open Console:** Press `F12`, go to "Console" tab

4. **Run this ONE LINE:**
   ```javascript
   (function(){try{var t=Ext.ComponentMgr.all.items.filter(function(i){return i.pages})[0];if(t){console.log("Found",t.pages.length,"pages:");t.pages.forEach(function(p,i){console.log((i+1)+".",p.uuid)});}else{console.log("Pages not found. Try Option 2.");}}catch(e){console.log("Error:",e.message)}})();
   ```

5. **Copy all output** and send it back

**DONE!** This gives us the UUIDs Web Access uses.

---

## 🔍 **WHAT WE'RE INVESTIGATING**

### Current Understanding:

```
Database for PL11089:
├── Type 111 (History Card): 1 page expected, 2 URLs in DB
├── Type 103 (Property File): 46 pages expected, 2 URLs in DB  ← ISSUE HERE
└── Type 127 (Land Form 7): 2 pages expected, 2 URLs in DB

Our Algorithm:
1. Gets reference URL: store://2015/3/26/15/8/3eee6f3f-...bin (ID 823587)
2. Finds 46 sequential files starting from ID 823588
3. Returns: IDs 823588-823633

Problem:
- ID 823588 contains PL689 content (not PL11089!)
- But Web Access shows correct PL11089 content
- So Web Access must be using DIFFERENT UUIDs!
```

### Key Questions:

1. **Which UUIDs does Web Access actually use?**
2. **How does it discover them?**
3. **What's different from our sequential ID approach?**

---

## 📊 **COMPARISON TABLE**

Once we get Web Access's UUIDs, we can compare:

| Page | Web Access UUID | Our System UUID | Match? | Issue |
|------|----------------|-----------------|--------|-------|
| 1    | ?              | eac6561d-...    | ?      | ?     |
| 2    | ?              | 2b12fb85-...    | ?      | ?     |
| ...  | ?              | ...             | ?      | ?     |

This will show us:
- ✅ If we're using completely different files
- ✅ If there's an offset/skip issue
- ✅ If the ordering is different
- ✅ If we're in the wrong directory/date

---

## 🎯 **EXPECTED OUTCOMES**

### Scenario A: Different UUIDs
```
Web Access uses: 3eee6f3f, aaaa1111, bbbb2222, ...
Our system uses:  eac6561d, 2b12fb85, 8567710b, ...

→ We're selecting from wrong range/directory
→ Need to adjust discovery algorithm
```

### Scenario B: Same UUIDs, Wrong Order
```
Web Access uses: [UUID1, UUID2, UUID3, ...]
Our system uses:  [UUID3, UUID1, UUID2, ...]

→ Sorting issue
→ Need to fix ordering logic
```

### Scenario C: Subset Match
```
Web Access uses: [UUID1, UUID2, ... UUID46]
Our system uses:  [UUID10, UUID11, ... UUID55]

→ Offset issue
→ Starting from wrong position
```

---

## 💡 **POSSIBLE DISCOVERIES**

What we might find:

### Discovery 1: Transaction-Based Grouping
```json
{
  "transactionId": 10000000011253,
  "pages": [
    {"uuid": "...", "documentId": 10000000013791},
    {"uuid": "...", "documentId": 10000000013791},
    ...
  ]
}
```

### Discovery 2: Parent-Child Relationships
```json
{
  "parentNode": 823586,
  "children": [
    {"nodeId": 823587, "uuid": "..."},
    {"nodeId": 823588, "uuid": "..."},
    ...
  ]
}
```

### Discovery 3: Timestamp-Based Clustering
```json
{
  "uploadDate": "2015-03-26T14:23:23",
  "timeWindow": 30,
  "pages": [...]
}
```

### Discovery 4: Direct Database Query
```sql
-- Maybe Web Access uses a query like:
SELECT cu.content_url
FROM alf_content_url cu
WHERE cu.content_url LIKE 'store://2015/3/26/%'
AND cu.id IN (
  SELECT content_url_id 
  FROM alf_content_data cd
  WHERE cd.id IN (
    SELECT node_id 
    FROM alf_node_properties np
    WHERE np.long_value = 10000000013791  -- document_id
  )
)
ORDER BY cu.id
```

---

## 📝 **WHAT TO SEND BACK**

Please capture and send ANY of these:

1. **✅ Console output** from JavaScript one-liner
2. **✅ List of UUIDs** (text file)
3. **✅ Network tab screenshot** showing API calls
4. **✅ JSON response** from `/details/document.do`
5. **✅ HTML source** of the document details page

**ANY of these will help!**

---

## 🔧 **NEXT STEPS (After We Get UUIDs)**

1. Compare Web Access UUIDs with our system's UUIDs
2. Identify the pattern/algorithm Web Access uses
3. Check database for those specific UUIDs
4. Update our Python code to match
5. Test with PL11089
6. Verify correct images are shown
7. Test with other documents
8. **SUCCESS!** ✅

---

## 📞 **SUPPORT**

If you have issues:

1. Try the **QUICK_CAPTURE_ONELINER.txt** first (easiest)
2. If that doesn't work, try **Network tab** method
3. Send whatever output you can get
4. Even a screenshot helps!

**We just need to see which UUIDs Web Access uses for PL11089 Type 103!**

---

## 🎯 **TL;DR**

1. Open Web Access → PL11089 Type 103
2. Press F12 → Console
3. Paste one-liner from `QUICK_CAPTURE_ONELINER.txt`
4. Copy output
5. Send back

**That's it!** 🚀

This will tell us exactly which files Web Access uses, and we can fix our code to match!

