[Yanel-commits] rev 33868 - in
public/yanel/contributions/realms/foaf: data/app/jelly
src/resources/import-foaf/src/build
src/resources/import-foaf/src/java/org/wyona/foaf/yanel/impl/resources/impfoaf
michi at wyona.com
michi at wyona.com
Sun Mar 23 00:52:22 CET 2008
Author: michi
Date: 2008-03-23 00:52:21 +0100 (Sun, 23 Mar 2008)
New Revision: 33868
Modified:
public/yanel/contributions/realms/foaf/data/app/jelly/import-foaf-files.jelly
public/yanel/contributions/realms/foaf/src/resources/import-foaf/src/build/dependencies.xml
public/yanel/contributions/realms/foaf/src/resources/import-foaf/src/java/org/wyona/foaf/yanel/impl/resources/impfoaf/ImportFOAFResource.java
Log:
create nodes
Modified: public/yanel/contributions/realms/foaf/data/app/jelly/import-foaf-files.jelly
===================================================================
--- public/yanel/contributions/realms/foaf/data/app/jelly/import-foaf-files.jelly 2008-03-22 23:27:44 UTC (rev 33867)
+++ public/yanel/contributions/realms/foaf/data/app/jelly/import-foaf-files.jelly 2008-03-22 23:52:21 UTC (rev 33868)
@@ -15,6 +15,9 @@
<body>
<h1>Import FOAF files</h1>
<p>Import directory: "${resource.getImportDirectory()}"</p>
+ <form action="">
+ <input type="submit" name="submit" value="Import"/>
+ </form>
</body>
</html>
</j:jelly>
Modified: public/yanel/contributions/realms/foaf/src/resources/import-foaf/src/build/dependencies.xml
===================================================================
--- public/yanel/contributions/realms/foaf/src/resources/import-foaf/src/build/dependencies.xml 2008-03-22 23:27:44 UTC (rev 33867)
+++ public/yanel/contributions/realms/foaf/src/resources/import-foaf/src/build/dependencies.xml 2008-03-22 23:52:21 UTC (rev 33868)
@@ -9,6 +9,7 @@
<remoteRepository refid="wyona.remote.repository"/>
<dependency groupId="wyona-org-yanel" artifactId="yanel-core" version="${yanel.source.version}"/>
<dependency groupId="wyona-org-yanel" artifactId="yanel-impl" version="${yanel.source.version}"/>
+ <dependency groupId="foaf" artifactId="yanel-resource-foaf" version="0.0.1-dev-rXXX"/>
</artifact:dependencies>
<artifact:dependencies pathId="maven2.resource.classpath" filesetId="maven2.resource.fileset">
Modified: public/yanel/contributions/realms/foaf/src/resources/import-foaf/src/java/org/wyona/foaf/yanel/impl/resources/impfoaf/ImportFOAFResource.java
===================================================================
--- public/yanel/contributions/realms/foaf/src/resources/import-foaf/src/java/org/wyona/foaf/yanel/impl/resources/impfoaf/ImportFOAFResource.java 2008-03-22 23:27:44 UTC (rev 33867)
+++ public/yanel/contributions/realms/foaf/src/resources/import-foaf/src/java/org/wyona/foaf/yanel/impl/resources/impfoaf/ImportFOAFResource.java 2008-03-22 23:52:21 UTC (rev 33868)
@@ -7,7 +7,10 @@
import org.wyona.yanel.impl.resources.usecase.ExecutableUsecaseResource;
import org.wyona.yanel.impl.resources.usecase.UsecaseException;
+import org.wyona.yarep.core.Node;
+
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.InputStream;
import org.apache.log4j.Logger;
@@ -25,7 +28,7 @@
* This method is executed when submitting the form provided in the default view (probably implemented as a jelly template).
*/
public void execute() throws UsecaseException {
-
+ doImportFOAFFiles();
}
/*
@@ -39,7 +42,7 @@
* Implement some test which are tested before the usecase will e executed
*/
public boolean checkPreconditions() throws UsecaseException {
- return false;
+ return true;
}
/**
@@ -49,7 +52,7 @@
try {
String importDir = getResourceConfigProperty("import-directory");
if (importDir != null) {
- if (new java.io.File(importDir).isDirectory()) {
+ if (new File(importDir).isDirectory()) {
return importDir;
} else {
return "No such directory: " + importDir;
@@ -62,4 +65,23 @@
return "Exception: " + e.getMessage();
}
}
+
+ /**
+ *
+ */
+ private void doImportFOAFFiles() {
+ File importDir = new File(getImportDirectory());
+ File[] filesAndDirs = importDir.listFiles();
+ for (int i = 0; i < filesAndDirs.length; i++) {
+ if (filesAndDirs[i].isFile()) {
+ log.error("DEBUG: File: " + filesAndDirs[i].getAbsolutePath());
+ try {
+ Node newFOAFNode = ((org.wyona.yanel.impl.map.FOAFRealm) getRealm()).getProfilesRepository().getNode("/profiles").addNode(filesAndDirs[i].getName(), org.wyona.yarep.core.NodeType.RESOURCE);
+ newFOAFNode.setMimeType("application/xml");
+ } catch(Exception e) {
+ log.error(e, e);
+ }
+ }
+ }
+ }
}
More information about the Yanel-commits
mailing list