July 11, 2008

subversion problem: svn: Can't move 'xyz/.svn/tmp/entries' to 'xyz/.svn/entries': Operation not permitted

    svn: Can't move 'xyz/.svn/tmp/entries' to 'xyz/.svn/entries': Operation not permitted

Diese Fehler sprang mir grade entgegen, nachdem ich mal wieder ein svn up machen wollte.
Nach genauerer Betrachtung, stellte ich dann fest, dass xyz/.svn/entries nur Lesesrechte hat.

Ein
    sudo chmod 777 xyz/.svn/entries
half leider auch nichts:
    chmod: ./xyz/.svn/entries: Operation not permitted

Das fand ich dann schon ziemlich dreist irgendwie :-D.
Letztendlich half mir ein:


    cp xyz/.svn/entries xyz/.svn/entries2
    sudo rm xyz/.svn/entries
    cp xyz/.svn/entries2 xyz/.svn/entries
    sudo chmod 777  xyz
/.svn/entries


Was zwar auf dem ersten Blick ein wenig aufwendig erscheint, aber in Form eines shell-scriptes angenehm die Arbeit übernimmt.
Allerdings weiß ich jetzt immer noch nicht WARUM dieser Fehler kommt.

Letztendlich habe ich mich ja daran gewöhnt, dass subversion meint, . hätte ein Lock....
Wenn mir da jemand mal erklären könnte, ob ich da was falsch mache oder wie... das fände ich mal toll :-).


Blogged with the Flock Browser

July 1, 2008

Multicast - genauer Nachgeschaut

Da das ja heute bei der Tafelrunde eher etwas zusammengesucht war, habe ich mich noch mal hingesetzt und mir die Dinge an-/eingelesen.
Ich werde einfach mal versuchen die Fragen, die da aufkamen wiederzugeben und dann mit passenden Texten beantworten:


  1. Was ist Multicast?
    Multicast ist eine Nachrichtenübertragung von einem Punkt zu einer Gruppe von Empfängern (auch Mehrpunktverbindung genannt).
    Daneben gibt es noch weitere Arten von Übertragungen:
    • Unicast: eine Punkt-zu-Punkt-Verbindung (klassische Client<->Server Verbindung)
    • Broadcast- und die Anycast-Übertragung ("ich bin da - wer noch?" - ping an x.x.x.255)
    • Geocast, ein besonderer Multicast, der räumlich begrenzt ist.

  2. Was sind die Vorteile von Multicast gegenüber Unicast?
    Es sind gleichzeitige Nachrichten an mehrere Teilnehmer möglich, ohne dass sich die Bandbreite des Senders verändert (für den Sender ist es als würde man eine Nachricht an einen Empfänger senden).
    Handelt es sich um paketorientierte Datenübertragung, findet die Vervielfältigung der Pakete an jedem Verteiler (Switch, Router) auf der Route statt.

  3. Wie geht das nun genau?
    Multicast ist die übliche Bezeichnung für IP-Multicast, das es ermöglicht, in IP-Netzwerken effizient Daten an viele Empfänger zur gleichen Zeit zu senden. Das passiert mit einer speziellen Multicast-Adresse. In IPv4 ist hierfür der Adress-Bereich 224.0.0.0 bis 239.255.255.255 (Klasse D), in IPv6 jede mit FF00::/8 beginnende Adresse reserviert.
    Bei der Übertragung über Ethernet werden die IPv4- bzw. IPv6-Multicastadressen auf bestimmte Pseudo-MAC-Adressen abgebildet, um bereits durch die Netzwerkkarte eine Filterung nach relevantem Traffic zu ermöglichen.

  4. Okaaaaay.... Wer macht sowas? Ist sowas nützlich?
    Ja ist es. Bekannte Anwendungen sind:
    • Audio- und Videoübertragungen (Protokolle wie RTP)
    • Verwendung beim Clustering und beim Routing nach dem Routing Information Protocol (RIP) Version 2.
    • ist für ein funktionierendes AppleTalk-Netzwerk notwendig.
    • Als Service Location Protocol und Multicast DNS wird als Teilimplementierung von Zeroconf Multicast (Rendezvous - inzwischen Bonjour) betrieben
      • automatische Zuweisung von IP-Adressen ohne DHCP-Server
      • übersetzen von Hostnamen in IP-Adressen ohne DNS-Server
      • automatisches Finden von Diensten im lokalen Netzwerk ohne einen zentralen Directory-Server
    • In Windows wird es im Simple Service Discovery Protocol benutzt
    • Weitere Multicast-Protokolle
      • Internet Relay Chat (IRC) bildet Netzwerke, welche einen einfachen TCP-basierten Multicast-Baum realisieren - wer hätte das gedacht ^^
      • Es wird überlegt in Jabber Multicast nach zurüsten.

  5. Und das geht jetzt auch über das Internet oder wie jetzt?
    Jein... also:
    Multicast-Pakete werden von den meisten Routern im Internet nicht verarbeitet. Deswegen werden multicastfähige Teilnetze über Tunnel zu Multicast Backbones (MBones) verbunden.
    Um Multicast-Pakete zwischen mehreren Netzen zu koordinieren, werden spezielle Multicast-Routing-Protokolle verwendet.

  6. Ahja... sehr schön - kann da nix passieren / durcheinander kommen?
    Es existieren bei der Verwendung bestimmter Adressbereiche einiger Switches Probleme bei der Weiterleitung von Multicastnachrichten.
    Die Adressen von 224.0.0.0 bis 224.255.255.255 sind für Routingprotokolle reserviert und für diese Adressen sendet der Router keine IP-Multicast-Datagramme. Die Adressen von 239.0.0.0 bis 239.255.255.255 sind für scoping reserviert, eine Weiterleitung innerhalb dieses Adressbereichs ist ebenfalls Switch abhängig. Adressen im Bereich 225.x.x.x bis 238.x.x.x sind frei verfügbar.

  7. Nachwort:
    Multicasting wird wieder populär, weil IPTV darauf basiert.
    Für verteilte Chat-Netzwerke wurde mittlerweile allgemein eingesehen, dass sie nicht mittels IP-Multicast realisiert werden können.
    Der Einsatz weiterer Multicast-Protokolle ist daher unumgänglich.  Na da haben wirs!


