Top Banner
Using your Database as a File Server Drag, Drop and other Stuff
55

BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Jun 23, 2015

Download

Documents

Marco Gralike

alternative, rewritten version for the BGOUG conference
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Using your Database as a File Server

Drag, Drop and other Stuff

Page 2: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
Page 3: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
Page 4: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
Page 5: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

OverviewXML DB Repository

Page 6: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Anyone?

Ever executed DBMS_XDB…?

dbms_xdb.SetHTTPPort(8080)dbms_xdb.SetFTPPort(2100)

Page 7: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Oracle XML DB

Based on XML Standards:XPath V2 , XSLT V1 , XQuery V1 ,XQuery Update (11.2.0.3) , XBRL (Extention)

XML HandlingStores, Consumes, Generates, Validates

XDB Repository HTTP(s), FTP & WebDAVXDB Repository Events

No Cost Option, Core database feature

Page 8: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XDB Repository - Features

XDB Repository File / Folder (aka Resources)

Resource manipulationDBMS_XDB, DBMS_XDBRESOURCE

Default XDB ACL Driven Security XDB Protocol Listener Respository Events Versioning XML Schema awareness Extending XML Schema functionality

Page 9: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XDB Repository - Resources XDB$RESOURCE

XDBResource.xsd XMLType Table (Schema based XML Table)

Access to XDB Repository WebDAV, FTP, HTTP(s) SQL, PL/SQL, NDWS PATH_VIEW, RESOURCE_VIEW

Select, Update, Delete UNDER_PATH, EQUALS_PATH

Page 10: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

xdbconfig.xml

Security ?

XMLSchema ?

Servlet ?

MIME Type?

XDB Event ?

Extention?

Event Listener Event Handler File / Folder ?

Page 11: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Batch File ProcessingUse Case

Page 12: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Copy a FILEto the

Database

Database FileServer 2 The MAX

Page 13: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XML Protocol Server

(Listener)

Event ListenerMIME

Check

Event Handle

r

Page 14: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Store in XDB Repository

MoveExtract

File Info

Page 15: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Batch File to XDB “Batch”

Directory

Extract File

Content

XDB File to Server

Page 16: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Picture Metadata Extraction

Use Case

Page 17: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Copy a PICTURE to the Database

Database FileServer 2 The MAX

Page 18: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XML Protocol Server

(Listener)

Event ListenerMIME

Check

Event Handle

r

Page 19: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Store in XDB Repository

Store in

Table

ExtractXML

Page 20: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Display in GUI, Google Map

EXIF KML

Page 21: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XDB Protocol ServerMethods at Work

Page 22: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

xdbconfig.xml

Security ?

XMLSchema ?

Servlet ?

MIME Type?

XDB Event ?

Extention?

Event Listener Event Handler File / Folder ?

Page 23: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

xdbconfig.xml

XML Schema - xdbconfig.xsd Notepad, XMLSpy, PL/SQL Secured via WebDAV ACL (xdbadmin) Packages (among others):

DBMS_XDB▪ Caching, Session, Locking, Security behavior▪ Enable HTTP/FTP, MIME, Encoding, Virtual Paths▪ SERVLETS: NDWS, APEX, XDBUrifactory

DBMS_EPG ▪ Creation off Database Access Descriptors

Page 24: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

<xdbconfig> <sysconfig> <acl-max-age>15</acl-max-age> <acl-cache-size>32</acl-cache-size> <invalid-pathname-chars/> <case-sensitive>true</case-sensitive> <call-timeout>6000</call-timeout> <max-link-queue>65536</max-link-queue> <max-session-use>100</max-session-use> <persistent-sessions>false</persistent-sessions> <default-lock-timeout>3600</default-lock-timeout> <xdbcore-log-level>0</xdbcore-log-level> <resource-view-cache-size>1048576</resource…size> <xdbcore-xobmem-bound>1024</xdbcore-xobmem-bound> <xdbcore-loadableunit-size>16</xdbcore-……………size> <acl-evaluation-method>ace-order</acl-ev……method> </sysconfig></xdbconfig>

Page 25: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

<servlet xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"> <servlet-name>APEX</servlet-name> <servlet-language>PL/SQL</servlet-language> <display-name>APEX</display-name> <plsql xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"> <database-username>ANONYMOUS</database-username> <default-page>apex</default-page> <document-table-name>wwv_flow_file_objects$</document-…-

name> <document-path>docs</document-path> <document-procedure>

wwv_flow_file_mgr.process_download </document-procedure>

<nls-language>american_america.al32utf8</nls-language> <request-validation-function>

wwv_flow_epg_include_modules.authorize </request-validation-function>

</plsql> <security-role-ref

xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"> <role-name>anonymousServletRole</role-name> <role-link>anonymousServletRole</role-link> </security-role-ref></servlet>

Page 26: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XDB Repository EventsMethods at Work

Page 27: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XDB Repository Event - Ingredients

Event Listener Java Class, PL/SQL Package, Object Type▪ E.g. a package called:

“HANDLE_XDB_EVENTS” Event Handlers

Event handlers processes a single event▪ Package procedures called

“handlePreCreate”, “handlePostCreate, “handlePreVersionControl”…

Resource Configuration File The glue between Event Listener and

Resources

Page 28: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Repository Event Types

Render Create Delete Update LinkIn

UnLinkInUnLinkFromLockCheckInCheckOut

PRE-…………

POST-………

PreCreate

PostCreate

UnCheckOutVersionControlUnLockLinkTo

