Ex ensión de na egado pa a la eliminación de me ada os
A b owse plug-in o me ada a emo al
T abajo de Fin de G ado
Cu so 2019–2020
Au o
Diego Ambi e Va ona
Guille mo Ga cía Mansilla
Rosa Oli ia Zumae a Sánchez
Di ec o
En ique Ma ín Ma ín
G ado en Ingenie ía In o má ica
Facul ad de In o má ica
Uni e sidad Complu ense de Mad id
Ex ensión de na egado pa a la
eliminación de me ada os
A b owse plug-in o me ada a emo al
T abajo de Fin de G ado en Ingenie ía In o má ica
Au o
Diego Ambi e Va ona
Guille mo Ga cía Mansilla
Rosa Oli ia Zumae a Sánchez
Di ec o
En ique Ma ín Ma ín
Con oca o ia: Junio 2020
G ado en Ingenie ía In o má ica
Facul ad de In o má ica
Uni e sidad Complu ense de Mad id
26 de JUNIO de 2020
Los me ada os, da os sob e los a chi os que gene amos digi almen e, dicen m´as sob e noso os
de lo que c eemos, pudiendo llega a ocasiona un g a e iesgo pa a nues a p i acidad e incluso
pa a la segu idad de nues os equipos. Nues o p oyec o ha consis ido en la elabo aci´on de una
aplicaci´on web en o ma de ex ensi´on de na egado ´acilmen e manejable po el usua io y que
equie e muy poca in e acci´on con ella, o eciendo la posibilidad de limpia los me ada os
p esen es en los a chi os, conc e amen e en im´agenes, que se an a subi a la pla a o ma
Google D i e.
Pa a la consecuci´on de es a me a, hemos o ganizado el p oyec o siguiendo una a qui ec u a
basada en mic ose icios o eciendo un ´acil acoplamien o a nue os o ma os cuyos me ada os se
quie an a a . Pa a el desa ollo de es os mic ose icios y de la ex ensi´on, hemos usado ecnolog
´ıas ampliamen e usadas hoy en d´ıa como pueden se Ja aSc ip , Sp ing Boo .
Palab as cla e: Me ada os, Ex ensi´on de na egado , Mic ose icios, P i aci-dad, Google
D i e, pe iciones HTTP, webReques , API REST
Resumen
The me ada a, which is da a abou he documen s we gene a e digi ally, ell mo e abou ou sel es
ha wha we could hink, po en ially being a h ea o ou p i acy and e en o he secu i y o ou
sys ems. Ou p ojec has been he de elopmen o a web applica ion which wo ks as a b owse
ex ension which is easy o handle by he use and which equi es e y li le in e ac ion wi h i ,
o e ing he possibili y o elimina e he me ada a p esen in he documen s, speci ically in images,
ha a e going o be uploaded o Google D i e.
Fo he achie emen o his goal, we decided o o ganize he p ojec ollowing an a chi ec u e
based on mic ose ices, o e ing an easy way o in oduce new o ma s o he sys em o he
p ocessing o he me ada a. Fo he de elopmen o hese Mic ose ices and he ex ension, we used
echnologies widely used oday, such as Ja aSc ip , Sp ing Boo .
keywo ds: Me ada os, B owse Ex ension, Mic ose ices, P i acy, Google D i e, HTTP
Reques s, webReques , API REST
Abs ac
Con en s
1. In oduc ion 1
1.1. Objec i e ..................................... 2
1.2. Thewo kplan .................................. 2
2. P elimina ies 5
2.1. Wha isMe ada a ................................ 5
2.2. Why is Me ada a so Impo an . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3. Wha a e Mic ose ices? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4. Bene i s o Mic ose ices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5. B owse ex ensions and Ja aSc ip . . . . . . . . . . . . . . . . . . . . . . . 9
2.6. Sp ingBoo .................................... 11
2.7. Tools o me ada a managemen . . . . . . . . . . . . . . . . . . . . . . . . 11
3. Sys em O ganiza ion 13
3.1. Ex ension ..................................... 14
3.2. O ches a o .................................... 15
3.3. Cleaning mic ose ices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4. Ex ension 17
4.1. Collec ing eques s ................................ 17
4.2. P ocessing he eques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.3. Da a exchange o mic ose ices . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3.1. O ches a o ............................... 20
4.3.2. Cleaning mic ose ices . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.4. Filecleaned.................................... 22
4.5. Limi a ions ound du ing de elopmen . . . . . . . . . . . . . . . . . . . . . 22
5. O ches a o 25
5.1. Pe o mance.................................... 25
5.2. Classes and In e aces used o c ea e he O ches a o . . . . . . . . . . . . 26
5.2.1. MSO ches a o Main ......................... 26
5.2.2. Fo ma .................................. 26
5.2.3. Fo ma sDAO ............................... 27
5.2.4. Fo ma sREST .............................. 27
5.2.5. Swagge Con ig . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.3. Consis ency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.4. Lib a ies employed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.5. Di icul ies and conside a ions . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6. Me ada a Managemen 31
6.1. Implemen a ion de ails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.1.1. Viewing me ada a om a p oposed ile . . . . . . . . . . . . . . . . . 31
6.1.2. Remo e me ada a om a p o ided ile . . . . . . . . . . . . . . . . . 33
6.2. File o ma s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.3. Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7. Con ibu ion 37
7.1. Diego’s con ibu ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.2. Guille mo’s con ibu ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7.3. Rosa’s con ibu ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.3.1. S age 1: Realiza ion o a es b owse ex ension . . . . . . . . . . . . 40
7.3.2. S age 2: B owse ex ension s udy . . . . . . . . . . . . . . . . . . . . 41
7.3.3. S age 3: Feasibili y o he p oposed b owse ex ension . . . . . . . . 41
7.3.4. S age 4: Memo y epo . . . . . . . . . . . . . . . . . . . . . . . . . 42
8. Conclusions 43
8.1. Fu u e wo k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
8.1.1. Ex end he unc ionali y o mo e o ma s . . . . . . . . . . . . . . . 44
8.1.2. Ex ension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8.1.3. Mo e o om local o online . . . . . . . . . . . . . . . . . . . . . . . 45
8.1.4. Ex end his se ice o o he pla o ms . . . . . . . . . . . . . . . . . 45
Bibliog aphy 47
2.2. Why is Me ada a so Impo an 7
"De ails":{
" Ca ego ies " : [
"GPS"
] ,
"Name": "Ve sionO Gps" ," Value ": "2 2 0 0" ,
"Name": " GpsLa i udeRe e ence " ," Value ": "N" ,
"Name": " La i ude " ," Value " : "40"25 ’1.54" ,
"Name": " GpsLongi udeRe e ence " ," Value " : "W" ,
"Name": "Longi ude " ," Value ": "3"39 ’45.71" ,
"Name": " Re e enceAl i ude " ," Value " : "Sea l e e l " ,
"Name": " Al i ude " ," Value ": "36675/50 me es " ,
"Name": "GpsTimes amp" ," Value " : "18: 37:17 UTC" ,
"Name": " Deg eeO P ecisionGps " ," Value " : "17399/1000" ,
"Name": "GpsDa es amp" ," Value " : "2020:06:13"
}
Figu e 2.1: Con en o he me ada a o a pho o aken om a phone on he s ee , we ha e
selec ed he e all he ields wi h some in o ma ion abou he GPS coo dina es, om all he
o iginal me ada a.
a lo o in o ma ion. They will know who a e you ex ing wi h, he imes amp o hose
messages, i i is a one-way o a ecip ocal communica ion and o how much ime he
con e sa ion ook place. Realizing he popula i y o hese se ices, he amoun o pe sonal
in o ma ion ga he ed is huge.
Finally, we will like o spo ligh ano he h ead which can be e en mo e di ec han he
ones men ioned abo e. The insigh o you me ada a can be a g ea se ice o someone
planning on a phishing (21) a ack on you.
A phishing a ack could be summa ized as a way o ge some o you pe sonal in o ma-
ion by p e ending o be a us wo hy en i y which you will no mis us . The e o e you
will obey hei demands o you pe sonal in o ma ion like changing a passwo d o di ec ly
elling i o hem. Bu phishing by i sel is no such a dange ous ool, a e all, p e ending
o be you bank o you phone company jus by making he mail look o icial is jus use ul
o a ce ain poin .
Bu now imagine ha his a acke has been able o ga he some o you iles, knowing
he numbe o iles we upload e e y day o he in e ne is no un hinkable. Maybe hey
did no con ain any sensi i e da a, bu as we ha e said be o e he me ada a on i could
con ain pe sonal in o ma ion like you name, he name o you company, mail add esses
o he people you ha e been in con ac wi h, you p o essional depa men , he kind o
so wa e you use, whe e in you compu e he ile was s o ed in, so i he olde s o you
compu e ha e desc ip i e names hey will become e en mo e clues abou you. Wi h all
his in o ma ion in his powe , he phishing a acke can look way con incing, o he wise,
how would hey know ha much abou you?.
8Chap e 2. P elimina ies
Figu e 2.2: Monoli hic a chi ec u e in opposi ion o he Mic ose ices a chi ec u e.
2.3. Wha a e Mic ose ices?
Mic ose ices (52) is an a chi ec u al and o ganiza ional way o building a so wa e
p ojec by disengaging i in smalle and g ea independen se ices dis ibu ed in di e en
machines which communica e among hemsel es h ough a well-de ined API.
A Se ice in he So wa e A chi ec u e ocabula y is each o he unc ionali ies ha
compose an applica ion and has a unique ask. So imagine you a e on a websi e whe e you
can buy any kind o good. When you add any good o he ca you a e using one speci ic
se ice, i you sea ch using he di e en il e s ha he si e o e s you a e using a second
se ice, and when inally you p oceed o pay o you o de , you will make use o a hi d
se ice. So on one websi e and in a ew seconds and wi hou no icing you ha e employed
h ee di e en se ices, all o hem wo king oge he in he same ame.
T adi ionally when So wa e companies had o de elop a p ojec ollowed wha we say
is a Monoli hic a chi ec u e. In his app oach, he en i e sys em unc ionali y is based on a
single applica ion. All he ea u es will be execu ed on he same machine, communica ing
among hem o o e di e en se ices o he use . As a consequence o his, all had o be
coded on he same p og amming language, as he e was jus one machine he e was jus
one da abase and one se e . This model can be seen on he le side o Figu e 2.2.
As he compu ing powe o he sys ems e ol ed also did he So wa e applica ions,
which became bigge , mo e complex and demanded a highe Main ainabili y. This was
ha d o accomplish in he ame o a monoli hic a chi ec u e o ob ious easons: looking
o a ce ain unc ion in a p ojec which has housands o lines o code which we e no
w i en by you does no look op imal.
F om his need o decen alise he p ojec s in o smalle pa s, he Mic ose ice A chi-
ec u e a ise. He e e e y ea u e which o ms he p ojec will be hei applica ion, unning
in hei machine and ha ing i needed hei da abase and se e . As said in he de ini ion
a he beginning o he sec ion, each mic ose ice will communica e wi h each o he using
an API.
2.4. Bene i s o Mic ose ices 9
2.4. Bene i s o Mic ose ices
The main ad an ages o adop ing he mic ose ice a chi ec u e a e he ollowing ones:
(51)
Modula i y: As each Mic ose ice is widely au onomous om he o he s, i can be
indi idually de eloped and deployed. This helps o spli he asks among he eam,
as bounda ies o each se ice a e well-de ined. As well in he case o any e o , i
will be jus in he same Mic ose ice whe e i was caused, enabling he es o he
sys em o wo k as usual.
Scalabili y: Wi h he spli o he p ojec , we can ocus ou e o on he Mic ose -
ices which demand a mo e in ensi e wo kload. Once a mic ose ice is al eady com-
ple ed i can be le aside being ully unc ional and no dis u bing he main e o
on he o he s.
Ve sa ili y: Mic ose ices b ing us he possibili y o using di e en echnologies
and p og amming languages o each mic ose ice. They will communica e wi h he
o he componen s in he sys em by he API, no ma e he chosen echnology. This
allows he de elope s o selec he echnology used in each module o he one which
adjus s he mos o he equi ed unc ionali y.
Main enabili y: When main aining any unc ionali y, as hey a e well dis inguished
we could ocus on hose in ol ed di ec ly in he changes, lea ing hose no in ol ed
in he main enance aside. This was ha de o ge in he monoli hic a chi ec u e, we e
p ocesses we e igh ly connec ed, and making a change could cause a domino e ec .
Agili y: Many common unc ionali ies such as he ones o au hen ica ion, he sea ch
o an i em o i is aceabili y ha e al eady been well de eloped as Mic ose ices by
hi d pa ies, so he e is no need o s a ing om sc a ch as you can make use o
hem. Mo eo e , he g ea e acili y o spli he wo k be ween al eady es ablished
mic ose ices makes i as e o s a de eloping.
2.5. B owse ex ensions and Ja aSc ip
B owse ex ensions a e small applica ions ha un on you In e ne b owse and o e
addi ional unc ionali y o he ones he b owse has by de aul . They a e ypically a ailable
on hei websi es o in an ex ension s o e, as many a e no ee. They equi e he use o
download and ins all hem bu as hey a e ypically qui e small i is done easily.
We could classi y he mos popula b owse ex ensions (19) by he use s by he pu pose
hey ha e:
Ad e isemen blocking: He e we could place he wo mos popula ones: Adblock
and Adblock plus. Thei ask is o anish he publici y, he i s one is mo e ocused
on websi e popups while he second in he ad e isemen on he ideos.
10 Chap e 2. P elimina ies
Secu i y: He e we can men ion A as Online Secu i y and A i a B owse Sa e y.
They y o a oid he download o malwa e and he acking o you ac i i ies e-
spec i ely.
Easiness: Unlike he wo las ca ego ies, his one has a b oade a ie y o pu poses
bu can be summa ized saying ha hey y o sa e you ime.
•A as Sa e P ice: Compa e he p ices o he same i em ac oss many si es o
o e you he bes deal.
•Quick s a : In a simila way ha b owse bookma ks, allow you o ge o you
a ou i e si es by jus one click.
•Adobe Ac oba - C ea e PDF: Downloads a whole web con e ing i o a PDF
ile.
•Hangou s: Allows you o go o he amous Google cha ing app wi hou he
need o en e ing and logging e e y ime in hei main si e.
I is e y encou aging o ou p ojec o ha e a simila cha ac e o some o he mos
popula ex ensions on he ma ke , as a e he ones p e iously g ouped as secu i y ex ensions.
Mos o he ex ensions a e coded using Ja aSc ip (50) as is one o he mos popula
and widely used p og amming languages (18). Ja aSc ip is an in e p e ed p og amming
language, his means ha does no equi e o be compiled as is designed o un on he
b owse s. I is mainly employed o execu e ac ions on he clien -side bu i is also possible
o use i as well in he se e -side. Al hough Ja aSc ip is an objec -o ien ed language,
i is based on p o o ypes, which means ha i does no use classes, also i is an un yped
p og amming language.
Ja aSc ip indica es he ac ion i wan s o pe om o a ce ain esou ce by HTTP pe i-
ions, Ja aSc ip can do his in wo di e en ways, using e ch(41) o XMLH pReques (45):
e ch is a new na i e Ja aSc ip API, suppo ed by mos o he b owse s which
p o ide a iendly in e ace. The e ch me hod ease making asynch onous eques s
and handle esponses be e han XMLH pReques .
The main di e ence be ween e ch and XMLH pReques is ha he e ch API
uses P omises(42), a oiding callbacks. When we call e ch aP omise is e-
u ned, whe he i was success ul o no . A P omise ep esen s a alue ha may
be a ailable now, in he u u e, o ne e .
Once e ch has p e o med he eques , a se o me hods will esponse as ollows:
•. hen() (38) In case he eques was success ul, he . hen() me hod will
ecei e a Response objec .
•.ca ch() I he eques ailed he .ca ch() me hod will ecei e an e o
objec .
•.json() As he communica ion among Mic ose ices is ca ied on by he use
o JSON iles, he esponse mus be ans o med in o a JSON objec wi h he
.json() me hod. As his me hod is applied o a Response objec , he e u n
will be a new P omise, so i needs o chain on ano he . hen().
2.6. Sp ing Boo 11
XMLH pReques is a Ja aSc ip objec ha p o ides an easy way o ge in-
o ma ion om a URL wi hou ha ing o eload he en i e page. A web page
can e esh only pa o he page wi hou in e up ing wha e e he use is doing.
XMLH pReques can make bo h synch onous and asynch onous eques s bu is
no as op imal as e ch (48) because, as said be o e XMLH pReques do no
use P omises. Bu un o una ely XMLH pReques is he only way o make syn-
ch onous eques s (36).
2.6. Sp ing Boo
Sp ing Boo (54) is an open-sou ce amewo k, based on Ja a, o de elop s and-alone
Ja a web applica ions ha can apidly and easily be deployed.
Sp ing Boo e ol es om he Sp ing (22) amewo k, bu ins ead o all he con igu a-
ions needed o inally ge a unc ional applica ion, Sp ing Boo uns wi h minimal o ze o
con igu a ions. I owns an embedded HTTP se e , and o a oid he majo numbe o
con igu a ions, i p io i izes con en ion o e con igu a ion. As well Sp ing Boo does no
equi e an XML con igu a ion, eplacing i by he anno a ions which s uc u e he p ojec
using componen -scanning.
All he abo e cha ac e is ics make Sp ing Boo an ideal ool o de eloping Ja a Mi-
c ose ices as i pe ec ly ma ches he bene i s de ailed in Sec ion 2.4.
2.7. Tools o me ada a managemen
F om wha we ha e esea ched he e is no a se ice ha o e s wha we ha e a ge ed
in his p ojec . The mix o bo h an ex ension ha is easily handled and no equi es om
wo king wi h he iles locally and he capabili y o cleaning he me ada a om he b owse
i sel is some hing ha a leas we could no ind.
Conside ing ex ensions, he e a e some in he ma ke which allows you o see he
me ada a o he websi e you a e on, bu he e is no one which ocuses on he cleaning o
he me ada a om uploaded iles be o e sending hem. Rega ding me ada a cleaning, he e
a e se ices which labou as desk op p og ams equi ing ins alla ion and wo king locally.
The e a e also some online applica ions which equi e you o upload he iles explici ly o
hei si e, so you ha e o ge hem ins ead o he o he way ha is wha we p e end. We
ha e disca ded he se ices which equi e o be bough o y hem as Ba chPu i ie (30)
and cen e ed ou a en ion on he ones we could use o ee, as ou ex ension is. Some o
he ones we conside mo e in e es ing a e:
The e is a desk op p og am called PDF Me ada a Edi o (29) which helps you o
handle he me ada a con ained in a ce ain PDF. I wo ks as ollows: i s you d ag
and d op he PDF you wan o wo k wi hin he p og am window. A e ha , all he
me ada a con ained in he documen is displayed in he di e en panels. The s ong
poin o his applica ion is how use - iendly i is and how li le ime i equi es o
modi y he me ada a. I also p esen s some in e es ing ea u es like se ing some
12 Chap e 2. P elimina ies
de aul alues o u u e uses. The main di e ences wi h ou applica ion a e he ac
ha his one jus wo ks locally and a ge s speci ically PDF documen s.
Ano he p og am wo h men ioning is Exi 2 (28) which in a simila way as PDF
Me ada a Edi o cleans iles which a e s o ed in he ile sys em. This p og am ins ead
ocuses on image iles, a o al o 25 di e en image o ma s a e suppo ed (Among
hem he mos common ones JPG, PNG, TIF and GIF). I is be e han PDF
Me ada a Edi o in e ms o suppo ing a wide ange o alid o ma s. Mo eo e ,
he use o his ool is by commands and is only a ailable o Linux and MacOS
making i less manageable o mos o he use s. We ha e in common wi h i he
o ma s we can clean, bu he ac ha his ool jus wo ks locally once mo e makes
i di e om ou applica ion.
A ool ha ma ches mo e wi h ou p ojec in he sense ha is an online se ice is Exi
Viewe (31). Howe e , i is no a ailable as a b owse ex ension and i does no allow
you o modi y he me ada a ound, jus o isualize i . Simila ly o Exi 2 i ocuses
on image o ma s and i has a comple e pla o m whe e you can ind me ada a such
as all he modi ica ions ha he image has had since i was c ea ed.
A p og am we can no exclude when alking abou dealing wi h me ada a is FOCA
(33) (Finge p in ing O ganiza ions wi h Collec ed A chi es). I s main pu pose is o
audi domains, and i is e y used in he p ac ice o pene a ion es ing. FOCA
sea ches in di e en sea ch engines (Google, Bing, and Duck Duck Go) o in o ma-
ion a he domain le el downloading all he iles ela ed. Then, using he me ada a
a ached o hose iles, i elabo a es a map whe e you can see he di e en ope a -
ing sys ems, applica ions, emails and he se e add essing o he company you a e
in es iga ing.
In addi ion o his powe ul ool, FOCA also allows you o scan a se o me ada a
which a e in you ile sys em. I is be e o his ask han he p og ams enume a ed
abo e because o e s you he possibili y o scan many di e en o ma s (PNG, PDF,
Open o ice...) and o do i in g oups and no one by one. I ex ac s he me ada a,
ea s i be o e p esen ing i , a oiding he epe i ions and classi ying he me ada a
by kind. FOCA is an open-sou ce p og am which is easily downloaded and which
comple e code is on hei Gi hub eposi o y (32).
Ele en Pa hs, he company who owns FOCA, also came up wi h Me ashield (23)
a se ice-o ien ed p og am o p o ec he me ada a o he companies. I is a paid
se ice, bu hey ha e as well a ee applica ion which enables you o upda e jus a
ile a a ime and hen i displays all he me ada a on i . Then i allows you o clean
i all. Ou o all he ee se ices we ha e checked his is p obably he one which
wo ks he bes , no jus in e ms o he numbe o ile o ma s which accep s bu also
because how easy is i o use.
Chap e 3
Sys em O ganiza ion
This chap e o he documen is dedica ed o he dis ibu ion o he di e en compo-
nen s ha make up he applica ion, whe e, as a me ada a cleane , i equi es he p ocessing
o many di e en ypes o iles. Each ype o ile equi es a di e en mic ose ice cleane ,
o ming a complex sys em ha wo ks oge he wi h he ex ension and he o ches a o
mic ose ice as shown in Figu e 3.1.
T adi ionally, applica ions we e designed so ha all he elemen s could be implemen ed
in he same p ojec whe e all p ocesses a e closely associa ed and un as a single se ice.
Bu when he applica ion equi es imp o emen s o added unc ionali y all a chi ec u e
mus be imp o ed. Adding o imp o ing he ea u es o a monoli hic applica ion be-
comes mo e complex as he code base g ows. In con as , i applica ions a e designed wi h
mic ose ices (14), hese p oblems a e sol ed and de elopmen and esponsi eness a e
p omo ed. Wi h mic ose ices, applica ions a e di ided in o independen elemen s ha
wo k oge he o ca y ou he same asks.
Figu e 3.1: G aphical ep esen a ion o he in e nal o ganiza ion o he sys em
13
14 Chap e 3. Sys em O ganiza ion
Each se ice is a sepa a e codebase, which can be managed by a small de elopmen
eam o a single pe son. Se ices can be deployed independen ly wi hou ebuilding and
edeploying he en i e applica ion and hey do no need o sha e he same echnology s ack,
lib a ies, o amewo ks. I de elope s add mo e code o a se ice o e ime and he se ice
becomes complex, i can be b oken down in o smalle se ices.
To gua an ee he co ec ope a ion o he mic ose ices in he sys em, he e mus be an
o ches a o componen ha is esponsible o placing se ices in he igh place ensu ing
ha he co ec mic ose ices a e being used in he igh place.
3.1. Ex ension
The ex ension is a small piece o so wa e ha is a ached o he b owse and allows
he use o emo e all he me ada a sen in a ile while uploading i . I wo ks as he
main p og am di ec ing each ope a ion pe o med in he sys em. The ex ension is he
componen ha makes mos o he connec ions as shown in Figu e 3.2, and hose a e he
ollowing:
Web b owse : The ex ension moni o s all eques s made by he b owse un il i
inds a eques wi h a ile o be uploaded. This ile is ex ac ed om he eques
and p ocessed i in he ex ension, whe e he ile ype is used o selec he URL
o he mic ose ice ha mus be called o clean he ile hanks o he o ches a o
mic ose ice.
O ches a o : The o ches a ing mic ose ice p o ides a mapping om ile ypes o
Figu e 3.2: Ex ension asks and i s connec ions
3.2. O ches a o 15
mic ose ice URLs ha p ocesses hem. These connec ions a e made asynch onously
wi h e ch API (41), sending a GET eques o he URL o he o ches a o .
Cleaning mic ose ices: The cleaning mic ose ices ecei e he ile sen by he
ex ension and e u n a lis wi h he me ada a o he ile o be emo ed. This p ocess
is done synch onously wi h he XMLH pReques API (45), which sends a POST
eques sending he ile o he co esponding URL. I can also ecie e a ile and dele e
e e y me ada a ound on i . hese connec ions a e made asynch onously wi h e ch
API, sending a POST eques o he URL gi en by he o ches a o .
The ex ension, as he cen al p og am o he sys em is he one in cha ge o ca ying ou
da a exchanges wi h o he pa s o he sys em. In addi ion o pe o ming da a exchanges,
i also pe o ms o he asks, such as p ocessing eques s o in e cep ou going iles, o
p ocessing hese iles o b eak hem down in o aluable in o ma ion o each mic ose ice.
Las ly, i is in cha ge o downloading he clean ile once i has been ecei ed by he cleaning
mic ose ice in o he use ’s compu e . This p ocess is explained in mo e de ail in Chap e
4.
3.2. O ches a o
The o ches a o p o ides he ex ension wi h in o ma ion abou he ypes o iles ha
a e suppo ed by he sys em, ha is, i hey can be p ocessed o no . Besides, i p o ides
he ex ension wi h he URLs o he mic ose ices o each ile ype, so ha i o ganizes
he sending o da a o o he se ices ( his p ocess is u he de ailed in Chap e 5). These
a e he connec ions made by he o ches a o :
Da abase: The in o ma ion ha he o ches a o manages is s o ed in a da abase.
The o ches a o accesses he da abase wi h Sp ing Da a JPA echnology (13),
which is pa o he la ge Sp ing Da a amily. This allows he o ches a o o que y
and add da a o he da abase. This pa is explained in de ail in Chap e 5.
Ex ension: As explained be o e, he ex ension sends a GET eques o he o -
ches a o and ecei es a lis wi h he names o he ile ypes ha a e a ailable in
he sys em, in addi ion o he URLs whe e each o he associa ed mic ose ices a e
loca ed.
3.3. Cleaning mic ose ices
The cleaning mic ose ices emo e he me ada a om he iles hey ecei e. The e is a
mic ose ice o each ype o ile ha can be cleaned by he sys em. These mic ose ices
can be implemen ed in di e en ways, using di e en echnologies, e c. New cleaning
mic ose ices can be added o he sys em by no i ying he o ches a o ha he e is a
new ype o da a ha can be cleaned. The connec ion es ablished by he mic ose ices is
always o he ex ension, which can be o wo ypes:
16 Chap e 3. Sys em O ganiza ion
Figu e 3.3: O ches a o connec ions
Me ada a que y: The ex ension sends a POST eques wi h he ile (explained in
Sec ion 3.1) and he mic ose ice sends back a s ing wi h he in o ma ion o all
he me ada a ound in he ile ha can be emo ed.
Cleaning me ada a: The ex ension sends again he ile (explained in Sec ion 3.1)
and he mic ose ice emo es me ada a ound in he me ada a que y.
Figu e 3.4: Cleaning mic ose ices connec ions
4.5. Limi a ions ound du ing de elopmen 23
i pops an ale o e eshing and no sa ing he changes like i is shown in Figu e
4.5.
Figu e 4.5: Popup when upda ing he page
This in e up ion is an au oma ic ale gene a ed by he b owse and canno be ac-
cessed wi h code, only he use can close i . This makes he ex ension less anspa en
making he use in e ac wi h i mo e imes han expec ed, and i could cause a wo se
expe ience wi h i .
API limi a ions: Web eques API seems o be incomple e acco ding o some pos s
ound in ch omium o ums indica ing ha some unc ionali ies a e incomple e o
bugged (34). The bigges p oblem was inding hose eques s ha ca y he ile ha
is abou o be uploaded. The Google pla o ms (Google D i e, Gmail, e c.) in heo y
ha e he same ile upload p o ocols. They use mul ipa / ela ed eques ypes
as i is shown in he documen a ion o de elope s, bu analyzing a ic eques s we
ha e disco e ed ha mul ipa / ela ed eques s a e cap u ed in Google D i e only.
This inc eases he limi a ions imposed on he ex ension, jus wo king in Google D i e.
Ano he eques ype we s udied was mul ipa / o m-da a. These eques s
a e used in HTML o ms, he mos simple POST eques ha can be done. The
uploaded ile was a eling in a Reques Payload heade and web eques API
does no suppo his ype o heade s and he in o ma ion canno be handled wi h
an ex ension.
Synch onous XMLH pReques dep eca ed: Mos o he eques s o he mi-
c ose ices a e done asynch onously, bu when he me ada a que y is done, he ex-
ension has o pause i s execu ion un il he me ada a eaches he ex ension. The use
o synch onous me hods igge s a wa ning on he console log like he one shown in
Figu e 4.6 indica ing ha synch onous me hohds a e dep eca ed (36). As explained
Figu e 4.6: Ale due o he usage o synch onous me hods on he main h ead
in he XMLH pReques documen a ion, hese ypes o eques s will s op wo king
in he nea u u e:
"Synch onous XMLH pReques ou side o wo ke s is in he p ocess o
being emo ed om he web pla o m as i has de imen al e ec s on he
end use ’s expe ience. (This is a long p ocess ha akes many yea s.)
De elope s mus no pass alse o he async a gumen when he cu en
global objec is a Window objec . Use agen s a e s ongly encou aged
o wa n abou such usage in de elope ools and may expe imen wi h
h owing an "In alidAccessE o " DOMExcep ion when i occu s."
24 Chap e 4. Ex ension
Ex ension compa ibili y: The usage o APIs like ch ome.downloads and
ch ome.no i ica ions make he ex ension only compa ible wi h Ch ome b owse
and Fi e ox. Ch ome implemen s he APIs using he ch ome.*namespace wi h call-
backs. Fi e ox implemen s he namespace b owse .*wi h P omises o all APIs,
and ch ome.*(wi h callbacks) o almos all APIs (all ha a e c oss-compa ible
wi h Ch ome) (39). The o he API is based on ch ome.downloads bu i is imple-
men ed using he b owse .*namespace (46) and his canno be used on Ch ome.
Chap e 5
O ches a o
We ha e al eady spoken be o e abou he ad an ages o he Mic ose ices A chi ec u e
(MSA) 2.4. Bu when you ollow his a chi ec u e, you ha e o decide on how o in eg a e
he mic ose ices and he e o e how a e going o in e ac among hemsel es. The e a e
wo op ions which ha e a e he mos popula ones when using MSA; he cho eog aphy and
o ches a ion echniques (56):
Cho eog aphy: In his echnique mic ose ices di ec ly in e ac wi h each o he
wi h no middle man. When a mic ose ice execu es a ansac ion, an e en is pub-
lished and i could be subsc ibed by one o mo e mic ose ices o igge hei ans-
ac ions.
O ches a ion: He e one se ice, he cen al coo dina o , conduc s he in e ac-
ions be ween mic ose ices. Based on an incoming e en , i igge s he nex local
ansac ions jus in he mic ose ices ha conce ns.
Ha ing conside ed bo h, we decided o ollow he O ches a o echnique. This elec ion
ligh ens he wo k o he es o he mic ose ices o he p ojec so hey can ocus comple ely
on hei asks. Also, his app oach makes he message low among mic ose ices mo e
o ganized, as can be pe cei ed in he ep esen a ion o bo h echniques in Figu e 5.1. This
chap e de ails he Sp ing Boo mic ose ice we ha e de eloped o ac as O ches a o ,
and how exac ly i wo ks.
5.1. Pe o mance
We ha e de eloped he o ches a o as an API REST (26) o manage he o ma s
suppo ed by ou sys em. So basically is a web se ice wi h a se ies o me hods, which
a e on di e en URL wai ing o p o ide ce ain unc ionali y. Any clien can use hem
by he expec ed HTTP p o ocol unc ion, ei he o ge in o ma ion o o commi i , his
in o ma ion will always be ep esen ed as a JSON ile.
25
26 Chap e 5. O ches a o
Figu e 5.1: The wo main echniques o coo dina e he i e a ion among mic ose ices
The pe o mance will be as ollows: When he ex ension ecei es a eques om a use ,
i will ask he o ches a o mic ose ice o he URL o he se ice which hos s ei he he
me ada a cleaning o he me ada a displaying o ha o ma . The o ches a o will consul
he da abase whe e his in o ma ion is s o ed, and ell he ex ension whe e he se ice is
hos ed.
As well i we wan o egis e any new da a o ma ha now is suppo ed, i can be
included o he da abase jus wi h an API call o he adequa e unc ion, as explained in
sec ion 5.2.4. Same can be applied o modi ica ion in case he URL in which a mic ose ice
ope a es changes o he elimina ion o a o ma ha is no held anymo e.
5.2. Classes and In e aces used o c ea e he O ches a o
In his sec ion, we will de ail he i e classes ha make up his mic ose ice. All o
hem a e in he ollowing pa o he eposi o y Me ada os-2020/MSO ques ado /
s c/main/ja a/com/ini / o ma os/.
5.2.1. MSO ches a o Main
This is a e y simple class, only con ains he main unc ion o he applica ion. Sp ing
Boo gene a es his class by de aul and i ini ializes he Tomca se e .
5.2.2. Fo ma
This class will ep esen each o he o ma s ha a e suppo ed by ou applica ion. I
is a plain old Ja a objec (POJO) so i ex ends nei he implemen s any o he class. I has
h ee p i a e class a iables which a e:
S ing name: I ep esen s he name o he o ma which is suppo ed, o example,
"PNG" o "JPEG".
5.2. Classes and In e aces used o c ea e he O ches a o 27
S ing elimina ionURL: URL o he se ice which deals wi h he o ma name
and which elimina es he me ada a.
S ing consul URL: URL o he same se ice bu his ime o he add ess which
will jus show he me ada a ins ead o elimina ing i .
In addi ion o hese class a iables i will ha e me hods ge and se o each one
o hem, so hey could be consul ed o modi ied by he me hods in Fo ma sREST, ha
will be explained la e in Sec ion 5.2.4. I coun s wi h a nulla y cons uc o , and ano he
cons uc o wi h h ee pa ame e s, o c ea e an objec wi h all he h ee a ibu es al eady
se .
To communica e wi h he da abase h ough JPA (27), we anno a e his class as @En i y.
JPA, will u n he objec s o his class o ows so hey will be able o be s o ed in he
MySQL da abase o his mic ose ice, also he ans o ma ion will as well be in he o he
way u ning each ow om he able o a di e en Fo ma objec .
To indica e o Sp ing Boo which able om he da abase co esponds o his class
we use he anno a ion @Table(name = o ma sDB). As well o c ea e he co espon-
dence among he class a ibu es and able columns we ha e o anno a e each o he a -
ibu es wi h @Colum(name="columnName", nullable = False), whe e each a -
ibu e "columnName" has o ma ch wi h he column name o he able. The exp ession
nullable = False o ces o ill hese a iables, no be possible o lea e hem wi h a
null alue. We also ha e o indica e which a ibu e will ac as iden i ica ion, once again
his is done by anno a ions, wi h @Id anno a ion, he ID in his class will be name.
5.2.3. Fo ma sDAO
This is he only in e ace o he mic ose ice. This in e ace i sel ex ends om ano he
in e ace, JpaReposi o y, which has wo gene ics. The i s one ells om which en i y
does he DAO, in ou case Fo ma . And second in e ace con igu es which da a ype is i s
ID, so o us, i will be S ing.
Only by doing his, we a e implemen ing all he unc ionali ies ha he DAO pa e n
in Sp ing Boo has (2). These unc ions will us o make use o i s unc ions, which will
come as a g ea help in he REST class 5.2.4 o pe o m consul s o he da abase.
Ano he eason o use he DAO pa e n is o sepa a e he unc ionali y o he logic o
his mic ose ice om he s o age pla o m we ha e chosen. So i o example, we decided
o change ou da abase om MySQL o ano he one,we ied and is de ailed in Sec ion
5.5, all he logic o he sys em will s ay he same as no hing ela ed o i has changed. The
DAO ac s as a unway be ween ou da abase which ensu e he pe sis ence and he logic o
ou sys em, so i we commi he change o s o ing se ice, only his class will be a ec ed.
5.2.4. Fo ma sREST
This class has all he REST se ices ha his mic ose ice p o ides. To indica e
his o Sp ing Boo we ha e o use he anno a ion @Fo ma sREST. Also o indica e
28 Chap e 5. O ches a o
he URL whe e his se ice will lis en o connec ions we ha e o use ano he anno a ion
@Reques Mapping("/ o ma s") which will make his mic ose ice wo k om he ad-
d ess localhos :8085/ o ma s, in Sec ion 5.5 is explained why his po .
I has a Fo ma sDAO objec , he one explained in Sec ion 5.2.3, as he only a ibu e,
o ca y on he communica ion wi h he da abase. To use i we ha e o make he anno a ion
@Au owi ed which will injec a eal objec . This is necessa y because Fo ma sDAO is
an in e ace, and in e aces can no be ins an ia ed, bu Sp ing Boo in e nally gene a es a
p oxy ha when unning he applica ion will p o ide us wi h a alid Fo ma sDAO objec .
The me hods o his class has a e:
ge Fo ma s: This unc ion will e u n a Lis o all he Fo ma objec s held by
he applica ion. Is going o be anno a ed as @Ge Mapping so i can esponse in he
add es localhos :8085/ o ma s o he me hods GET. I uses he Fo ma sDAO
me hod indAll() o ge hem all.
ge Fo ma : This is a simila unc ion o ge Fo ma s, bu his will only e u n
one ce ain Fo ma . I eci es as pa ame e a S ing name elling he name o
he o ma we wan o consul . As ge Fo ma s is al eady lis ening in he add ess
localhos :8085/ o ma s o GET me hods we need a di e en add ess o lis en
i . To sol e his we will use @Reques Mapping ( alue = "nameFo ma "), so
his unc ion will be lis ening o @GET me hods in he add ess localhos :8085/
o ma s/nameFo ma , whe e nameFo ma co esponds o each o he names o
he o ma s p esen in he da abase. The sea ch o ha pa icula o ma his ime
will done by he Fo ma sDAO me hod indById(). As esul o his ucn ion
he Fo ma objec i sel will be e u n i i was ound and a HTTP S a us code
no-con en o he wise.
c ea eFo ma : Will inse a new Fo ma ha we a e able o handle o he
da abase. As pa ame e i ecie es he objec Fo ma ha we wan o s o e. I will
use he anno a ion @Pos Mapping so will be lis en in he add ess localhos :
8085/ o ma s like ge Fo ma s bu his ime wai ing o POST me hods. This
unc ion will use he Fo ma sDAO me hod sa e() o s o e he Fo ma in he
da abase. I will e u n he Fo ma objec ha we jus inse ed, in case he se ice
which made he call wan s o check ha spellcheck wen as expec ed.
dele eFo ma : This unc ion is used o elimina e o o ma s which do no hold
any mo e. Same as ge Fo ma i lis ens in all he add esses co esponding o
each o he Fo ma p esen in ou da abase. Bu unlike ha , his se ice will
wai o DELETE me hods as is old by i s anno a ion @Dele eMapping( alue
= "nameFo ma ") on he add ess localhos :8085/ o ma s/nameFo ma .
I will ha e a pa ame e S ing nameFo ma which indica es he Fo ma sDAO
which Fo ma o elimina e. The Fo ma sDAO objec will pe o m he elimina ion
by using dele eById() being his ID nameFo ma . The answe om his me hod
will be an emp y body, bu we will be able o know i was success ul because also
will p oduce he code 200.
upda eFo ma : Is in cha ge o changing he alues o an objec Fo ma in case
he URL whe e he co esponding se ice is hos ed changes. I will wo k on he
add ess localhos :8085/ o ma s wai ing o PUT me hods, his is indica ed
5.3. Consis ency 29
Figu e 5.2: Documen a ion gene a ed by Swagge , showing all he unc ions a ailable by
ou API REST.
by he anno a ion @Pu Mapping. The calls o his se ice will be done a aching
o hem a JSON objec , showing how we wan ha Fo ma o look like a e he
upda e. Fi s we will ind ha Fo ma by using indById() and hen wi h he
Fo ma se e s we modi y i o look as he JSON objec ecei ed. I will e u n a
Fo ma showing how he upda e looked like.
5.2.5. Swagge Con ig
This class gene a es he documen a ion o he whole mic ose ice. I someone wan s
o make use o ou se ices, wi h no need o look a ou code, will be able o know
o each me hod, in which URL esponses, which HTTP me hod is wai ing o , which
pa ame e is expec ing and wha will be he answe . Has jus one me hod, api() which
is anno a ed by @EnableSwagge 2 o enable Swagge o au o-documen ou se ices.
All he documen a ion will be displayed in a e y use ul g aphic in e ace whe e we can
e en y each o he me hods, on he add ess "/swagge -ui.h ml". An example o
how his documen a ion looks is in Figu e 5.2
5.3. Consis ency
To keep he da a consis ency in his mic ose ice and a oid losing he o ma s ou
applica ion can wo k wi h, we decided o use a da abase o s o e hem. As he amoun o
da a we s o e is small, he decision o using MySQL is no op imal, as is a hea y pla o m
designed o wo k wi h huge ables. Bu due o di icul ies which we explain in Sec ion 5.5
and ha Sp ing Boo o e s easy in eg a ion o MySQL (24), we decided o use i .
As de ailed in he class Fo ma in Sec ion 5.2.2, JPA makes he in e ac ion wi h he
da abase qui e easy, jus needing he anno a ions o do he ans o ma ions be ween objec s
and SQL ins uc ions and ice e sa. In he MySQL en i onmen , we jus need o gene a e
he able wi h he same name as he name used in he anno a ions. To le Sp ing Boo
know he de ails o he da abase connec ion such as he use name o he passwo d we ha e
30 Chap e 5. O ches a o
o modi y he con igu a ion ile, speci ying hese p ope ies. I is use ul also o indica e
in his ile he p ope y ddl-au o: upda e so he able will be illed in au oma ically
om he en i y class e e y ime we lunch he p ojec . Ano he p ope y which needs o
be se is dialec : o g.hibe na e.dialec .MySQL5Dialec , which de ines he
language used o ca y he p e iously men ioned ans o ma ions.
5.4. Lib a ies employed
Along wi h he classes and in e aces de ailed in Sec ion 5.2 o build his o ches a o
mic ose ice we ha e used some lib a ies o simpli y ce ain ac ions. These lib a ies a e:
Sp ing Boo s a e web (55): When we un he main() me hod, his lib a y
will s a a Tomca se e as an embedded con aine so we do no ha e o use an
ex e nal se e . This in addi ion o simpli ying a lo he a chi ec u e o he mic ose -
ice, allows i o un in jus a ew seconds.
mysql connec o ja a (24): This one includes he MySQL d i e which allow
us o connec o ha Da abase.
sp ing boo s a e da a jpa (25): Ja a Pe sis ence API (JPA) le us con-
e objec s o SQL ins uc ions and he o he way, u n he esul o a SQL consul
o an objec .
sp in ox swagge ui (8): This lib a y gi e us he possibili y o au o-documen
ou se ices employing he me ada a on he anno a ions used on he unc ions.
5.5. Di icul ies and conside a ions
We ied o use a ligh e da abase mo e lined wi h ou needs, namely SQLi e (9)
ins ead o MySQL. Un o una ely, he e was no much documen a ion on how o
in eg a e i in Sp ing Boo and we we e no able o modi y he p ope ies ile o ge
i . So inally we s ayed wi h MySQL.
We ha e decided o un he whole web applica ion in he po 8085, he e o e, a oid-
ing he de aul po , 8080, and he possible po con lic s ha usually i causes. As
well he communica ion wi h he MySQL da abase is ca ied on h ough he po
3306.
Chap e 6
Me ada a Managemen
This chap e p o ides he implemen a ion de ail o he mic ose ice in cha ge o man-
aging he me ada a o he p o ided ile. As discussed in p e ious chap e s, you can de elop
as many mic ose ices as you wan o manage
6.1. Implemen a ion de ails
The mic ose ice has been de eloped in Ja a (7) wi h he main echnologies men ioned
abo e. I p o ides wo esou ces ha will be consumed om he ou side, in his case om
he b owse ex ension.
The esou ces de eloped in he applica ion a e as ollows:
Viewing me ada a om a p oposed ile
Remo e me ada a om a p o ided ile
6.1.1. Viewing me ada a om a p oposed ile
POST se ice wi h he ollowing cha ac e is ics:
Name: /me ada os/mos a
Con en -Type: mul ipa / o m-da a
P oduces: aplica ion/json
The se ice ecei es he ile as a pa ame e , and e u ns he co esponding me ada a.
@Reques Mapping ( alue="/me ada os / mos a " , me hod = Reques Me hod .POST,
consumes = " mul ipa / o m−da a " , p oduces ="a ppl i c a i o n / json ")
public ResponseEn i y<S ing >
31
32 Chap e 6. Me ada a Managemen
lee Me ada os ( @Reques Pa am (" i l e ") Mul ipa File i l e ) h ows
Excep ion
{
e u n new ResponseEn i y <>(mos a Me ada os ( i l e ) ,
H pS a us .OK) ;
}
p i a e S ing mos a Me ada os ( Mul i pa File i l e ) h ows Excep ion
{
File mul ToFile =con e ToFile ( i l e ) ;
Map<Tag , S ing > me a =p ocess ( mul ToFile , n ull ) ;
Map<Tag , S ing > me aNue o = new HashMap<>() ;
o (Map. En y<Tag , S ing > en y : me a . en ySe ( ) ) {
i ( en y . ge Value () != null && ! en y . ge Value () . isEmp y ()
| | ! en y . ge Value () . equals ("0") )
{
Sys em . ou . p i n l n (" cla e=" + en y . ge Key ( ) + " ,
alo =" + en y . ge Value () ) ;
me aNue o . pu ( en y . ge Key () , en y . ge Value ( ) ) ;
}
}
Objec Mappe objec Mappe = new Objec Mappe ( ) ;
S i ng me ada os = objec Mappe . w i eValueAsS ing ( me aNue o ) ;
e u n me ada os ;
}
Line 6: The mos a Me ada os me hod, a e con e ing he ile using he con e ToFile
me hod, he p ocess me hod is in oked which que ies he me ada a. Finally, only he
me ada a ags ha ha e a alue o he han null will be shown.
Line 9: The con e ToFile me hod ecei e as pa ame e he ile in Mul ipa / o m-da a
o ma and e u ns he ile in File o ma o i s la e ea men in he subsequen p o-
cesses.
The p ocess me hod is he ans e sal p ocess, bo h o he consul a ion se ice and
o he dele ion se ice. In his me hod, he Exi ool lib a y is used, p o iding he
in e ace o me hod managemen .
public s a i c Map<Tag , S ing> p ocess ( F il e image , Map<Tag , S ing>
me a )
h ows Excep ion {
y {
Exi Tool e xi To ol = new Exi ToolBuilde () . build () ;
i ( me a!= n u l l ) {
e xi Too l . se ImageMe a ( image , me a ) ;
}
Map<Tag , S ing > me ada os = new HashMap<Tag , S ing >() ;
me ada os =exi Tool . ge ImageMe a ( image , a sL is (
S anda dTag .ISO,
S anda dTag .APERTURE,
S anda dTag .WHITE_BALANCE,
S anda dTag .CONTRAST,
7.2. Guille mo’s con ibu ions 39
YouTube called "P og amming om A o Z" by Daniel Shi man (known as "The coding
ain" on YouTube) (59) whe e he lea ned how o make his i s b owse ex ensions.
To p ac ice, he de eloped se e al a ied ex ensions o assimila e he concep s seen in
he online cou se. The i s es wi h ex ensions was a Ch ome b owse ex ension ha
pops up wi h he ph ase "Hello Wo ld!" when you click on he ex ension icon. Nex , he
de eloped an ex ension ha changes all he images on a websi e in o ki en pho os. Finally,
he made an ex ension ha had a window ha an image would appea when ac i a ing he
icon o he ex ension.
Once he basic concep s o ex ensions we e assimila ed, he began wi h he esea ch on
web eques API (16) which will be used du ing he de elopmen o he en i e p ojec .
The objec i e a he beginning was o p in in he console all he eques s o e e y e en
a ailable in he API (mo e in o ma ion a ailable in he Chap e 4) and compa e hem
wi h he eques s o he b owse s de elope mode (F12 mode). The i s a emp wo king
wi h hese ou going eques s was o make an HTML se e whe e only one ile could be
uploaded. A he same ime, he same es s would be done on Google D i e, since i is
a mo e ealis ic scena io o he use o his ex ension. Mos o he ime in es ed in his
pa o he p ojec was spen sea ching o in o ma ion on eques s and in o ma ion on he
web eques API. No in o ma ion was ound on how o ex ac he iles uploaded om
eques s in HTML o ms, so om ha momen , he in es iga ion was done en i ely on
Google D i e since he e was in o ma ion abou he eques s ha con ained uploaded iles.
The ollowing mon h was dedica ed o he p ocessing o he da a om he eques .
This p ocess was slowe since on hose da es mo e ime was needed o ca y ou asks om
o he subjec s. To alida e ha he image was being p ocessed co ec ly, he base64
code ob ained was es ed on a page (37) whe e i con e s he base64 code in o a isible
image. Many es s we e necessa y since he in o ma ion on hese eques s was no ound
un il se e al es s la e , ailing some o hose a emp s. The p ocessing o his da a in ol ed
many modi ica ions ega ding he in o ma ion ob ained om he eques , such as di iding
i in o in o ma ion sec ions o disca d unnecessa y in o ma ion, decode, encode, e c. Each
o hese ope a ions equi es a ew days o ob ain in o ma ion and p o e ha hey wo k
indi idually.
The nex miles one co esponding o Guille mo’s wo k was o connec all he com-
ponen s o he p ojec , ha is, he o ches a o and a cleaning mic ose ice. To lea n
abou making connec ions wi h o he se ices, a es ex ension was i s c ea ed and hen
i was in eg a ed in o he p ojec ’s ex ension code. This es consis ed o sending in o -
ma ion o he o ches a o ha was w i en wi h XMLH pReques and seeing i he
da abase was modi ied. This op ion a he beginning was no iable because wo king wi h
XMLH pReques (45) was con using and was changed by he e ch API (41) which
simpli ied he code and he connec ion wi h he o ches a o was a success om he i s
a emp . This i s connec ion o he o ches a o ook abou wo days o wo k. The i s
connec ion o he cleaning mic ose ice ook app oxima ely one week o wo k. This is due
o he o ma incompa ibili ies ha we e sen by he ex ension since hey did no coincide
wi h he mic ose ice. Guille mo also had o know he echnologies used o each compo-
nen o he p ojec o be able o make he necessa y adjus men s so ha e e y hing could
i oge he . To do his, he had o wa ch ideos on he in e ne abou he basic knowledge
o Sp ingboo since i was unknown o him. Rega ding he da abase, he downloaded and
lea ned o use My Wo kbench SQL, which is connec ed o he o ches a o .
40 Chap e 7. Con ibu ion
Once all he componen s a e wo king a he same ime, he nex s ep o he de elop-
men o he applica ion would be o cancel he eques whe e he p ocessed ile is ound.
I ook se e al weeks o pa allel wo k wi h o he asks o he ex ension o in es iga e on
canceling his ype o eques s since he i s es s ca ied ou we e all unsuccess ul. This
unc ionali y would no be pe ec ly implemen ed because he e is no in o ma ion abou i
in o icial manuals and an al e na i e solu ion had o be chosen.
Ano he o he asks ha he has ied o sol e is being able o use he ex ension on
e e y web page. This ook 2-3 weeks wi hou any esul s, as he web eques API did no
o e enough in o ma ion. I was no possible o know all he sec ions whe e he e can be
a ile. This was a ailu e, so, oge he wi h he p ojec de elopmen eam, hey decided o
limi he unc ionali y o he p ojec o Google se ices (such as Google D i e, Gmail, e c.).
This op ion was s ill no easible gi en ha no clea in o ma ion abou ile upload eques s
could be ound in he o he Google se ices, so he eam decided o limi he p ojec o
Google D i e only, and hen, as u u e wo k, i could be implemen ed in di e en pla o ms
o web pages.
The las wo weeks o de elopmen we e spen on op imizing ce ain pa s o he code
and co ec ing e o s. No many e o s we e ound bu enough es s we e ca ied ou o
e i y i s co ec ope a ion. Changes we e also necessa y o he pa o he code ha
p ocesses he eques in o ma ion o i s p ope unc ioning.
7.3. Rosa’s con ibu ions
This chap e desc ibes he con ibu ions ha Rosa Oli ia Zumae a Sánchez made o
he p ojec . Those con ibu ions a e classi ied in he di e en s ages ha he de elopmen
o he p ocess wen h ough.
7.3.1. S age 1: Realiza ion o a es b owse ex ension
The ini ial objec i e we se was o ob ain enough knowledge abou he de elopmen
o b owse ex ension and how do hey wo k. Since we did no ha e his knowledge, we
dedica ed he i s weeks o lea n abou b owse ex ension, doing some es s like displaying
an icon in he b owse . A his poin , he i s p oblem a ose om he e sion o he
mani es . This was because he la es e sion o Ch ome had changed he ield mani es -
e sion, ha now mus be included wi h alue wo. A e inding he co ec alue, he
b owse ex ension icon could be displayed and isualized in Ch ome.
A e ha ini ial es , he nex objec i e was o o e mo e unc ionali ies o he b owse
ex ension. We wo ked o display a ile selec o , so he use could selec a ile, and hen
he p ope ies o da a o he ile would be displayed. A his poin , i was a ma e o
assigning JS and HTML iles o he ini ial b owse ex ension. A e se e al in es iga ions
o di e en po als, he changes desc ibed we e made.
Ini ially, he code was in Ja asc ip and HTML, al hough he inal idea was o use
jQue y o Angula JS. To end wi h his s age, we made a small POC, using a FileReade
o display he da a o a ile selec ed om a Ch ome ex ension.
7.3. Rosa’s con ibu ions 41
7.3.2. S age 2: B owse ex ension s udy
Du ing his s age, ou goal was o check o which b owse s we could de elop he p ojec .
Fo p ac ical pu poses, we hough ha Ch ome and Mozilla we e g ea candida es since
hey use he same p ocedu es o implemen he b owse ex ensions.
7.3.3. S age 3: Feasibili y o he p oposed b owse ex ension
Fo his s age, each membe o he eam was assigned a ask. Rosa, in pa icula , was
in cha ge o de eloping a mic ose ice ha could manage he me ada a o a ile.
When she s a ed wi h he de elopmen she ound di icul ies wi h he ins alla ion.
Using Eclipse as he IDE o wo k wi h Sp ing Boo , gene a ed lo s o e o s un il she was
able o inally s a ed Eclipse co ec ly. She was able o accomplish ha a e con igu ing
he lib a ies and p ope ies needed o he inclusion o he dependency wi h Sp ing Boo .
Du ing his esea ch p ocess, she obse ed ha a speci ic IDE, o example, Sp ing Tool
Sui e (STS), could ha e been a be e choice o his ask. STS is an Eclipse-based IDE
wi h Sp ing Boo in eg a ed on i , o e ing he de elope o ge away om con igu a ion
issues, including he con igu a ions needed o de elop mic ose ices.
A e ha ing an en i onmen wo king on a Hello wo ld, he nex she aced was o s a
wi h he de elopmen o he me ada a consul a ion se ice. Ini ially, he me ada a que y
was done comple ely by Rosa, wi hou using any lib a y. This ini ial p og am was he one
she uses o he p oo -o -concep she had wi h he es o he eam. Bu when she ied o
de elop a se ice o emo e he me ada a om he ile (a ask ha in ol ed se e al es s)
he possibili y o using a lib a y was conside ed due o he di icul y o he ask.
To con inue wi h he emo al o he me ada a, she decided o ocus on inding a lib a y
ha p o ided image me ada a managemen , inding he lib a y she inally decided o use,
Exi ool. The ins alla ion o he lib a y did no wo k p ope ly he i s ime since she did
no pay a en ion o he execu able ile equi ed he ins alla ion, using only he p e iously
commen ed dependency.
Once he lib a y was p ope ly ins alled, and a e de eloping and es ing he unc-
ionali y o emo e me ada a, he las s ep was o in oke om a clien he se ices o
consul ing and dele ing me ada a. She ound ha he con en - ype o sending images is
mul ipa / o m-da a, and he e o e was needed o implemen a es clien , based on an
HTML ha allowed he selec ion o an image ile.
The ac ion was modi ied o in oke he me ada a que y o me ada a dele ion se ice as
app op ia e. Du ing he es ing phase, she no ed ha he se ice que ied all he me ada a
ields p esen on he ile, e en i hose ields did no ha e any in o ma ion, e u ning mos
o he ime a lo o emp y da a because o hose ields. To sol e his she had o ecode he
p og am o make i e u n only hose ields which had in o ma ion.
Some hing simila ly happened o he me ada a e ased. The que y dele ed all me ada a
ags, e en hose ags ha we e no p esen in ha ype o ile, so she modi ied i o only
dele e hose me ada a ags which had alue.
42 Chap e 7. Con ibu ion
Du ing he in eg a ion es s, he eam obse ed ha he ile ha was e u ned by he
mic ose ice when he me ada a was dele ed was no suppo ed by he b owse ex ension
de eloped by Guille mo because he b owse ex ension expec ed he ile as an a ay o
by es. To sol e his Rosa made a change in he way he esou ce was being sen so i
ma ched he expec ed o ma .
A e he de elopmen o he mic ose ice and he ixing, he complica ions eme ged
du ing he in eg a ion, he memo y is w i en.
7.3.4. S age 4: Memo y epo
In his pa , Rosa’s con ibu ion ocused on he ollowing: The in oduc ion o he
epo , he chap e in which Rosa’s con ibu ions o he eam we e de ailed, he chap e
co esponding o he implemen a ion o he mic ose ice ha manages he me ada a o
a ile, and along wi h he o he membe s o he eam he conclusions she ob ained while
wo king on his p ojec .
Chap e 8
Conclusions
In gene al e ms we a e qui e happy wi h he esul s o he p ojec , as is qui e simila
o hose we planned a he beginning o he de olopmen . Bu we should men ion he g ea
amoun o complica ions we aced du ing he e oluion o i . Mos o hem occasioned by
he ex ension, as explained in Chap e 4.
Wha we ha e accomplished is a comple ely unc ional applica ion which de ec s he
Google D i e eques s, o e ing he use he possibili y o cleaning he me ada a o he
uploaded iles i hese a e among he o ma s we suppo .
A he momen he applica ion suppo s image o ma s such as JPEG, PNG, GIF, e c.
Bu being designed as a mic ose ices-based a chi ec u e, adding new o ma s would no
be a p oblem, since he e is no need o modi y code in he di e en componen s o he
sys em. I is ex ensible o all he desi ed o ma s and o any a ailable pla o m, being
able o c ea e each mic ose ice in a di e en echnology o p og amming languages.
Ano he hing we alue e y posi i ely is he chance we ha e had o use mode n ech-
nologies, which a e widely used in he indus y bu no so in he academic wo ld. Examples
o hese a e Sp ing Boo , Ja aSc ip , mic ose ices a chi ec u e, o he use o ex e nal li-
b a ies such as JPA o Sp ing Boo s a e web.
A conside able pa o he ime we in es ed in his p ojec was di ec ed o in es iga ion
and disco e i di e en ideas we e easible o no . Ha ing ou wo k in his p ojec as a base,
we belie e he e is a g ea po en ial o include new unc ionali ies making he "b owse
plug-in o me ada a emo al" mo e use ul.
8.1. Fu u e wo k
The main a eas whe e his p ojec could be ex ended, wi h no much wo ked needed
and making i a mo e comple e p oduc woule be:
43
44 Chap e 8. Conclusions
8.1.1. Ex end he unc ionali y o mo e o ma s
Wha we eg e he mos was no being able o ex end he unc ionali y we buil o
wo k wi h o he me ada a o ma s bu images. As we we e h ee componen s in he g oup,
one was ocused on he o ches a o , o he on he ex ension and jus one pe son was dealing
wi h he o ma s. Ou ini ial idea a he ea ly s ages o he p ojec de elopmen was o be
able o ea he me ada a in o ma s like:
PDF.
OpenDocumen mainly .od ,.ods and .odp.
The mos popula Mic oso O ice o ma s like .docx,.xlsx and .pp .
Some ideo o ma s like .mp4 o .a i.
This was a e y op imis ic app oach, because each o hem would equi e om a di -
e en mic ose ice, as each o ma will ha e di e en unc ions o lib a ies o deal wi h
he co esponding me ada a. None heless aking ad an age ha he ex ension and he
o ches a o a e comple ely de eloped, u u e wo k will be only equi ed on his side o he
p ojec . Using amewo ks like he ones we ha e al eady used as Sp ingboo will speed up
his de elopmen . As well as ha ing al eady a wo king mic ose ice like he one we de el-
oped o deal wi h images, is a g ea e e ence. The e o e, inding he he p ope lib a y o
deal wi h he me ada a o he new o ma is he key o any u u e expansion o he p ojec .
All hose sugges ions we e p o ed while he de elopmen o he mic ose ice we made
o deal wi h he PDF. This ea u e is no included in he p ojec as was no comple ed, bu
we we e close being able o modi y he me ada a om PDF documen s on he ile sys em,
as is explained in de ail in Chap e 7.3.4.
8.1.2. Ex ension
As de ailed in he Chap e 4 he ex ension has had nume ous e o s ha could no be
sol ed due o p oblems wi h he API o insu icien in o ma ion. The ask ha should be
imp o ed he mos in he u u e is o ex end he ex ension o e e y possible web page ha
has o ile uploads. This can be implemen ed as he webReques API imp o es, o e ing
mo e in o ma ion on eques s so ha iles ha a e no in he body o he eques can be
accessed by he ex ension.
Ano he possible imp o emen o he p ojec is he cancella ion o eques s when he
use decides no o upload he ile o be cleaned. In he cu en s a e o he p ojec i has
no been implemen ed in an op imal way, so he use has o do some mo e in e ac ion wi h
he ex ension han expec ed. This can be imp o ed as he API imp o es o he upload
eques s a e s anda dized so ha i is he same o all web pages.
Finally, he ex ension is only a ailable o he Ch ome b owse and Fi e ox, so i would
be necessa y o ew i e some unc ions o make hem compa ible wi h o he b owse s o
o e he same ex ension in o he b owse s sepa a ely.
8.1. Fu u e wo k 45
8.1.3. Mo e o om local o online
The p ojec is cu en ly wo king locally, ha is, he o ches a o and cleaning mic ose -
ices a e ins alled on he use ’s compu e and wo king a he same ime. Ha ing he en i e
p ojec locally is necessa y o i s p ope de elopmen since i allows es ing wi h he o he
componen s o he p ojec , bu i is no a solu ion o i s use wi h eal use s. The e o e,
he se ices ha make up he ex ension (see Chap e 2.7) mus be uploaded o In e ne
se e s. This allows you o ha e as many cleaning mic ose ices as you wan a di e en
URLs, no i ying he o ches a o whe e hose mic ose ices a e loca ed. The use does no
need o s a he cleaning mic ose ices o he en i e sys em o unc ion, allowing only he
use o in e ac wi h he ex ension. In addi ion o he CPU load ha hese mic ose ices
could be using, i sa es ha ing o download and excu e hese componen s.
8.1.4. Ex end his se ice o o he pla o ms
We app oach his p ojec wi h he idea o making he p ojec wo king wi h he leas
in e ac ion om he use as possible. Tha was he eason we used he b owse ex ension
as he componen which looks o ou going HTTP connec ions. In ha sense, an ex ension
is an ideal ool, bu he mic ose ices we de eloped could wo k in e y di e en ames.
One o he ad an ages o he mic ose ice a chi ec u e is he independence hey ha e om
o he componen s o he sys em, as is explained in Chap e 1.2.
This independence makes hem g ea ly eusable, as o how hey communica e is h ough
API calls, hey could be called om e y di e en pla o ms. Fo example, i we de elop
a desk op applica ion, he only code ha would be equi ed will be he one necessa y
o de elop a use in e ace and he calls o ou mic ose ices. Same could be applied o
a mobile app, as mos o he communica ions people ha e nowadays is h ough mobile
phones, his is a e y in e es ing u u e wo k. Once again all he pa which deals wi h
bo h he use and he lea ing pe i ions wi h a ile a ached will need o be code, bu once
ha is done, he ea men o he me ada a could be done in ou mic ose ices
One las pla o m is o de elop a comple e websi e ins ead o an ex ension. This could
be use ul i we wan ed o ha e g ea e in e ac ion wi h he use , as in he ex ension his
is limi ed o he small window i uses. Once again all he mic ose ices and he ad ances
achie ed in his p ojec could we eused o i .
Bibliog aphy
[1] Baeldung websi e. h ps://www.baeldung.com/.
[2] A con olle , se ice and dao. h ps://www.baeldung.com/
js -sp ing-boo -con olle -se ice-dao.
[3] Disco e i ex pd . h ps://i ex pd .com/.
[4] Exi ool by phil ha ey. h ps://exi ool.o g/.
[5] Ins alling sp ing boo . "h ps://docs.sp ing.io/
au o epo/docs/sp ing-boo /1.0.0.RC5/ e e ence/h ml/
ge ing-s a ed-ins alling-sp ing-boo .h ml".
[6] Lea n apache ma en build au oma ion ool. h ps://www. u o ialspoin .
com/ma en/ma en_o e iew.h m.
[7] O icial web o ja a. h ps://www.ja a.com/es/download/ aq/ja a8.xml.
[8] Se ing up swagge 2 wi h a sp ing es api. h ps://www.baeldung.com/
swagge -2-documen a ion- o -sp ing- es -api.
[9] Sp ing boo wi h sqli e. h ps://www.baeldung.com/sp ing-boo -sqli e.
[10] Sp ing ools o eclipse ide. h ps://www.eclipse.o g/communi y/eclipse_
newsle e /2018/ eb ua y/sp ingboo .php.
[11] Wha is me ada a? h ps://www.li ewi e.com/
me ada a-de ini ion-and-examples-1019177.
[12] Ch ome no i ica ions de elope guide. h ps://de elope .ch ome.com/apps/
no i ica ions, (accessed June 12, 2020).
[13] Sp ing da a jpa. h ps://sp ing.io/p ojec s/sp ing-da a-jpa, (accessed
June 12, 2020).
[14] Wha a e mic ose ices? h ps://aws.amazon.com/es/mic ose ices/,
(accessed June 12, 2020).
[15] R c1341(mime) : 7 he mul ipa con en ype. h ps://www.w3.o g/
P o ocols/ c1341/7_2_Mul ipa .h ml, (accessed June 5, 2020).
47
48 BIBLIOGRAPHY
[16] Web eques api documen a ion websi e. h ps://de elope .ch ome.com/
ex ensions/webReques , (accessed June 5, 2020).
[17] Ch ome api o downloading iles. h ps://de elope .ch ome.com/
ex ensions/downloads, (accessed June 9, 2020).
[18] Gi hu 2.0 a small place o disco e languages in gi hub. h ps://madnigh .
gi hub.io/gi hu /#/pull_ eques s/2020/1, Ap il 12, 2019 (accessed June
10, 2020).
[19] Mos popula google ch ome b owse ex ensions e e . h p://www.skipse .com/
p/2/p/mos -popula -ch ome-ex ensions.h ml, Ap il 12, 2019 (accessed
June 10, 2020).
[20] Why wha sapp (and eleg am) messages a e no eally p i-
a e? h ps://www.and ea o una.o g/2019/08/12/
why-wha sapp-and- eleg am-messages-a e-no - eally-p i a e/,
Ap il 12, 2019 (accessed June 10, 2020).
[21] Phishing a ack. h ps://www.ada sus.com/phishing-que-es/, Ap il 12,
2019 (accessed June 8, 2020).
[22] Sp ing amewo k - sp ing. h ps://sp ing.io/p ojec s/
sp ing- amewo k, Ap il 12, 2019 (accessed June 8, 2020).
[23] Me ada a analyze - ele enpa hs. h ps://www.ele enpa hs.com/es/
labs ools/me ashield-analyze /index.h ml, Ap il 2, 2019 (accessed June
12, 2020).
[24] Accessing da a wi h mysql. h ps://sp ing.io/guides/gs/
accessing-da a-mysql/, Ap il 22, 2019 (accessed May 10, 2020).
[25] Accessing da a wi h mysql. h ps://sp ing.io/guides/gs/
accessing-da a-jpa/, Ap il 22, 2019 (accessed May 12, 2020).
[26] Res api u o ial. h ps:// es ulapi.ne /, Ap il 22, 2019 (accessed May 12,
2020).
[27] Wha is jpa? in oduc ion o he ja a pe sis ence
api. h ps://www.in owo ld.com/a icle/3379043/
wha -is-jpa-in oduc ion- o- he-ja a-pe sis ence-api.h ml,
Ap il 22, 2019 (accessed May 12, 2020).
[28] Exi 2. c++ me ada a lib a y and ools. h ps://www.exi 2.o g/index.h ml,
Ap il 3, 2019 (accessed June 10, 2020).
[29] Pd me ada a edi o . h p://b oken-by.me/pd -me ada a-edi o /, Ap il
3, 2019 (accessed June 10, 2020).
[30] Ba chpu i ie . ba ch mul i- o ma hidden da a & me ada a emo al so wa e ool
o windows. h p://www.digi alcon idence.com/ba chpu i ie .h ml,
Ap il 3, 2019 (accessed June 13, 2020).
[31] Je ey’s image me ada a iewe . h p://exi . egex.in o/exi .cgi, Ap il 3,
2019 (accessed June 13, 2020).