Schamlos kopiert von http://de.wikipedia.org/wiki/Multicast - teiweise gekürtzt und ein wenig angepasst.
Die Formulierungen sind auf die frühe Stunde zurück zu führen.


Anschließend zur Entspannung noch ein wenig Java - ein einfacher Chat-Server:
Zuerst der "Server" - Der ja eigentlich auch Teil jedes Clients ist:

    public class NameServer{
        // the multicast group address sent to new members
        private static final String GROUP_HOST = "228.5.6.7";  
        private static final int PORT = 1234;      // for this server
        private static final int BUFSIZE = 1024;   // max size of a message
        private DatagramSocket serverSock;
   
        // holds the names of the current members of the multicast group
        private ArrayList groupMembers; 

        try {  // try to create a socket for the server
          serverSock = new DatagramSocket(PORT);
        }catch(SocketException se){
            System.out.println(se);
            System.exit(1);
        }
        groupMembers = new ArrayList();
        waitForPackets();
       
       // das ist dann hier wieder die typische Server-While-Schleifen-Methode
        private void waitForPackets(){
            DatagramPacket receivePacket;
            byte data[];
            System.out.println("Ready for client messages");
            try {
              while (true) {
                data = new byte[BUFSIZE];  // set up an empty packet
                receivePacket = new DatagramPacket(data, data.length);
                serverSock.receive( receivePacket );  // wait for a packet
       
                // extract client address, port, message
                InetAddress clientAddr = receivePacket.getAddress();
                int clientPort = receivePacket.getPort();
                String clientMsg = new String( receivePacket.getData(), 0, receivePacket.getLength() ).trim();
                processClient(clientMsg, clientAddr, clientPort);

              }
            }catch(IOException ioe){ 
                System.out.println(ioe); 
            }
        }
        ...
    }