Page 29: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Events & Event Handlers

Create

Delete

Render Lock

URL: XDBEvent

handlePreCreatehandlePostCreatehandlePreDeletehandlePostDeletehandleRenderhandlePreLockhandlePostLock

XDBEventListener

Page 30: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
Page 31: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XDB ResourcesMethods at Work

Page 32: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

xdbconfig.xml

Security ?

XMLSchema ?

Servlet ?

MIME Type?

XDB Event ?

Extention?

Event Listener Event Handler File / Folder ?

Page 33: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Resource Configuration File Glue between Event Listener and

Resource An XML File

XML Schema restricted: XDBResConfig.xsd Contains (among others):

Events and Source (Event Listener) Path to “itself” (/public/myResFile.xml) Pre-conditions (XPATH on XDB$RESOURCE)

Is assigned to a Resource (File/Folder) DBMS_RESCONFIG.AppendResConfig

Page 34: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

TABLE: XDB.XDB$RESOURCE

XML Schema: xdb$resource.xsd XMLType Table PATH_VIEW, RESOURCE_VIEW LOB Column (with file content) Non Schema based metadata in LOB Info about:

RESID, DisplayName, Owner, Creator, VersionID, ChecktOut, CreationDate, ModifiedDate, SizeOnDisk, ContentSize, ContentType, Comments, CharacterSet, Etc…

Page 35: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Ideas for <pre-conditions>

<pre-condition> <existsNode> <XPath>/Resource[ContentType="image/jpg"]</XPath> </existsNode></pre-condition>

<pre-condition> <existsNode> <XPath>/Resource[Creator="BATCH"]</XPath> </existsNode></pre-condition>

Move all files created by BATCH to…Extract Info from picture if extension

GIF…

Page 36: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Imagination at WorkHolistic Approach

Page 37: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

xdbconfig.xml

Security ?

XMLSchema ?

Servlet ?

MIME Type?

XDB Event ?

Extension?

Event Listener Event Handler File / Folder ?

Page 38: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Oracle XML Handling (v.9.2)

XML Document XML Schema in XML ?

XML SchemaRegistered ?

Physical XMLType Associated ?

Shred XML intoXMLType

Update XDB$Resource

Page 39: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Everybody knows EXIF…

Page 40: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

EXIF Information in JPEG/JPG

Jeffrey's EXIF Viewer

Page 41: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Continued…

Page 42: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

EXIF Data via Google Map

Page 43: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

EXIF Metadata

Camera Make and Model Aperture, Shutter Speed, Focal

Length ISO Speed, Date Taken, Description Geo-coding, Copyright Information

EXIF XML Schema is pre-registered with XML DB by Oracle MultiMedia

Type ordsys.ordimage extracts EXIF metadata document from a JPG image

Page 44: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Oracle MultiMedia

The following embedded image metadata formats are supported by Oracle Multimedia:

EXIF (JPEG/TIFF - JEIDA) IPTC-IIM (JPEG/TIFF – Adobe) XMP (GIF/JPEG/TIFF – Adobe/RDF)

http://www.adobe.comhttp://www.w3.org/RDF Wikipedia - EXIF

Page 45: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

User Defined XDB Metadata ENABLE_HIERARCHY_RESMETADATA

Page 46: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XML Schema based Metadata

Metadata defined using an XML Schema

Metadata stored in a separate table Table includes hidden column RESID

Enables join with RESOURCE_VIEW, PATH_VIEW

Applications query and update metadata directly Improved Indexing

Metadata deleted when resource is deleted

Page 47: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Oracle XDB Event - Example

Document Event Listener?MIME type JPG

EXIF XML Schema?Event Handler? EXIF Extended

w/ USER XSD ?

Extract JPG File info

XDB$Resource

Extract JPG EXIF info

XMLType Table

Extract JPG USER metadataXMLType Table

Page 48: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

XACE.SOURCEFORGE.NET

Page 49: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Recap…Its about Time to wrap it Up

Page 50: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

xdbconfig.xml

Security ?

XMLSchema ?

Servlet ?

MIME Type?

XDB Event ?

Extention?

Event Listener Event Handler File / Folder ?

Page 51: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

GENERAL FILE STUFF

1. EVENT LISTENER • Package

2. EVENT HANDLERS • Procedures in “Event Listener”

3. RESOURCE CONFIGURATION FILE • XML File

Page 52: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

GENERAL (XML) FILE STUFF

• General File Stuff turns out to be XML then…

4. XML SCHEMA REGISTRATION• dbms_xmlschema.register_schema

5. EXTRA USER DEFINED METADATA NEEDED• dbms_xmlschema.enable_hierarchy_resm

etadata

Page 53: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Conclusions

• XML DB - Beyond the Database, Fileserver Realm

• Imagination is your limit, e.g.:- Extending “file” server with Text Search- Extending “file” server with ETL functionality

• Extra options: database / fileserver interfacing• Based on standards• No cost option / all database versions

Page 54: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

Oracle XML DB Sample Code

URL: OTN XMLDB Sample Code

XFILES Version 5 Introduction to Oracle XML DB

Repository Events Oracle XML DB-based Mashup with

Google Earth Oracle XML DB Repository Features XDB Utilities and more…

Page 55: BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server

www.xmldb.nl

Blog posts about:

Setting up logging in the XDB Repository Package template HANDLE_XDB_EVENTS Concepts & Howto’s for XDB Repository Automatically shred content out of

Windows Office (docx) into table columns

References to XLSX examples of Marc Bleron and Anton Scheffers