Ignore:
Timestamp:
Jul 12, 2012, 10:54:46 AM (12 years ago)
Author:
casties
Branch:
default
Message:

new internal actor class for creator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java

    r5 r9  
    55
    66import java.io.UnsupportedEncodingException;
    7 import java.net.URLDecoder;
    8 import java.net.URLEncoder;
    97import java.security.InvalidKeyException;
    108import java.security.SignatureException;
     
    3634import org.restlet.resource.ServerResource;
    3735
     36import de.mpiwg.itgroup.annotations.Actor;
    3837import de.mpiwg.itgroup.annotations.Annotation;
    3938import de.mpiwg.itgroup.annotations.Annotation.FragmentTypes;
     
    194193                // make short user id
    195194                String userId = annot.getCreatorUri();
     195                // remove namespace from user uri to get id
    196196                if (userId != null && userId.startsWith(NS.MPIWG_PERSONS_URL)) {
    197                     userId = userId.replace(NS.MPIWG_PERSONS_URL, ""); // entferne
    198                                                                        // NAMESPACE
    199                 }
    200                 // save as id
     197                    userId = userId.replace(NS.MPIWG_PERSONS_URL, "");
     198                }
     199                // set as id
    201200                userObject.put("id", userId);
    202201                // get full name
     
    390389             * } authUser = httpUser.getIdentifier();
    391390             */
     391        }
     392        // get or create creator object
     393        Actor creator = annot.getCreator();
     394        if (creator == null) {
     395            creator = new Actor(false, null, null);
     396            annot.setCreator(creator);
    392397        }
    393398        // username not required, if no username given authuser will be used
     
    414419        }
    415420        // try to get full name
    416         if (username != null) {
     421        if (creator.getName() == null && username != null) {
    417422            RestServer restServer = (RestServer) getApplication();
    418423            String fullName = restServer.getFullNameFromLdap(username);
    419             annot.setCreatorName(fullName);
     424            creator.setName(fullName);
    420425        }
    421426        // userUri should be a URI, if not it will set to the MPIWG namespace
     
    428433        }
    429434        // TODO: should we overwrite the creator?
    430         if (annot.getCreatorUri() == null) {
    431             annot.setCreatorUri(userUri);
     435        if (creator.getUri() == null) {
     436            creator.setUri(userUri);
    432437        }
    433438       
Note: See TracChangeset for help on using the changeset viewer.