Und hier dann noch mal der "Client"-Anteil:

    public class MultiChat {
   
      // timeout used when waiting in receive()
      private static final int TIME_OUT = 5000;   // 5 secs
     
      // max size of a message
      private static final int PACKET_SIZE = 1024;

      // NameServer address and port constants
      private static final String SERVER_HOST = "localhost";
      private static final int SERVER_PORT = 1234; 

      /* The multicast port. The multicast group address is
      obtained from the NameServer object. */
      private static final int GROUP_PORT = 5555; 

      // for communication with the NameServer
      private DatagramSocket clientSock;
      private InetAddress serverAddr; 

      // for communication with the multicast group
      private MulticastSocket groupSock;
      private InetAddress groupAddr;  

      public MultiChat(String nm){
         /* Attempt to register name and get multicast group
         address from the NameServer */
         makeClientSock();
         waitForPackets();

      } // end of MultiChat();
     
      private void makeClientSock(){
        try {   // try to create the client's socket
          clientSock = new DatagramSocket();
          clientSock.setSoTimeout(TIME_OUT);  // include a time-out
        }catch( SocketException se ) {
          se.printStackTrace();
          System.exit(1);
        } 

        try {  // NameServer address string --> IP no.
          serverAddr = InetAddress.getByName(SERVER_HOST);
        }catch( UnknownHostException uhe) {
          uhe.printStackTrace();
          System.exit(1);
        }
      }  // end of makeClientSock()
     
      private void waitForPackets(){
        DatagramPacket packet;
        byte data[];

        try {
          while (true) {
           data = new byte[PACKET_SIZE];    // set up an empty packet
            packet = new DatagramPacket(data, data.length);
            groupSock.receive(packet);  // wait for a packet
            processPacket(packet);
          }

        }catch(IOException ioe){ 
            System.out.println(ioe); 
            }
      }  // end of waitForPackets() 
    }


Wie man ziemlich gut erkennen kann, ist es auch nicht wesentlich anders, als wenn man sich direkt Sockets erstellt. Gefunden habe ich das Ganze in dem Buch "Killer Game Programming in Java" - heißt wirklich so - hin und wieder finden sich da wirklich interessante Dinge besprochen (Link: hier!).

So das wars.
Die Tage wollte ich noch mal bissel was zu OSGi schreiben - so denn das schöne Buch ankommt.
Und aus - leider aktuellem Anlass - zu IPMI und wieso es eigentlich schon fast unverschämt ist, dass ein _mitgelieferetes_ Linux-Tool fehlerhaft ist und deswegen vom Hersteller empfohlen wird, extra dafür ein Windows aufzusetzen. Nichts gegen Windows, aber wieso liefert man ein fehlerhaftes Tool dann mit?

P.S.: Schreibt mal wieder ;-)

Blogged with the Flock Browser

May 10, 2008

Splines mit dem HTML Canvas Tag

Splines innerhalb eines Canvas Tags sind mit ein wenig Javascript recht schnell machbar!

(drumherum dann noch den ganzen HTML-Kram denken):


<canvas width="150" height="150" id="myCanvas1"></canvas>

<script type="text/javascript">
function draw1(){
    var myCanvas1 = document.getElementById('myCanvas1');
    myCanvas1.style.border = "1px black dashed";   

    var ctx = myCanvas1.getContext('2d');
   
    ctx.beginPath();   
    ctx.strokeStyle = "#dedede";
    for (i=1;i<15;i++){
        ctx.moveTo(i*10,0);
        ctx.lineTo(i*10,150);
    }
    for(j=1;j<15;j++){
        ctx.moveTo(0,j*10);
        ctx.lineTo(150,j*10);
    }
    ctx.stroke();   

    //Steuerpunkte malen (nur zur Verdeutlichung)
    ctx.beginPath();
    ctx.lineWidth = 2;
    ctx.strokeStyle = "rgb(0,200,0)";
    ctx.moveTo(0,135);
    ctx.lineTo(60, 130);
    ctx.arc(60,130,3,0,360, false);
    ctx.lineTo(75,75);
    ctx.lineTo(90,20);
    ctx.arc(90,20,3,0,360, false);
    ctx.lineTo(150, 15);
    ctx.stroke();
   
    //quadraticCurveTo malen
    ctx.beginPath();
    ctx.strokeStyle = "#000000";
    ctx.moveTo(0,135);
    ctx.lineWidth = 4;
    ctx.quadraticCurveTo(60, 130, 75, 75);
    ctx.moveTo(75,75);
    ctx.quadraticCurveTo(90, 20, 150, 15);
    ctx.stroke();

}
draw1();
</script>


Das macht einem dann ein:


Das ganze funktioniert mit Firefox ab Version 1.5 (aber erst ab 2.x gehen auch quadratic Splines), Opera 9 und neueren Safaries.

Infos hier:
Wikipedia Canvas Tag
Mozilla Dev Page (sehr zu empfehlen)
whatwg.org - watt immer das ist.. steht auch n bissel was zu
Und zu guter Letzt DIE (besagte) Apple Dev Page

Die Seite von Apple ist angeblich nicht mehr gültig, aber es geht damit einwandfrei...
Die grünen Linien habe ich nur gemacht, damit man die Stützpunkte der Splines besser sehen kann.

