Exemplo n.º 1
0
 public String insertResource(Resource rsce, String contUrl) {
   return "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
       + "PREFIX res:<"
       + this.getRes()
       + "s#>"
       + "INSERT  "
       + " { <"
       + rsce.getUrl()
       + "> res:submitter  \""
       + rsce.getSubmitter().getLogin()
       + "\" ; "
       + "                       res:state  \""
       + rsce.getState()
       + "\" ; "
       + "                       res:vocname  \""
       + rsce.getVoc().getName()
       + "\" ; "
       + "                       res:type  \""
       + rsce.getType()
       + "\" ; "
       + "                       res:language  \""
       + rsce.getLanguage()
       + "\" ; "
       + "                       res:format  \""
       + rsce.getFormat()
       + "\" ; "
       + "                       res:author  \""
       + rsce.getAuthor()
       + "\" ; "
       + "                       res:content  \""
       + contUrl
       + "\"  "
       + "               }";
 }
Exemplo n.º 2
0
 /**
  * Extract the id from a resource element and add to the resource map then recurse into any
  * contained resources. Also extract the ids from any contained method and its representation or
  * fault elements.
  *
  * @param file the URI of the current WADL file being processed
  * @param r the resource element
  * @throws javax.xml.bind.JAXBException if the WADL file is invalid or if the code generator
  *     encounters a problem.
  * @throws java.io.IOException if the specified WADL file cannot be read.
  */
 protected void extractResourceIds(Resource r, URI file) throws JAXBException, IOException {
   processIDHref(file, r.getId(), null, r);
   for (String type : r.getType()) {
     processIDHref(file, null, type, r);
   }
   for (Object child : r.getMethodOrResource()) {
     if (child instanceof Method) extractMethodIds((Method) child, file);
     else if (child instanceof Resource) extractResourceIds((Resource) child, file);
   }
 }
Exemplo n.º 3
0
 static boolean checkResource(Resource resource) {
   boolean isValid;
   if (isValid = resource != null) {
     isValid = TYPES.contains(resource.getType());
     isValid = isValid && resource.getProperty(URL_PROPERTY) != null;
     isValid = isValid && resource.getProperty(USERNAME_PROPERTY) != null;
     isValid = isValid && resource.getProperty(PASSWORD_PROPERTY) != null;
   }
   return isValid;
 }
 private void makeResource(Resource resource, String sitePath, Session session, ZipFile zip) {
   if (resource == null) {
     throw new IllegalArgumentException("Illegal Resource");
   }
   final String resourceType = resource.getType();
   if ("org.sakaiproject.content.types.folder".equalsIgnoreCase(resourceType)) {
     // folders are not currently supported in K2 - so ignore them
     // final Node node = makeNode(destination, session);
     // applyMetaData(node, resource, session);
   } else if ("org.sakaiproject.content.types.fileUpload".equalsIgnoreCase(resourceType)
       || "org.sakaiproject.content.types.TextDocumentType".equalsIgnoreCase(resourceType)
       || "org.sakaiproject.content.types.HtmlDocumentType".equalsIgnoreCase(resourceType)) {
     final String relativeId = resource.getRelativeId();
     String fileName = null;
     if (relativeId.contains("/")) {
       // folders are not currently supported in K2 - strip the folders.
       fileName = relativeId.substring(relativeId.lastIndexOf("/") + 1);
     } else {
       fileName = relativeId;
     }
     final Node node =
         copyFile(
             resource.attributes.get("body-location"),
             fileName,
             sitePath,
             resource.attributes.get("content-type"),
             session,
             zip);
     applyMetaData(node, resource, session);
   } else if ("org.sakaiproject.content.types.urlResource".equalsIgnoreCase(resourceType)) {
     // ignore urlResources for now - until BigStore refactor is complete
     // final String nodeName = destination.replace(":", "");
     // final Node node = makeNode(nodeName, session);
     // try {
     // applyMetaData(node, resource, session);
     // node.setProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY,
     // "sling:redirect");
     // node.setProperty("sling:target", resource.properties
     // .get("DAV:displayname"));
     // } catch (Exception e) {
     // throw new Error(e);
     // }
   } else {
     LOG.error("Missing handler for type: " + resourceType + ": " + resource);
   }
 }
Exemplo n.º 5
0
 /**
  * Add a resource and (recursively) its children to a tree starting at the parent. Follow
  * references to resources across WADL file boundaries
  *
  * @param parent the parent resource in the tree being built
  * @param resource the WADL resource to process
  * @param file the URI of the current WADL file being processed
  */
 protected void buildResourceTree(ResourceNode parent, Resource resource, URI file) {
   if (resource != null) {
     ResourceNode n = parent.addChild(resource);
     for (String type : resource.getType()) {
       addTypeToResource(n, type, file);
     }
     for (Object child : resource.getMethodOrResource()) {
       if (child instanceof Resource) {
         Resource childResource = (Resource) child;
         buildResourceTree(n, childResource, file);
       } else if (child instanceof Method) {
         Method m = (Method) child;
         addMethodToResource(n, m, file);
       }
     }
   }
 }
Exemplo n.º 6
0
 public String insert(Resource rsce) {
   String descr = "";
   for (String term : rsce.getContent()) {
     descr += "  ;  res:content  \"" + term + "\"  ";
   }
   return "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
       + "PREFIX res:<"
       + this.getRes()
       + "s#>"
       + "INSERT  "
       + " { <"
       + rsce.getUrl()
       + "> res:submitter  \""
       + rsce.getSubmitter().getLogin()
       + "\" ; "
       + "                       res:state  \""
       + rsce.getState()
       + "\" ; "
       + "                       res:vocname  \""
       + rsce.getVoc().getName()
       + "\" ; "
       + "                       res:type  \""
       + rsce.getType()
       + "\" ; "
       + "                       res:language  \""
       + rsce.getLanguage()
       + "\" ; "
       + "                       res:format  \""
       + rsce.getFormat()
       + "\" ; "
       + "                       res:author  \""
       + rsce.getAuthor()
       + "\"  "
       + descr
       + "               }";
 }