Ach was war die CG-Vorlesung doch schön :D

Blogged with the Flock Browser

April 2, 2008

NetBeans IDE 6.1 Beta Blogging Contest

Preamble:

So i just decided to use the newst version of Netbeans (6.1 beta) to dive deeper into (Ruby on Rails) RoR. Currently i am basically a Developer, concentrated on Java. During my "Diplomarbeit" i was focused on JEE in interplay with YUI. To be honest, i had almost  no  encounters with RoR - beside from a project where i mainly was responsible for the HTML/Template work.

Before using Java, i was primary a PHP-Guy. So... yep there is already a big heritage to Script-Languages.


The cast:

the protagonist:    Philipp Haußleiter, me, myself and i. I just finished my study an have around a month free time.

featured parts:    
                            technical advice (i just hope this at least): Phillip Ghadir, Stefan Tilkov, Willem van Kerkhof, ... from innoQ
                            artistic advice (currently on travel): Michael Wolff from 3strom.de
                            beta testing crowd:   still on casting :-).
locations:              
                            somewhere in Germany
                            on a Macbook (2,16 Ghz/3GB)
                            with Mac OS 10.5.2 with Java 6 DP[1] and Netbeans 6.1 beta


The challenge:
     
 
If you plan to start developing in Ruby on Rails, there is always this - "Hello World"-Equivalent: writing a Web-Blog. So i think for me - as a beginner - it would be a good start. Of course i will try to bring in some special taste ;-). I am currently using Wordpress 2.5 for my private Blogging-experience. So bar is already  on a high level. So trying to beat WP, would be suicide. So in opposite to this, i will focus on just a few functions:

based on RoR with Ruby/JRuby - NB 6.1 seems to provide an easier change between both VMs
better Upload-Handling with search-functions
out-of-the-box anti-spam captchas[2]
JavaScript-enabled behaviour (yeah... Web 2.0 ^^) - also for testing the new JavaScript-functions in NB 6.1

So currently i figure out some Database-model and trying to get notified by Netbeans.org[3].

[1] http://developer.apple.com/java/download
[2] http://en.wikipedia.org/wiki/Captcha
[3] http://www.netbeans.org/competition/blog-contest-form.html
 

Blogged with the Flock Browser

Tags:

April 1, 2008

Idee! Lerne RoR! ... und da ist noch dieser NetBeans 6.1 Contest!

Ich habe mir fest vorgenommen mich in der freien Zeit ein wenig mehr mit RoR zu befassen.
Ich dache mir mit dem RoR-Pendant zu "Hello World" anzufangen und mich an das Erstellen einen Web-Blogs zu wagen. Natürlich hoffe ich mit den 08/15 Funktionen schnell durch zu sein - verspricht das RoR nicht auch? Ich habe ein paar grundsätzliche Dinge, die mir - selbst an der aktuellsten[1] - Wordpress Version aufstoßen:
  * Dem Kommentar-Spam lässt sich nur durch Plug-Ins Herr werden
  * Upload/Posten von Dateien ist immer noch ein Graus, auch wenn es mittlerweile WYSIWYG-Editoren gibt.

Movable-Type ist meiner Meinung auch eher funktional, als angenehm ;-).

Hierbei nutze ich nun testweise die neue Version von Netbeans, welche als 6.1 beta erhältlich ist.


Auf der Netbeans-Seite gibt es zudem eine Art Gewinnspiel, in dem man sein Blog angeben kann und dieses dann in eine Auswahl zu den besten Netbeans 6.1 Einführungen kommt [2]. Ist die Teilnahme an solchen "Maßnahmen" mit innoQ-Blogs eigentlich gestattet? Ansonsten müsste ich da auf mein eigenes Blog dann zurückgreifen.

Letztendlich ist mir heute auch schon ein Fehler aufgefallen:
Nutze ich die Java 6 Preview Version von Apple, bleiben einige Wizards hängen.
Dies ist bei Java- sowie Ruby-Anwendungen der Fall. Eine Lösung fand sich zum Glück auch schon[3].


[1] http://de.wordpress.org/wordpress-2.5-de_DE.zip
[2] http://www.netbeans.org/competition/blog-contest.html?cid=923686
[3] http://teera.seriyagroup.com/blog/index.php/2008/03/04/netbeans-6-and-mac-java-6-developer-preview-9-project-wizard-hangs-problem/

Blogged with the Flock Browser

March 28, 2008

the end?

Nach dem Countdown nach bin ich nun am -34. Tag.... :D. Wie dem auch sei. Ich bin durch, fertig - es ist vollbracht.... (hier folgende weitere ausschmückende Beschreibungen). Da ich eigentlich nun nix mehr zu schreiben hätte, könnte ich hier ein großes CLOSED Schield aufhängen. Aber ich denke, da ich den April off habe (ein wenig Urlaub machen und Ordnung machen und so...), werde ich vielleicht über ein paar Dinge schreiben, die mir so im Kopf rumschwirren, also Projekte, die ich irgendwann mal (in naher/ferner Zukunft) in Angriff nehmen möchte. Auch hier sind Kommentare natürlich herzlichst willkommen.

February 7, 2008

SSL erzwingen in einem Java Application Server

Morgen :-),

so langsam bin ich dabei alle meine Problem gelöst zu bekommen :-) - ja wird auch Zeit :-D.
Bezogen auf diesen (http://www.innoq.com/blog/phaus/2007/12/zum_jahresende.html) Post:

Ich bin an der Implementierung mit JAAS noch dran, allerdings habe ich herausgefunden, dass man dem Server einen Filter unterschieben kann, der bei jedem Aufruf überprüft, ob eine SSL Verbindung besteht, und wenn dies nicht der Fall ist, diese per Redirect erzwingt.
Das ganze funktioniert über Filter (wie es ja Ruby on Rails auch macht).

Man erstellt sich eine Klasse, welche javax.servlet.Filter implementiert.
Diese bindet man dann per web.xml ein:

    <filter>
        <filter-name>SSLFilter</filter-name>
        <filter-class>de.hausswolff.cotodo.security.SSLFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>SSLFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping> 

D.h. alle Anfragen, die an die Applikation gesendet werden, werden durch diesen Filter geschickt.
Der Filter im einzelnen vergleicht ob request.getScheme() == "https" ist. ansonsten redirected er einfach auf entsprechnede Seite.
In meinem Fall (da eine nicht-https Verbindung nur bei einem nicht angemeldeten Benutzer vorhanden ist auf eine Login-Seite)
Ich hoffe, dass ich morgen dann meine Anmeldung vervollständigen kann.

Für alle die sich noch näher mit den Feature von JEE 5 befassen wollen:
Unter http://java.sun.com/developer/releases/petstore/  kann man sich mit petstore eine Beispielanwendung herunterladen, die die Neuerungen (inkl. AJAX) demonstriert. Duke's Bank scheint demnach nicht mehr genutzt zu werden :-)

Blogged with Flock

February 3, 2008

mal wieder.... REST

Guten Morgen!
Weil ich grade darüber am schreiben bin, mal wieder was zum Thema:

How I Explained REST to My Wife

Wife: Who is Roy Fielding?

Ryan: Some guy. He's smart.

Wife: Oh? What did he do?

Ryan: He helped write the first web servers and then did a ton of research explaining why the web works the way it does. His name is on the specification for the protocol that is used to get pages from servers to your browser.

Wife: How does it work?

Ryan: The web?

Wife: Yeah.

Ryan: Hmm. Well, it's all pretty amazing really. And the funny thing is that it's all very undervalued. The protocol I was talking about, HTTP, it's capable of all sorts of neat stuff that people ignore for some reason.

Wife: You mean http like the beginning of what I type into the browser?

Ryan: Yeah. That first part tells the browser what protocol to use. That stuff you type in there is one of the most important breakthroughs in the history of computing.

Wife: Why?

Ryan: Because it is capable of describing the location of something anywhere in the world from anywhere in the world. It's the foundation of the web. You can think of it like GPS coordinates for knowledge and information.

Wife: For web pages?

Ryan: For anything really. That guy, Roy Fielding, he talks a lot about what those things point to in that research I was talking about. The web is built on an architectural style called REST. REST provides a definition of a resource, which is what those things point to.

Wife: A web page is a resource?

Ryan: Kind of. A web page is a representation of a resource. Resources are just concepts. URLs--those things that you type into the browser...

Wife: I know what a URL is..

Ryan: Oh, right. Those tell the browser that there's a concept somewhere. A browser can then go ask for a specific representation of the concept. Specifically, the browser asks for the web page representation of the concept.

Wife: What other kinds of representations are there?

Ryan: Actually, representations is one of these things that doesn't get used a lot. In most cases, a resource has only a single representation. But we're hoping that representations will be used more in the future because there's a bunch of new formats popping up all over the place.

Wife: Like what?

Ryan: Hmm. Well, there's this concept that people are calling Web Services. It means a lot of different things to a lot of different people but the basic concept is that machines could use the web just like people do.

Wife: Is this another robot thing?

Ryan: No, not really. I don't mean that machines will be sitting down at the desk and browsing the web. But computers can use those same protocols to send messages back and forth to each other. We've been doing that for a long time but none of the techniques we use today work well when you need to be able to talk to all of the machines in the entire world.

Wife: Why not?

Ryan: Because they weren't designed to be used like that. When Fielding and his buddies started building the web, being able to talk to any machine anywhere in the world was a primary concern. Most of the techniques we use at work to get computers to talk to each other didn't have those requirements. You just needed to talk to a small group of machines.

Wife: And now you need to talk to all the machines?

Ryan: Yes - and more. We need to be able to talk to all machines about all the stuff that's on all the other machines. So we need some way of having one machine tell another machine about a resource that might be on yet another machine.

Wife: What?

Ryan: Let's say you're talking to your sister and she wants to borrow the sweeper or something. But you don't have it - your Mom has it. So you tell your sister to get it from your Mom instead. This happens all the time in real life and it happens all the time when machines start talking too.

Wife: So how do the machines tell each other where things are?

Ryan: The URL, of course. If everything that machines need to talk about has a corresponding URL, you've created the machine equivalent of a noun. That you and I and the rest of the world have agreed on talking about nouns in a certain way is pretty important, eh?

Wife: Yeah.

Ryan: Machines don't have a universal noun - that's why they suck. Every programming language, database, or other kind of system has a different way of talking about nouns. That's why the URL is so important. It let's all of these systems tell each other about each other's nouns.

Wife: But when I'm looking at a web page, I don't think of it like that.

Ryan: Nobody does. Except Fielding and handful of other people. That's why machines still suck.

Wife: What about verbs and pronouns and adjectives?

Ryan: Funny you asked because that's another big aspect of REST. Well, verbs are anyway.

Wife: I was just joking.

Ryan: It was a funny joke but it's actually not a joke at all. Verbs are important. There's a powerful concept in programming and CS theory called polymorphism. That's a geeky way of saying that different nouns can have the same verb applied to them.

Wife: I don't get it.

Ryan: Well.. Look at the coffee table. What are the nouns? Cup, tray, newspaper, remote. Now, what are some things you can do to all of these things?

Wife: I don't get it...

Ryan: You can get them, right? You can pick them up. You can knock them over. You can burn them. You can apply those same exact verbs to any of the objects sitting there.

Wife: Okay... so?

Ryan: Well, that's important. What if instead of me being able to say to you, "get the cup," and "get the newspaper," and "get the remote"; what if instead we needed to come up with different verbs for each of the nouns? I couldn't use the word "get" universally, but instead had to think up a new word for each verb/noun combination.

Wife: Wow! That's weird.

Ryan: Yes, it is. Our brains are somehow smart enough to know that the same verbs can be applied to many different nouns. Some verbs are more specific than others and apply only to a small set of nouns. For instance, I can't drive a cup and I can't drink a car. But some verbs are almost universal like GET, PUT, and DELETE.

Wife: You can't DELETE a cup.

Ryan: Well, okay, but you can throw it away. That was another joke, right?

Wife: Yeah.

Ryan: So anyway, HTTP--this protocol Fielding and his friends created--is all about applying verbs to nouns. For instance, when you go to a web page, the browser does an HTTP GET on the URL you type in and back comes a web page.

Web pages usually have images, right? Those are separate resources. The web page just specifies the URLs to the images and the browser goes and does more HTTP GETs on them until all the resources are obtained and the web page is displayed. But the important thing here is that very different kinds of nouns can be treated the same. Whether the noun is an image, text, video, an mp3, a slideshow, whatever. I can GET all of those things the same way given a URL.

Wife: Sounds like GET is a pretty important verb.

Ryan: It is. Especially when you're using a web browser because browsers pretty much just GET stuff. They don't do a lot of other types of interaction with resources. This is a problem because it has led many people to assume that HTTP is just for GETing. But HTTP is actually a general purpose protocol for applying verbs to nouns.

Wife: Cool. But I still don't see how this changes anything. What kinds of nouns and verbs do you want?

Ryan: Well the nouns are there but not in the right format.

Think about when you're browsing around amazon.com looking for things to buy me for Christmas. Imagine each of the products as being nouns. Now, if they were available in a representation that a machine could understand, you could do a lot of neat things.

Wife: Why can't a machine understand a normal web page?

Ryan: Because web pages are designed to be understood by people. A machine doesn't care about layout and styling. Machines basically just need the data. Ideally, every URL would have a human readable and a machine readable representation. When a machine GETs the resource, it will ask for the machine readable one. When a browser GETs a resource for a human, it will ask for the human readable one.

Wife: So people would have to make machine formats for all their pages?

Ryan: If it were valuable.

Look, we've been talking about this with a lot of abstraction. How about we take a real example. You're a teacher - at school I bet you have a big computer system, or three or four computer systems more likely, that let you manage students: what classes they're in, what grades they're getting, emergency contacts, information about the books you teach out of, etc. If the systems are web-based, then there's probably a URL for each of the nouns involved here: student, teacher, class, book, room, etc. Right now, getting the URL through the browser gives you a web page. If there were a machine readable representation for each URL, then it would be trivial to latch new tools onto the system because all of that information would be consumable in a standard way. It would also make it quite a bit easier for each of the systems to talk to each other. Or, you could build a state or country-wide system that was able to talk to each of the individual school systems to collect testing scores. The possibilities are endless.

Each of the systems would get information from each other using a simple HTTP GET. If one system needs to add something to another system, it would use an HTTP POST. If a system wants to update something in another system, it uses an HTTP PUT. The only thing left to figure out is what the data should look like.

Wife: So this is what you and all the computer people are working on now? Deciding what the data should look like?

Ryan: Sadly, no. Instead, the large majority are busy writing layers of complex specifications for doing this stuff in a different way that isn't nearly as useful or eloquent. Nouns aren't universal and verbs aren't polymorphic. We're throwing out decades of real field usage and proven technique and starting over with something that looks a lot like other systems that have failed in the past. We're using HTTP but only because it helps us talk to our network and security people less. We're trading simplicity for flashy tools and wizards.

Wife: Why?

Ryan: I have no idea.

Wife: Why don't you say something?

Ryan: Maybe I will.


Quelle: Ryan Tomayko's Blog: How I Explained REST to My Wife

und hier mal ein Ausblick wie das ganze bei mir aussieht:

Blogged with Flock

January 30, 2008

OFFTOPIC: texten mit LaTeX

Es gibt 1001 Gründe, wieso ich jetzt etwas zu LaTeX unter MacOS schreibe.
Einer mag sein, dass ich grade - zufälligerweise - LaTeX intensiv nutze.
Ein weiterer, dass ich grade über einen ziemlich dummen Bug unter MacOS Leopard 10.5.1 gestoßen bin, der es einem (und vor allem grade MIR) unmöglich macht, mein schönes LaTeX-Dokument (nein ich sage NICHT was es ist) auszudrucken.
Siehe auch dazu: hier

Ach noch n Bug: Konnte man unter MacOS 10.4.x noch recht simpel mit
 ifconfig ethX lladdr
oder
 ifconfig ethX ether
noch relativ angenehm einfach die MAC Adresse seines Netdevices ändern, geht das seltsamerweise unter 10.5 nicht mehr. In den man-pages steht es aber noch. Ich benutze nun seit 10.3 n Mac und plötzlich kommen die Bugs :-/.

Noch mal zum Thema LaTeX:
Wer sich schon immer gefragt hat, wie man denn unter TexMaker oder TexShop eingetippte Umlaute in sein Latex-Dokument bekommt, der sollte es mal mit diesen Einstellungen versuchen:

 \usepackage[T1]{fontenc}
 \usepackage[applemac]{inputenc}
 \usepackage[ngerman]{babel}

Die tex-Datei sollte man dann bitte als MacOS-Latin1 abspeichern und nicht als UTF8. Gleiches gilt übrigens für alle Listing (Quellcode) Dateien.
Hat gedauert, bis ich darauf kam. Hatte die natürlich alle als UTF8 und in guter Manier alle Kommentare in Deutsch und mit Umlauten.


OFFOFFTOPIC:
Ich habe noch bissel Platz im Auto für Donnerstag. Wer noch ne Fahrgelegenheit braucht, kann sich ja einfach bei mir melden.

Ich teste jetzt noch ob der Acrobat Reader mein PDF will (und sowas unter MacOS) *grml*

Blogged with Flock

P.S.: ich vermisse irgendwie ein Wiki :-o

January 28, 2008

Upgrade - Downgrade - Löschen - Upgrade: Läuft

Mal wieder ne Stellungnahme:

Da ich u.a. eine Query machen möchte, ob zum Beispiel ein Benutzer mit einer bestimmten Email schon existiert, hatte ich bisher folgende URI zum Abfragen:

 http://localhost:8080/cotodo/resources/users/like/?cat=email&val=Test@test.com/

Das lief auch wunderbar. Wen es interessiert, der Code dazu schaut so aus:

    @HttpMethod("GET")
    @UriTemplate("like/")
    @ProduceMime({"application/xml", "application/json"})
    public UsersConverter getLikeQuery(
            @QueryParam("val") @DefaultValue("") String val,
            @QueryParam("cat") @DefaultValue("email") String cat ) {
          try {
            return new UsersConverter(getEntitiesLike(cat, val), context.getAbsolute());
        } finally {
            PersistenceService.getInstance().close();
        }
    }

Allerdings wäre eine schönere URI ala
 http://localhost:8080/cotodo/resources/users/email/like/philipp@haussleiter.de/
denkbar.

Ich habe mich dann heute mal hingesetzt, um auf eine neuere JSR311 Version (Version 0.5) zu updaten. Eigentlich sollte so allmählich die Final kommen, aber nungut, man weiß ja nicht was für Fehler noch kommen mögen.
Kurzum: Es hat sich einiger geändert. Ist wohl das Problem, wenn man mit nicht spezifizierten Packeten arbeitet :-).
Hier mal ein paar Änderungen:

@HttpMethod ist verkürzt worden:

aus @HttpMethod("GET") wird @GET, aus @HttpMethod("POST") wird @POST usw.

getAbsolute() heißt nun getAbsolutePath(), ansonsten sind mir keine Änderungen aufgefallen.

Der URI Builder (eine statische Klasse, um URIs zusammen zu bauen) wurde umbenannt - was meiner Meinung nach einleuchtender ist nun:
Aus:
 Builder.created(context.getAbsolute().resolve(entity.getUserId() + "/")).build();
wird nun:
 Response.created(context.getAbsolutePath().resolve(entity.getUserId() + "/")).build();

Da in beiden Fällen der Rückgabewert vom Typ Response ist, ist letzteres einleuchtender.

Mit der neuen Version 0.5 ändert sich obige Methode folgendermaßen:

    @GET
    @Path("{cat}/like/{val}/")
    //@UriTemplate("like/")
    @ProduceMime({"application/xml", "application/json"})
    public UsersConverter getLikeQuery(
            @UriParam("val") @DefaultValue("") String val,
            @UriParam("cat") @DefaultValue("email") String cat ) {
          try {
            return new UsersConverter(getEntitiesLike(cat, val), context.getAbsolutePath());
        } finally {
            PersistenceService.getInstance().close();
        }
    }

Und tut nun auch direkt was sie soll. Ein unschönes (weil sicherheitskritisches) Problem habe ich allerdings in der getEntitiesLike Methode:
Ich muss in den JPQL-Query-String die variabel cat direkt einfügen, über parameter scheint es nicht zu gehen (ist wohl wirklich nur für variable werte vorgesehen). Ich muss noch mal suchen, ob es eine Art SQL_escape methode gibt. Ich will ja nun keine SQL-Injektion hinauf beschwören.

Abschließen hat mich das Update einen guten Teil des Morgens gekostet.
Letztendlich war wohl eine Jar version von ASM (wird u.a. von maven2 benutzt, aber von glassfish benötigt) fehlerhaft.
Es kam andauernd:
 java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
Obwohl die Klasse definitiv im vorhandenen jar zu finden ist!

Letztendlich habe ich dann alle meine jars mal gelöscht und Schritt für Schritt neu hinzugefügt.
Es hat wohl tatsächlich etwas mit fehlerhaften Referencen zu tun. Das gleiche Problem triff wohl auch bei der Benutztung von Hibernate auf.

Heute Abend, oder morgen schreibe ich dann noch etwas dazu, wie ich ein skizziertes HTML Formular per JS DOM Anweisungen erstelle.
Braucht ein wenig Übung, ist aber sauberer und schneller als sich Strings zusammen zu bauen und außerdem bleibt einem in Hinsicht auf AJAX und callback functions eh nichts anderes übrig.

Blogged with Flock

July 2008

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Archives

Powered by
Movable Type 3.31