Finished Implememtation and completed FacebookFriendFinder Photark face app and also finished the backend implememtation of GenericFriendFinder app
git-svn-id: https://svn.apache.org/repos/asf/incubator/photark/trunk@1157388 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionService.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionService.java
index 0d76bac..a65b512 100644
--- a/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionService.java
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionService.java
@@ -115,7 +115,7 @@
* @throws FaceClientException
* @throws FaceServerException
*/
- public List<SavedTag> saveTags(String tids, String uid, String label) throws FaceClientException, FaceServerException;
+ public void saveTags(String tids, String uid, String label) throws FaceClientException, FaceServerException;
/**
* Does recognize whether the given image contains any of given users(by ID).
@@ -144,16 +144,16 @@
* @throws FaceClientException
* @throws FaceServerException
*/
- public Photo detectFromFile(File imageFile) throws FaceClientException, FaceServerException;
+ public PhotarkPhoto detectFromFile(File imageFile) throws FaceClientException, FaceServerException;
/**
* Detection happens same as {@detectFromFile} except this time its from urls
- * @param urls
+ * @param url
* @return
* @throws FaceClientException
* @throws FaceServerException
*/
- public List<Photo> detectFromUrls(String urls) throws FaceClientException, FaceServerException;
+ public PhotarkPhoto detectFromUrl(String url) throws FaceClientException, FaceServerException;
/**
* Gives the status of the given User IDs from the training set.
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionServiceImpl.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionServiceImpl.java
index e82e04c..50d506b 100644
--- a/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionServiceImpl.java
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionServiceImpl.java
@@ -48,6 +48,7 @@
@Init
public void init() {
+ System.out.println("# ... Initializing FaceRecognitionService ...");
defaultFaceClient = new DefaultFaceClient(API_KEY,API_SECRET);
}
@@ -61,8 +62,14 @@
/**
* @see {@link FaceRecognitionService#train(String)}
*/
- public void train(String uids) throws FaceClientException, FaceServerException {
- defaultFaceClient.train(uids);
+ public void train(String uids) {
+ try {
+ defaultFaceClient.train(uids);
+ } catch (FaceClientException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (FaceServerException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
}
/**
@@ -89,23 +96,43 @@
/**
* @see {@link FaceRecognitionService#saveTags(String,String,String)}
*/
- public List<SavedTag> saveTags(String tids, String uid, String label) throws FaceClientException, FaceServerException {
- return defaultFaceClient.saveTags(tids, uid, label);
+ public void saveTags(String tids, String uid, String label) {
+ try {
+ defaultFaceClient.saveTags(tids, uid, label);
+ } catch (FaceClientException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (FaceServerException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
}
/**
* @see {@link FaceRecognitionService#recognizeFromFile(File,String)}
*/
- public PhotarkPhoto recognizeFromFile(File imageFile, String uids) throws FaceClientException, FaceServerException {
- Photo photo = defaultFaceClient.recognize(imageFile, uids);
- return BeanGeneratorUtil.createPhotarkPhoto(photo);
+ public PhotarkPhoto recognizeFromFile(File imageFile, String uids) {
+ Photo photo = null;
+ try {
+ photo = defaultFaceClient.recognize(imageFile, uids);
+ } catch (FaceClientException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (FaceServerException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ return BeanGeneratorUtil.createPhotarkPhoto(photo);
}
/**
* @see {@link FaceRecognitionService#recognizeFromUrl(String,String)}
*/
- public PhotarkPhoto recognizeFromUrl(String url, String uid) throws FaceClientException, FaceServerException {
- Photo p = defaultFaceClient.recognize(url, uid).get(0);
+ public PhotarkPhoto recognizeFromUrl(String url, String uid) {
+ Photo p = null;
+ try {
+ p = defaultFaceClient.recognize(url, uid).get(0);
+ } catch (FaceClientException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (FaceServerException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
return BeanGeneratorUtil.createPhotarkPhoto(p);
}
@@ -113,15 +140,31 @@
/**
* @see {@link FaceRecognitionService#detectFromFile(File)}
*/
- public Photo detectFromFile(File imageFile) throws FaceClientException, FaceServerException {
- return defaultFaceClient.detect(imageFile);
+ public PhotarkPhoto detectFromFile(File imageFile) {
+ Photo photo = null;
+ try {
+ photo = defaultFaceClient.detect(imageFile);
+ } catch (FaceClientException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (FaceServerException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ return BeanGeneratorUtil.createPhotarkPhoto(photo);
}
/**
- * @see {@link FaceRecognitionService#detectFromUrls(String)}
+ * @see {@link FaceRecognitionService#detectFromUrl(String)}
*/
- public List<Photo> detectFromUrls(String urls) throws FaceClientException, FaceServerException {
- return defaultFaceClient.detect(urls);
+ public PhotarkPhoto detectFromUrl(String url) {
+ Photo photo = null;
+ try {
+ photo = defaultFaceClient.detect(url).get(0);
+ } catch (FaceClientException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (FaceServerException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ return BeanGeneratorUtil.createPhotarkPhoto(photo);
}
/**
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java
index f6f9496..a9f56e7 100644
--- a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java
@@ -24,12 +24,12 @@
@Remotable
public interface FacebookFriendFinder {
- public Entry<String, String>[] getAllMyFBFriendsFromPictureLocal(String pathToFile,String photarkUid);
+ public Entry<String, String[]>[] getAllMyFBFriendsFromPictureLocal(String pathToFile,String photarkUid);
- public Entry<String, String>[] getAllMyFBFriendsFromPictureUrl(String fileUrl,String photarkUid);
+ public Entry<String, String[]>[] getAllMyFBFriendsFromPictureUrl(String fileUrl,String photarkUid);
public void setFacebookAuth(String facebookId, String fbAccessToken);
public void storeFacebookAccessToken(String photarkUid, String accessToken);
-
+ public Entry<String, String[]>[] check();
}
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java
index 36f7c62..15c9f7a 100644
--- a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java
@@ -47,11 +47,11 @@
private final String adamAccessToken = "";
private AccessManager accessManager;
- @Init
+ @Init
public void init() {
- System.out.println("############## INIT..............############");
+ System.out.println("# ... Initializing FacebookFriendFinder Service ...");
}
-
+
@Reference(name = "faceRecognitionService")
protected void setFaceRecognitionService(FaceRecognitionService faceRecognitionService) {
this.faceRecognitionService = faceRecognitionService;
@@ -63,19 +63,27 @@
this.accessManager = accessManager;
}
- public Entry<String, String>[] getAllMyFBFriendsFromPictureLocal(String pathToFile,String photarkUid) {
+ public Entry<String, String[]>[] check() {
+ List<Entry<String, String[]>> detectedFriends = new ArrayList<Entry<String, String[]>>();
+ detectedFriends.add(new Entry<String, String[]>("uid", new String[]{"AAAA", "BBBB"}));
+ Entry<String, String[]>[] imageArray = new Entry[detectedFriends.size()];
+ return detectedFriends.toArray(imageArray);
+
+ }
+
+ public Entry<String, String[]>[] getAllMyFBFriendsFromPictureLocal(String pathToFile, String photarkUid) {
return processFBFriends(pathToFile, true, photarkUid);
}
- public Entry<String, String>[] getAllMyFBFriendsFromPictureUrl(String fileUrl, String photarkUid) {
+ public Entry<String, String[]>[] getAllMyFBFriendsFromPictureUrl(String fileUrl, String photarkUid) {
return processFBFriends(fileUrl, false, photarkUid);
}
public void storeFacebookAccessToken(String photarkUid, String accessToken) {
faceRecognitionService.setFacebookOauth2(getMyFacebookUserId(accessToken), accessToken);
- accessManager.setFacebookAccessTokenToUser(photarkUid,Constants.REGISTERED_USER_LIST,accessToken);
+ accessManager.setFacebookAccessTokenToUser(photarkUid, Constants.REGISTERED_USER_LIST, accessToken);
}
public void setFacebookAuth(String facebookId, String fbAccessToken) {
@@ -83,28 +91,32 @@
}
- private Entry<String, String>[] processFBFriends(String fileLocation, boolean isLocal, String photarkUid) {
+ private Entry<String, String[]>[] processFBFriends(String fileLocation, boolean isLocal, String photarkUid) {
PhotarkPhoto photo = null;
- List<Entry<String, String>> detectedFriends = new ArrayList<Entry<String, String>>();
- String accessToken = accessManager.getUserFacebookAccessToken(photarkUid,Constants.REGISTERED_USER_LIST);
+ List<Entry<String, String[]>> detectedFriends = new ArrayList<Entry<String, String[]>>();
+ String accessToken = accessManager.getUserFacebookAccessToken(photarkUid, Constants.REGISTERED_USER_LIST);
try {
- faceRecognitionService.setFacebookOauth2(getMyFacebookUserId(accessToken),accessToken);
+ faceRecognitionService.setFacebookOauth2(getMyFacebookUserId(accessToken), accessToken);
if (isLocal) {
photo = faceRecognitionService.recognizeFromFile(new File(fileLocation), "friends@facebook.com");
} else {
photo = faceRecognitionService.recognizeFromUrl(fileLocation, "friends@facebook.com");
}
+// output tuple = [name, link, gender, confidence,]
+
for (PhotArkFace face : photo.getPhotArkFaces()) {
String uid = "";
String confidence = "";
+ String gender = "";
if (face.getGuess() != null) {
System.out.println("***Identified*** " + face.getGuess().toString());
uid = face.getGuess().getGuessID();
confidence = face.getGuess().getConfidence();
- detectedFriends.add(new Entry<String, String>(uid, confidence));
+ gender = face.getGender();
+ detectedFriends.add(new Entry<String, String[]>(uid, getFacebookUserDataTuple(accessToken, uid, gender, confidence)));
} else {
System.out.println("??? Unidentified ..");
}
@@ -115,15 +127,29 @@
} catch (FaceServerException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
- Entry<String, String>[] imageArray = new Entry[detectedFriends.size()];
- return detectedFriends.toArray(imageArray);
+ //TODO If want can validate and remove duplicates from the "detectedFriends".
+
+ Entry<String, String[]>[] dataArray = new Entry[detectedFriends.size()];
+ return detectedFriends.toArray(dataArray);
}
private String getMyFacebookUserId(String accessToken) {
- FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
- User user = facebookClient.fetchObject("me", User.class);
- return user.getId();
+ FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
+ User user = facebookClient.fetchObject("me", User.class);
+ return user.getId();
+ }
+
+ private String[] getFacebookUserDataTuple(String accessToken, String uid, String gender, String confidence) {
+ String name = "";
+ String link = "";
+ String userId = uid.trim().split("@")[0];
+
+ FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
+ User user = facebookClient.fetchObject(userId, User.class);
+ name = user.getName();
+ link = user.getLink();
+ return new String[]{name, link, gender, confidence};
}
}
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/generic/GenericFriendFinder.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/generic/GenericFriendFinder.java
new file mode 100644
index 0000000..75690ac
--- /dev/null
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/generic/GenericFriendFinder.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.face.services.applications.generic;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface GenericFriendFinder {
+
+ public String check();
+
+ public void trainUrlImage(String imagePath, String userName, String label) ;
+
+ public void trainLocalImage(String imagePath, String userName, String label);
+
+ public Entry<String, String[]>[] getAllMyFriendsFromPictureLocal(String pathToFile, String uids, String photarkUid);
+
+ public Entry<String, String[]>[] getAllMyFriendsFromPictureUrl(String fileUrl,String uids, String photarkUid);
+
+}
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/generic/GenericFriendFinderImpl.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/generic/GenericFriendFinderImpl.java
new file mode 100644
index 0000000..a955afe
--- /dev/null
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/generic/GenericFriendFinderImpl.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.face.services.applications.generic;
+
+import com.github.mhendred.face4j.exception.FaceClientException;
+import com.github.mhendred.face4j.exception.FaceServerException;
+import com.github.mhendred.face4j.model.Face;
+import com.github.mhendred.face4j.model.Photo;
+import org.apache.photark.face.services.FaceRecognitionService;
+import org.apache.photark.face.services.beans.PhotArkFace;
+import org.apache.photark.face.services.beans.PhotarkPhoto;
+import org.apache.photark.security.authorization.services.AccessManager;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+@Scope("COMPOSITE")
+public class GenericFriendFinderImpl implements GenericFriendFinder {
+ private FaceRecognitionService faceRecognitionService;
+ private AccessManager accessManager;
+
+ @Init
+ public void init() {
+ System.out.println("# ... Initializing GenericFriendFinder Service ...");
+ }
+
+ @Reference(name = "faceRecognitionService")
+ protected void setFaceRecognitionService(FaceRecognitionService faceRecognitionService) {
+ this.faceRecognitionService = faceRecognitionService;
+ }
+
+
+ @Reference(name = "accessmanager")
+ protected void setAccessService(AccessManager accessManager) {
+ this.accessManager = accessManager;
+ }
+
+ public String check() {
+ return "VVV"; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+
+ public Entry<String, String[]>[] getAllMyFriendsFromPictureLocal(String pathToFile, String uids, String photarkUid) {
+ return processMyFriends(pathToFile, uids, true, photarkUid);
+ }
+
+ public Entry<String, String[]>[] getAllMyFriendsFromPictureUrl(String fileUrl, String uids, String photarkUid) {
+ return processMyFriends(fileUrl, uids, false, photarkUid);
+ }
+
+
+ private Entry<String, String[]>[] processMyFriends(String pathToFile, String uid, boolean isLocal, String photarkUid) {
+ PhotarkPhoto photo;
+ List<Entry<String, String[]>> detectedFriends = new ArrayList<Entry<String, String[]>>();
+
+ try {
+ if (isLocal) {
+ photo = faceRecognitionService.recognizeFromFile(new File(pathToFile), uid);
+ } else {
+ photo = faceRecognitionService.recognizeFromUrl(pathToFile, uid);
+
+ }
+ // user data tuple [uid,confidence,gender]
+ for (PhotArkFace face : photo.getPhotArkFaces()) {
+ String userName = "";
+ String confidence = "";
+ String gender = "";
+ if (face.getGuess() != null) {
+ System.out.println("***Identified*** " + face.getGuess().toString());
+ userName = face.getGuess().getGuessID();
+ confidence = face.getGuess().getConfidence();
+ gender = face.getGender();
+ detectedFriends.add(new Entry<String, String[]>(userName, new String[]{userName, confidence, gender}));
+ } else {
+ System.out.println("??? Unidentified ..");
+ }
+ }
+
+ } catch (FaceClientException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (FaceServerException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ Entry<String, String[]>[] dataArray = new Entry[detectedFriends.size()];
+ return detectedFriends.toArray(dataArray);
+ }
+
+ public void trainLocalImage(String imagePath, String userName, String label) {
+ try {
+ PhotarkPhoto photo = faceRecognitionService.detectFromFile(new File(imagePath));
+ for (PhotArkFace face : photo.getPhotArkFaces()) {
+ if (face.getGuess() != null) {
+ userName = face.getGuess().getGuessID();
+
+ faceRecognitionService.saveTags(face.getTid(), userName, label);
+ } else {
+ faceRecognitionService.saveTags(face.getTid(), userName, label);
+ }
+
+ faceRecognitionService.train(userName);
+ }
+ } catch (FaceClientException e) {
+ e.printStackTrace();
+ } catch (FaceServerException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void trainUrlImage(String imagePath, String userName, String label) {
+ try {
+ PhotarkPhoto photo = faceRecognitionService.detectFromUrl(imagePath);
+ for (PhotArkFace face : photo.getPhotArkFaces()) {
+ if (face.getGuess() != null) {
+ userName = face.getGuess().getGuessID();
+
+ faceRecognitionService.saveTags(face.getTid(), userName, label);
+ } else {
+ faceRecognitionService.saveTags(face.getTid(), userName, label);
+ }
+
+ faceRecognitionService.train(userName);
+ }
+ } catch (FaceClientException e) {
+ e.printStackTrace();
+ } catch (FaceServerException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
diff --git a/photark-face-recognition/src/test/java/org/apache/photark/face/facebook/test/GenericFaceRecognitionTestCase.java b/photark-face-recognition/src/test/java/org/apache/photark/face/facebook/test/GenericFaceRecognitionTestCase.java
index 4edb31e..810eebb 100644
--- a/photark-face-recognition/src/test/java/org/apache/photark/face/facebook/test/GenericFaceRecognitionTestCase.java
+++ b/photark-face-recognition/src/test/java/org/apache/photark/face/facebook/test/GenericFaceRecognitionTestCase.java
@@ -76,15 +76,15 @@
public void testFaceRecognition() throws FaceServerException, FaceClientException {
FaceRecognitionService defaultFaceClient =
(FaceRecognitionService)node.getService(FaceRecognitionService.class, "FaceRecognitionService");
- Photo p1 =
+ PhotarkPhoto p1 =
defaultFaceClient
- .detectFromUrls("https://lh3.googleusercontent.com/-z13PTuGA9mg/Thi6cKAiJVI/AAAAAAAAABs/lTEMvH9in1s/s128/Jennifer-Lopez0045.jpg").get(0);
- Photo p2 =
+ .detectFromUrl("https://lh3.googleusercontent.com/-z13PTuGA9mg/Thi6cKAiJVI/AAAAAAAAABs/lTEMvH9in1s/s128/Jennifer-Lopez0045.jpg");
+ PhotarkPhoto p2 =
defaultFaceClient
- .detectFromUrls("https://lh5.googleusercontent.com/-K6Jpe-1liwc/Thk0cEGT9cI/AAAAAAAAAB4/9a_84-oMqL8/s128/jennifer-lopez.jpg").get(0);
+ .detectFromUrl("https://lh5.googleusercontent.com/-K6Jpe-1liwc/Thk0cEGT9cI/AAAAAAAAAB4/9a_84-oMqL8/s128/jennifer-lopez.jpg");
- defaultFaceClient.saveTags(p1.getFace().getTID(), "jenifer@photark.com", "jenifer");
- defaultFaceClient.saveTags(p2.getFace().getTID(), "jenifer@photark.com", "jenifer");
+ defaultFaceClient.saveTags(p1.getPhotArkFace().getTid(), "jenifer@photark.com", "jenifer");
+ defaultFaceClient.saveTags(p2.getPhotArkFace().getTid(), "jenifer@photark.com", "jenifer");
defaultFaceClient.train("jenifer@photark.com");
PhotarkPhoto p =
diff --git a/photark-ui-admin/src/main/webapp/admin/js/face.js b/photark-ui-admin/src/main/webapp/admin/js/face.js
index bd44b0c..320628a 100644
--- a/photark-ui-admin/src/main/webapp/admin/js/face.js
+++ b/photark-ui-admin/src/main/webapp/admin/js/face.js
@@ -21,6 +21,7 @@
var selectFaceApp
var faceService;
+
dojo.addOnLoad(function() {
dojo.require("dojo._base.xhr");
dojo.require("dojo.rpc.JsonService");
@@ -33,6 +34,8 @@
function initServices() {
faceService = new dojo.rpc.JsonService(photark.constants.FaceRecognitionService);
facebookService = new dojo.rpc.JsonService(photark.constants.FacebookFriendFinder);
+ genericFaceService = new dojo.rpc.JsonService(photark.constants.GenericFriendFinder);
+
}
@@ -80,8 +83,8 @@
var url = window.location.href;
if (url != "http://localhost:8080/photark/admin/face.html") {
var accesstoken = url.split("&")[0].split("=")[1];
- store_facebook_access_token(accesstoken) ;
-
+ store_facebook_access_token(accesstoken);
+
}
}
@@ -94,23 +97,41 @@
window.location = url;
}
-function trainUser(user_name) {
+function trainUser() {
+ var userName = dojo.byId("train_uname_input").value;
+
if (selectFaceApp.value == "General-Face-Recognition") {
- //TODO call train method in generic face app
+ var filePath = dojo.byId("imageFilePathInput").value;
+ var fileUrl = dojo.byId("imageUrlInput").value;
+ var label = dojo.byId("train_label_input").value;
+
+ if (label == "") {
+ label = "photark_default";
+ }
+
+ if ((filePath == "" ) && (fileUrl != "")) {
+ genericFaceService.trainUrlImage(fileUrl, userName, label).addCallback(facebook_gff_void_callback);
+ } else if ((fileUrl == "" ) && (filePath != "")) {
+
+ genericFaceService.trainLocalImage(filePath, userName, label).addCallback(facebook_gff_void_callback);
+ } else {
+ alert("..You should fill either image file path or url ...!!! ");
+ }
+
} else if (selectFaceApp.value == "FaceBook-Friend-Finder") {
- faceService.train(user_name).addCallback(facebook_ff_callback);
+ faceService.train(userName).addCallback(facebook_ff_callback);
}
}
function store_facebook_access_token(accessToken) {
- dojo.xhrPost({
+ dojo.xhrPost({
url:"../security", //photark.constants.SecurityEndpoint,
content:{request:"getUser"},
handleAs: "json",
load: function(response, ioArgs) {
- facebookService.storeFacebookAccessToken(response.user.userId,accessToken).addCallback(facebook_ff_void_callback);
+ facebookService.storeFacebookAccessToken(response.user.userId, accessToken).addCallback(facebook_ff_void_callback);
},
error: function(response, ioArgs) {
@@ -129,8 +150,16 @@
function facebook_ff_void_callback(items, exception) {
if (exception) {
alert("Error");
- } else {
-// alert("CAME");
+ } else {
+ // alert("CAME");
+ }
+}
+
+function facebook_gff_void_callback(items, exception) {
+ if (exception) {
+ alert("Error");
+ } else {
+ alert("GFF CAME");
}
}
diff --git a/photark-ui/src/main/webapp/gallery.html b/photark-ui/src/main/webapp/gallery.html
index 243c8b9..c543f56 100644
--- a/photark-ui/src/main/webapp/gallery.html
+++ b/photark-ui/src/main/webapp/gallery.html
@@ -112,8 +112,15 @@
</td>
<td align="left">
<div id="tags">
- <input id="addtag-input" style="width:20;" type="text" style="display:inline;" value="" size="20" alt="add tag..."/><input type="button" onclick="addTag();" style="display:inline;" value="Add Tag"/><input type="button" onclick="showFacebookFriends();" style="display:inline;" value="facebook"/>
- <table id='tableTags' style="margin-left:auto; margin-right:auto;width:150;" border="0"
+ <input id="addtag-input" style="width:20;" type="text" style="display:inline;" value="" size="20" alt="add tag..."/><input type="button" onclick="addTag();" style="display:inline;" value="Add Tag"/><input type="button" onclick="showFriends();" style="display:inline;" value="Recognize Friends"/>From
+ <select id="faceAppType" name="faceAppType" >
+ <option value="facebook">Facebook</option>
+ <option value="">Private NameSpace</option>
+ </select>
+
+ <table id='faceTable' width="300" border="0" cellspacing="0" cellpadding="1">
+ </table>
+ <table id='tableTags' style="margin-left:auto; margin-right:auto;width:150;" border="0"
cellspacing="0" cellpadding="1">
</table>
</div>
diff --git a/photark-ui/src/main/webapp/js/constants.js b/photark-ui/src/main/webapp/js/constants.js
index b0946e3..73c4b76 100644
--- a/photark-ui/src/main/webapp/js/constants.js
+++ b/photark-ui/src/main/webapp/js/constants.js
@@ -28,6 +28,7 @@
photark.constants.contextRoot = "/photark/";
photark.constants.adminContextRoot = "/photark/admin/";
+photark.constants.GenericFriendFinder = photark.constants.contextRoot + "GenericFriendFinder?smd";
photark.constants.FacebookFriendFinder = photark.constants.contextRoot + "FacebookFriendFinder?smd";
photark.constants.FaceRecognitionService = photark.constants.contextRoot + "FaceRecognitionService?smd";
photark.constants.RemoteAlbumSubscription = photark.constants.contextRoot + "RemoteAlbumSubscriptionManager?smd";
diff --git a/photark-ui/src/main/webapp/js/gallery.js b/photark-ui/src/main/webapp/js/gallery.js
index 59e9b5e..7a83d21 100644
--- a/photark-ui/src/main/webapp/js/gallery.js
+++ b/photark-ui/src/main/webapp/js/gallery.js
@@ -17,18 +17,30 @@
* under the License.
*/
-var index_off= new Image(31,31); index_off.src = "images/index.gif";
-var index_on = new Image(31,31); index_on.src = "images/index_on.gif";
-var next_off = new Image(31,31); next_off.src = "images/next.gif";
-var next_on = new Image(31,31); next_on.src = "images/next_on.gif";
-var prev_off = new Image(31,31); prev_off.src = "images/prev.gif";
-var prev_on = new Image(31,31); prev_on.src = "images/prev_on.gif";
-var slide_before_start = new Image(31,31); slide_before_start.src = "images/slide_before_start.gif";
-var slide_pause = new Image(31,31); slide_pause.src = "images/slide_pause.gif";
-var show_slide = new Image(31,31); show_slide.src = "images/show_slide.gif";
-var show_slide_on = new Image(31,31); show_slide_on.src = "images/show_slide_on.gif";
-var show_slide_slow = new Image(31,31); show_slide_slow.src = "images/show_slide_slow.gif";
-var show_slide_slow_on = new Image(31,31); show_slide_slow_on.src = "images/show_slide_slow_on.gif";
+var index_off = new Image(31, 31);
+index_off.src = "images/index.gif";
+var index_on = new Image(31, 31);
+index_on.src = "images/index_on.gif";
+var next_off = new Image(31, 31);
+next_off.src = "images/next.gif";
+var next_on = new Image(31, 31);
+next_on.src = "images/next_on.gif";
+var prev_off = new Image(31, 31);
+prev_off.src = "images/prev.gif";
+var prev_on = new Image(31, 31);
+prev_on.src = "images/prev_on.gif";
+var slide_before_start = new Image(31, 31);
+slide_before_start.src = "images/slide_before_start.gif";
+var slide_pause = new Image(31, 31);
+slide_pause.src = "images/slide_pause.gif";
+var show_slide = new Image(31, 31);
+show_slide.src = "images/show_slide.gif";
+var show_slide_on = new Image(31, 31);
+show_slide_on.src = "images/show_slide_on.gif";
+var show_slide_slow = new Image(31, 31);
+show_slide_slow.src = "images/show_slide_slow.gif";
+var show_slide_slow_on = new Image(31, 31);
+show_slide_slow_on.src = "images/show_slide_slow_on.gif";
var gallery;
var remoteGallery;
@@ -50,7 +62,7 @@
var rpos = 0;
var remoteFlag = 0;
-var slideShowSpeed=0;
+var slideShowSpeed = 0;
var timer;
var userId;
var SECURITY_TOKEN;
@@ -90,9 +102,9 @@
}
-function initServices(){
- searchService = new dojo.rpc.JsonService( photark.constants.SearchServiceEndpoint );
- gallery = new dojo.rpc.JsonService( photark.constants.GalleryServiceEndpoint );
+function initServices() {
+ searchService = new dojo.rpc.JsonService(photark.constants.SearchServiceEndpoint);
+ gallery = new dojo.rpc.JsonService(photark.constants.GalleryServiceEndpoint);
remoteGallery = new dojo.rpc.JsonService(photark.constants.RemoteGalleryServiceEndpoint);
faceService = new dojo.rpc.JsonService(photark.constants.FaceRecognitionService);
facebook_ff = new dojo.rpc.JsonService(photark.constants.FacebookFriendFinder);
@@ -119,25 +131,25 @@
}
function populateUserInfo() {
- dojo.xhrPost({
- url:"security", //photark.constants.SecurityEndpoint,
- content:{request:"getUser"},
- handleAs: "json",
- load: function(response, ioArgs) {
- displayLoginLinks(response);
- },
- error: function(response, ioArgs) {
- console.error("Error in getting user info");
- }
- });
+ dojo.xhrPost({
+ url:"security", //photark.constants.SecurityEndpoint,
+ content:{request:"getUser"},
+ handleAs: "json",
+ load: function(response, ioArgs) {
+ displayLoginLinks(response);
+ },
+ error: function(response, ioArgs) {
+ console.error("Error in getting user info");
}
-function displayLoginLinks (response) {
- if(response!=null&&response.user.userId!="null"&&response.user.userId!="Guest"){
+ });
+}
+function displayLoginLinks(response) {
+ if (response != null && response.user.userId != "null" && response.user.userId != "Guest") {
var displayName = response.user.userInfo.displayName;
- document.getElementById("loginLinks").innerHTML="Welcome <b>"+displayName+"</b> : <span><a href=\"./admin/upload.html\"><u>Admin page</u></a></span> <span><a href=\"./logout/\"><u>Logout</u></a></span>" ;
+ document.getElementById("loginLinks").innerHTML = "Welcome <b>" + displayName + "</b> : <span><a href=\"./admin/upload.html\"><u>Admin page</u></a></span> <span><a href=\"./logout/\"><u>Logout</u></a></span>";
} else {
- document.getElementById("loginLinks").innerHTML="<span><a href=\"./admin/authenticate\"><u>Super admin</u></a></span> <span><a href=\"./home/authenticate\"><u>Login</u></a></span>";
+ document.getElementById("loginLinks").innerHTML = "<span><a href=\"./admin/authenticate\"><u>Super admin</u></a></span> <span><a href=\"./home/authenticate\"><u>Login</u></a></span>";
}
@@ -145,45 +157,45 @@
function remote_gallery_getAlbumsResponse(albums, exception) {
- if(exception) {
- // alert(exception.msg);
- // return;
- logout();
+ if (exception) {
+ // alert(exception.msg);
+ // return;
+ logout();
}
remoteGalleryAlbums = albums;
- for(i=0; i< remoteGalleryAlbums.length; i++)
+ for (i = 0; i < remoteGalleryAlbums.length; i++)
{
- //gallery.getAlbumCover(galleryAlbums[i].name).addCallback(gallery_getAlbumCoverResponse);
- remoteGallery.getAlbumCoverToUser(remoteGalleryAlbums[i].name,SECURITY_TOKEN,"remote").addCallback(remote_gallery_getAlbumCoverResponse);
+ //gallery.getAlbumCover(galleryAlbums[i].name).addCallback(gallery_getAlbumCoverResponse);
+ remoteGallery.getAlbumCoverToUser(remoteGalleryAlbums[i].name, SECURITY_TOKEN, "remote").addCallback(remote_gallery_getAlbumCoverResponse);
}
}
function gallery_getAlbumsResponse(albums, exception) {
- if(exception) {
- // alert(exception.msg);
- // return;
- logout();
+ if (exception) {
+ // alert(exception.msg);
+ // return;
+ logout();
}
galleryAlbums = albums;
- for(i=0; i< galleryAlbums.length; i++)
+ for (i = 0; i < galleryAlbums.length; i++)
{
- // gallery.getAlbumCover(galleryAlbums[i].name).addCallback(gallery_getAlbumCoverResponse);
- gallery.getAlbumCoverToUser(galleryAlbums[i].name,SECURITY_TOKEN).addCallback(gallery_getAlbumCoverResponse);
+ // gallery.getAlbumCover(galleryAlbums[i].name).addCallback(gallery_getAlbumCoverResponse);
+ gallery.getAlbumCoverToUser(galleryAlbums[i].name, SECURITY_TOKEN).addCallback(gallery_getAlbumCoverResponse);
}
}
function remote_gallery_getAlbumCoverResponse(cover, exception) {
- if(exception){
-// alert(exception.msg);
-// return;
- logout();
+ if (exception) {
+ // alert(exception.msg);
+ // return;
+ logout();
}
remoteAlbumCovers[rpos] = cover;
rpos += 1;
- if(remoteAlbumCovers.length == remoteGalleryAlbums.length)
+ if (remoteAlbumCovers.length == remoteGalleryAlbums.length)
{
initializeRemoteGallery();
displayRemoteGallery();
@@ -191,98 +203,122 @@
}
function gallery_getAlbumCoverResponse(cover, exception) {
- if(exception){
-// alert(exception.msg);
-// return;
- logout();
+ if (exception) {
+ // alert(exception.msg);
+ // return;
+ logout();
}
albumCovers[pos] = cover;
pos += 1;
- if(albumCovers.length == galleryAlbums.length)
+ if (albumCovers.length == galleryAlbums.length)
{
initializeGallery();
displayGallery();
}
}
-function searchResponse(items, exception){
+function searchResponse(items, exception) {
- if(exception) {
-// alert(exception.msg);
-// return;
- logout();
+ if (exception) {
+ // alert(exception.msg);
+ // return;
+ logout();
}
- var table=document.getElementById('tableSearch');
- deleteTableRows(table);
-
+ var table = document.getElementById('tableSearch');
+ deleteTableRows(table);
+
for (i = 0; i < items.length / 5; i++) {
- var row = table.insertRow(i*2);
- for (j = 0; j < 5 && i*5 + j < items.length ; j++) {
-
- var column = row.insertCell(j);
- var aux = items[i*5 + j].split('/', 2);
- var albumName = aux[0];
- var imageName = aux[1];
-// var img = document.createElement("img");
-// img.src = (window.location.href).replace("admin/upload.html", "") + "gallery/" +items[i*5 + j ];
-// img['class'] = "slideImage";
-// img.width=100;
-// //img.height=10;
-// img.ondragstart = function () { return false; };
-// img.onselectstart = function () { return false; };
-// img.onconstextmenu = function () { return false; };
-// img.alt = items[i*5 + j];
-// var a = document.createElement("a");
-// a.href = "javascript:initializeAlbum('" + albumName + "', '" + imageName + "')";
-// a.appendChild(img);
- column.innerHTML= "<a href=\"javascript:initializeAlbum('" + albumName + "', '" + imageName + "')\">"+albumName+"/"+imageName+"</a>";
+ var row = table.insertRow(i * 2);
+ for (j = 0; j < 5 && i * 5 + j < items.length; j++) {
+
+ var column = row.insertCell(j);
+ var aux = items[i * 5 + j].split('/', 2);
+ var albumName = aux[0];
+ var imageName = aux[1];
+ // var img = document.createElement("img");
+ // img.src = (window.location.href).replace("admin/upload.html", "") + "gallery/" +items[i*5 + j ];
+ // img['class'] = "slideImage";
+ // img.width=100;
+ // //img.height=10;
+ // img.ondragstart = function () { return false; };
+ // img.onselectstart = function () { return false; };
+ // img.onconstextmenu = function () { return false; };
+ // img.alt = items[i*5 + j];
+ // var a = document.createElement("a");
+ // a.href = "javascript:initializeAlbum('" + albumName + "', '" + imageName + "')";
+ // a.appendChild(img);
+ column.innerHTML = "<a href=\"javascript:initializeAlbum('" + albumName + "', '" + imageName + "')\">" + albumName + "/" + imageName + "</a>";
- }
-
- row = table.insertRow(i*2+1);
- column = row.insertCell(0) ;
- column.innerHTML = "<img src=\"images/space.gif\" class=\"slideImage\" width=\"10\" height=\"10\" ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\">";
-
- }
+ }
- displaySearchResults();
+ row = table.insertRow(i * 2 + 1);
+ column = row.insertCell(0);
+ column.innerHTML = "<img src=\"images/space.gif\" class=\"slideImage\" width=\"10\" height=\"10\" ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\">";
+
+ }
+
+ displaySearchResults();
}
function deleteTableRows(table) {
- while (table.rows.length > 0) {
- table.deleteRow(0);
- }
+ while (table.rows.length > 0) {
+ table.deleteRow(0);
+ }
}
function addTag() {
- var tag = document.getElementById("addtag-input").value;
- searchService.addTag(albumName, albumItems[albumPos], tag);
-
- var imageID = albumName + '/' + albumItems[albumPos];
- var imageTags = albumTags[imageID];
-
- if (imageTags == null) {
- imageTags = new Array();
- albumTags[imageID] = imageTags;
-
- }
-
- imageTags.push(tag);
- showTags(imageTags);
-
+ var tag = document.getElementById("addtag-input").value;
+ searchService.addTag(albumName, albumItems[albumPos], tag);
+
+ var imageID = albumName + '/' + albumItems[albumPos];
+ var imageTags = albumTags[imageID];
+
+ if (imageTags == null) {
+ imageTags = new Array();
+ albumTags[imageID] = imageTags;
+
+ }
+
+ imageTags.push(tag);
+ showTags(imageTags);
+
}
-function showFacebookFriends(){
- var file_path = document.getElementById("albumImage").src;
+function clearFaceTable() {
+ for (var i = document.getElementById("faceTable").rows.length; i > 0; i--) {
+ document.getElementById("faceTable").deleteRow(i - 1);
+ }
+}
+
+function showFriends() {
+ clearFaceTable();
+
+ var facetype = dojo.byId("faceAppType").value;
+ var textField = document.getElementById('addtag-input');
+
+ if (facetype == "facebook") {
+ showFacebookFriends();
+ } else if (facetype == "private") {
+
+
+ }
+
+
+}
+
+function showFacebookFriends() {
+
+ var file_path = "https://lh4.googleusercontent.com/-rb_m-GQcL00/Ti8sqThvrDI/AAAAAAAAAMY/kUBurbFKJ0A/s640/friends_2.jpg";
+
dojo.xhrPost({
url:"security", //photark.constants.SecurityEndpoint,
content:{request:"getUser"},
handleAs: "json",
load: function(response, ioArgs) {
- facebook_ff.getAllMyFBFriendsFromPictureUrl(file_path,response.user.userId).addCallback(facebook_ff_callback);
+ facebook_ff.getAllMyFBFriendsFromPictureUrl(file_path, response.user.userId).addCallback(facebook_ff_callback);
},
error: function(response, ioArgs) {
@@ -292,7 +328,7 @@
}
function face_callback(items, exception) {
- if(exception) {
+ if (exception) {
alert("FB AUTH Error");
}
@@ -300,27 +336,68 @@
}
-function face_callback1(items, exception) {
- if(exception) {
+function face_callback1(entries, exception) {
+ if (exception) {
alert("FB AUTH Error");
-
}
- //alert("FB AUTH OK");
+
}
-function facebook_ff_callback(items, exception) {
- if(exception) {
+function facebook_ff_callback(entries, exception) {
+ if (exception) {
alert("Error");
+ } else {
+ viewFaceResults(entries);
+ // for (var i=0; i<entries.length; i++) {
+ // var user_data = entries[i];
+ // var name = entries[i].data[0];
+ // var link = entries[i].data[1];
+ // var confidence = entries[i].data[2];
+ // // TODO Display these data in a table
+ // alert(name+ ":: "+link+":: "+confidence);
+ // }
}
- alert(items.length);
}
+function viewFaceResults(entries) {
+
+ var table = document.getElementById('faceTable');
+ var lastRow = 0;
+ var row = table.insertRow(lastRow++);
+
+ column = row.insertCell(0);
+ column.width = 1300;
+ column.innerHTML = "<span style=\"color:#336633\">"+"Name"+"</span>";
+ column = row.insertCell(1);column.width = 400;
+ column.innerHTML = "<span style=\"color:#336633\">"+"Gender"+"</span>";
+ column = row.insertCell(2);column.width = 400;
+ column.innerHTML = "<span style=\"color:#336633\">"+"Confidence"+"</span>";
+
+ for (var i = 0; i < entries.length; i++) {
+ var row = table.insertRow(i+1);
+ var user_data = entries[i];
+ var uname = entries[i].data[0];
+ var link = entries[i].data[1];
+ var gender = entries[i].data[2];
+ var confidence = entries[i].data[3];
+
+ column = row.insertCell(0);
+ column.innerHTML = "<a href=\""+link+"\" style=\"color:green;\">"+uname+"</a>";
+
+ column = row.insertCell(1);
+ column.innerHTML = "<span style=\"color:green\">"+gender+"</span>";
+
+ column = row.insertCell(2);
+ column.innerHTML = "<span style=\"color:green\">"+confidence+" %"+"</span>";
+ }
+}
+
function initializeRemoteGallery() {
- var table=document.getElementById('remoteTableGallery');
+ var table = document.getElementById('remoteTableGallery');
var lastRow = table.rows.length;
for (i = 0; i < remoteGalleryAlbums.length; i++) {
var row = table.insertRow(lastRow++);
@@ -336,7 +413,7 @@
column.innerHTML = html;
column = row.insertCell(1);
- column.innerHTML = "<div style=\"width:500\">"+remoteGalleryAlbums[i].description+"</div>";
+ column.innerHTML = "<div style=\"width:500\">" + remoteGalleryAlbums[i].description + "</div>";
row = table.insertRow(lastRow++);
column = row.insertCell(0)
@@ -346,11 +423,11 @@
column = row.insertCell(0)
column.innerHTML = "<img src=\"images/space.gif\" class=\"slideImage\" width=\"10\" height=\"10\" ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\">";
}
- }
+ }
}
function initializeGallery() {
- var table=document.getElementById('tableGallery');
+ var table = document.getElementById('tableGallery');
var lastRow = table.rows.length;
for (i = 0; i < galleryAlbums.length; i++) {
var row = table.insertRow(lastRow++);
@@ -360,13 +437,13 @@
var albumName = galleryAlbums[i].name;
var img = document.createElement("img");
- img.src = window.location.href + "gallery/"+ albumName +"/" + albumCovers[i];
+ img.src = window.location.href + "gallery/" + albumName + "/" + albumCovers[i];
var img_html = "<img src=" + img.src + " class=\"slideImage\" width=180px ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\"/>";
var html = "<a href=\"javascript:initializeAlbum('" + albumName + "', null)\">" + img_html + "</a>";
column.innerHTML = html;
column = row.insertCell(1);
- column.innerHTML = "<div style=\"width:500\">"+galleryAlbums[i].description+"</div>";
+ column.innerHTML = "<div style=\"width:500\">" + galleryAlbums[i].description + "</div>";
row = table.insertRow(lastRow++);
column = row.insertCell(0)
@@ -376,46 +453,46 @@
column = row.insertCell(0)
column.innerHTML = "<img src=\"images/space.gif\" class=\"slideImage\" width=\"10\" height=\"10\" ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\">";
}
- }
+ }
}
function displayRemoteGallery() {
- setVisibility('gallery',true);
- setVisibility('album',false);
- setVisibility('search',false);
+ setVisibility('gallery', true);
+ setVisibility('album', false);
+ setVisibility('search', false);
}
function displayGallery() {
- setVisibility('gallery',true);
- setVisibility('album',false);
- setVisibility('search',false);
+ setVisibility('gallery', true);
+ setVisibility('album', false);
+ setVisibility('search', false);
}
function displaySearchResults() {
- setVisibility('search',true);
- setVisibility('gallery',false);
- setVisibility('album',false);
+ setVisibility('search', true);
+ setVisibility('gallery', false);
+ setVisibility('album', false);
}
-function initializeAlbum(albumName,imageName) {
+function initializeAlbum(albumName, imageName) {
try {
this.albumName = albumName;
- albumImageToBeLoaded = imageName;
- albumTags = new Array();
- gallery.getAlbumPicturesToUser(albumName,SECURITY_TOKEN).addCallback(gallery_getAlbumPicturesResponse);
-
+ albumImageToBeLoaded = imageName;
+ albumTags = new Array();
+ gallery.getAlbumPicturesToUser(albumName, SECURITY_TOKEN).addCallback(gallery_getAlbumPicturesResponse);
+
} catch(exception) {
alert(e);
}
}
-function initializeRemoteAlbum(albumName,imageName) {
+function initializeRemoteAlbum(albumName, imageName) {
try {
this.albumName = albumName;
- albumImageToBeLoaded = imageName;
- albumTags = new Array();
- remoteGallery.getAlbumPicturesToUser(albumName,SECURITY_TOKEN,"remote").addCallback(gallery_getRemoteAlbumPicturesResponse);
+ albumImageToBeLoaded = imageName;
+ albumTags = new Array();
+ remoteGallery.getAlbumPicturesToUser(albumName, SECURITY_TOKEN, "remote").addCallback(gallery_getRemoteAlbumPicturesResponse);
} catch(exception) {
alert(e);
@@ -423,60 +500,60 @@
}
function loadTags(albumPos) {
- var imageTags = albumTags[albumName + '/' + albumItems[albumPos]];
-
- if (imageTags == null) {
- searchService.getTags(albumName, albumItems[albumPos]).addCallback(getTagsResponse);
-
- } else {
- showTags(imageTags);
- }
-
+ var imageTags = albumTags[albumName + '/' + albumItems[albumPos]];
+
+ if (imageTags == null) {
+ searchService.getTags(albumName, albumItems[albumPos]).addCallback(getTagsResponse);
+
+ } else {
+ showTags(imageTags);
+ }
+
}
function getTagsResponse(items, exception) {
- if(exception) {
+ if (exception) {
alert(exception.msg);
// logout();
return;
}
-
+
albumTags[items.imageID] = items.tags;
-
- if (albumName + '/' + albumItems[albumPos] == items.imageID) {
- showTags(items.tags);
+
+ if (albumName + '/' + albumItems[albumPos] == items.imageID) {
+ showTags(items.tags);
}
-
+
}
function showTags(tags) {
- var table=document.getElementById('tableTags');
- var textField = document.getElementById('addtag-input');
- textField.value = "";
- deleteTableRows(table);
+ var table = document.getElementById('tableTags');
+ var textField = document.getElementById('addtag-input');
+ textField.value = "";
+ deleteTableRows(table);
- var lastRow = 0;
- for (i = 0; i < tags.length; i++) {
- var row = table.insertRow(lastRow++);
+ var lastRow = 0;
+ for (i = 0; i < tags.length; i++) {
+ var row = table.insertRow(lastRow++);
var column = row.insertCell(0);
- var divElement = document.createElement("div");
+ var divElement = document.createElement("div");
var tagElement = document.createElement("a");
- tagElement.href = "javascript:executeSearch('tag:" + tags[i] + "')";
+ tagElement.href = "javascript:executeSearch('tag:" + tags[i] + "')";
tagElement.innerHTML = tags[i];
divElement.id = tags[i];
divElement.style.display = 'inline';
divElement.onmouseover = function (evt) {
- this.removeButton.style.display = 'inline';
+ this.removeButton.style.display = 'inline';
this.removeButton.style.visibility = 'visible';
};
divElement.onmouseout = function (evt) {
- this.removeButton.style.display = 'none';
+ this.removeButton.style.display = 'none';
this.removeButton.style.visibility = 'hidden';
};
-
- divElement.appendChild(tagElement);
-
+
+ divElement.appendChild(tagElement);
+
var removeElement = document.createElement("a");
removeElement['class'] = "removeTag";
removeElement.href = "javascript:removeTag('" + tags[i] + "')";
@@ -486,79 +563,79 @@
removeElement.style.visibility = 'hidden';
divElement.removeButton = removeElement;
divElement.appendChild(removeElement);
-
+
column.appendChild(divElement);
-
- }
-
- setVisibility('tableTags',true);
-
+
+ }
+
+ setVisibility('tableTags', true);
+
}
function removeTag(tag) {
- searchService.removeTag(albumName, albumItems[albumPos], tag);
- var table=document.getElementById('tableTags');
-
- for (i = 0 ; i < table.rows.length ; i++) {
-
- if (table.rows[i].cells[0].firstChild.id == tag) {
- table.deleteRow(i);
- break;
- }
-
- }
-
-
+ searchService.removeTag(albumName, albumItems[albumPos], tag);
+ var table = document.getElementById('tableTags');
+
+ for (i = 0; i < table.rows.length; i++) {
+
+ if (table.rows[i].cells[0].firstChild.id == tag) {
+ table.deleteRow(i);
+ break;
+ }
+
+ }
+
+
}
function gallery_getAlbumPicturesResponse(items, exception) {
- if(exception) {
- // alert(exception.msg);
+ if (exception) {
+ // alert(exception.msg);
displayGallery();
- logout();
- // return;
+ logout();
+ // return;
}
albumItems = items;
albumPos = 0;
-
+
if (albumImageToBeLoaded != null) {
-
- for (i = 0 ; i < items.length ; i++) {
-
- if (items[i] == albumImageToBeLoaded) {
- albumPos = i;
- albumImageToBeLoaded = null;
-
- }
-
- }
-
+
+ for (i = 0; i < items.length; i++) {
+
+ if (items[i] == albumImageToBeLoaded) {
+ albumPos = i;
+ albumImageToBeLoaded = null;
+
+ }
+
+ }
+
}
-
+
showAlbum();
}
function gallery_getRemoteAlbumPicturesResponse(items, exception) {
- if(exception) {
- // alert(exception.msg);
+ if (exception) {
+ // alert(exception.msg);
displayGallery();
- logout();
- // return;
+ logout();
+ // return;
}
albumItems = items;
albumPos = 0;
if (albumImageToBeLoaded != null) {
- for (i = 0 ; i < items.length ; i++) {
+ for (i = 0; i < items.length; i++) {
- if (items[i] == albumImageToBeLoaded) {
- albumPos = i;
- albumImageToBeLoaded = null;
+ if (items[i] == albumImageToBeLoaded) {
+ albumPos = i;
+ albumImageToBeLoaded = null;
- }
+ }
- }
+ }
}
@@ -566,33 +643,33 @@
}
function showAlbum() {
- if(albumItems.length > 0) {
+ if (albumItems.length > 0) {
showImage(albumPos);
}
displayAlbum();
}
function showRemoteAlbum() {
- if(albumItems.length > 0) {
+ if (albumItems.length > 0) {
showRemoteImage(albumPos);
}
displayAlbum();
}
function displayAlbum() {
- setVisibility('gallery',false);
- setVisibility('album',true);
- setVisibility('search',false);
+ setVisibility('gallery', false);
+ setVisibility('album', true);
+ setVisibility('search', false);
}
function showImage(albumPos) {
var img = document.createElement("img");
img.onload = function(evt) {
document.getElementById("albumImage").src = this.src;
- document.getElementById("albumImage").width=this.width;
- document.getElementById("albumImage").height=this.height;
+ document.getElementById("albumImage").width = this.width;
+ document.getElementById("albumImage").height = this.height;
}
- img.src = window.location.href + "gallery/"+ this.albumName +"/" + albumItems[albumPos];
+ img.src = window.location.href + "gallery/" + this.albumName + "/" + albumItems[albumPos];
loadTags(albumPos);
remoteFlag = 0;
return false;
@@ -602,8 +679,8 @@
var img = document.createElement("img");
img.onload = function(evt) {
document.getElementById("albumImage").src = this.src;
- document.getElementById("albumImage").width=this.width;
- document.getElementById("albumImage").height=this.height;
+ document.getElementById("albumImage").width = this.width;
+ document.getElementById("albumImage").height = this.height;
}
img.src = albumItems[albumPos];
remoteFlag = 1;
@@ -613,33 +690,33 @@
function goNext() {
- if(albumPos < albumItems.length - 1) {
+ if (albumPos < albumItems.length - 1) {
albumPos++;
- if(remoteFlag ==1) {
- showRemoteImage(albumPos);
+ if (remoteFlag == 1) {
+ showRemoteImage(albumPos);
} else {
- showImage(albumPos);
+ showImage(albumPos);
}
}
}
function goPrevious() {
- if(albumPos > 0) {
+ if (albumPos > 0) {
albumPos--;
- if(remoteFlag ==1) {
- showRemoteImage(albumPos);
+ if (remoteFlag == 1) {
+ showRemoteImage(albumPos);
} else {
- showImage(albumPos);
+ showImage(albumPos);
}
}
}
function setVisibility(divId, visible) {
- //valid values { visible, hidden }
+ //valid values { visible, hidden }
if (document.getElementById) {
var element = document.getElementById(divId)
- if(visible) {
+ if (visible) {
element.style.display = 'block';
element.style.visibility = 'visible';
} else {
@@ -649,83 +726,83 @@
}
}
-function onGoPreviousMouseOver(){
- if(albumPos == 0){
- document.previous.src=prev_off.src;
- }else{
- document.previous.src=prev_on.src;
+function onGoPreviousMouseOver() {
+ if (albumPos == 0) {
+ document.previous.src = prev_off.src;
+ } else {
+ document.previous.src = prev_on.src;
}
}
-function onGoNextMouseOver(){
- if(albumPos == albumItems.length - 1){
- document.next.src=next_off.src;
- }else{
- document.next.src=next_on.src;
+function onGoNextMouseOver() {
+ if (albumPos == albumItems.length - 1) {
+ document.next.src = next_off.src;
+ } else {
+ document.next.src = next_on.src;
}
}
-function goSlideShow(){
- if(slideShowSpeed==0){
- slideShowSpeed=1;
+function goSlideShow() {
+ if (slideShowSpeed == 0) {
+ slideShowSpeed = 1;
clearTimeout(timer);
startTimer(5000);
- }else if(slideShowSpeed==1) {
- slideShowSpeed=2;
+ } else if (slideShowSpeed == 1) {
+ slideShowSpeed = 2;
clearTimeout(timer);
startTimer(2000);
- }else{
- slideShowSpeed=0;
+ } else {
+ slideShowSpeed = 0;
clearTimeout(timer);
}
}
-function beforeClick(){
- clearTimeout(timer);
- slideShowSpeed=0;
- document.show.src=slide_before_start.src;
+function beforeClick() {
+ clearTimeout(timer);
+ slideShowSpeed = 0;
+ document.show.src = slide_before_start.src;
}
-function search(){
- var query = document.getElementById("search-input").value;
- executeSearch(query);
+function search() {
+ var query = document.getElementById("search-input").value;
+ executeSearch(query);
}
function executeSearch(query) {
- //searchService.search(query).addCallback(searchResponse);
- searchService.searchToUser(query,SECURITY_TOKEN).addCallback(searchResponse);
+ //searchService.search(query).addCallback(searchResponse);
+ searchService.searchToUser(query, SECURITY_TOKEN).addCallback(searchResponse);
}
-function onSlideShow(){
- if(slideShowSpeed==0){
- document.show.src=show_slide_slow_on.src;
- }else if(slideShowSpeed==1){
- document.show.src=show_slide_on.src;
- }else{
- document.show.src=slide_pause.src;
- }
-}
-
-function offSlideShow(){
- if(slideShowSpeed==0){
- document.show.src=slide_before_start.src;
- }else if(slideShowSpeed==1){
- document.show.src=show_slide_slow.src;
- }else{
- document.show.src=show_slide.src;
- }
-}
-
-function startTimer(time){
- if(albumPos < albumItems.length - 1) {
- albumPos++;
- }else{
- albumPos=1;
- }
- if(remoteFlag == 1) {
- showRemoteImage(albumPos);
+function onSlideShow() {
+ if (slideShowSpeed == 0) {
+ document.show.src = show_slide_slow_on.src;
+ } else if (slideShowSpeed == 1) {
+ document.show.src = show_slide_on.src;
} else {
- showImage(albumPos);
+ document.show.src = slide_pause.src;
}
- timer=setTimeout("startTimer("+time+")",time);
+}
+
+function offSlideShow() {
+ if (slideShowSpeed == 0) {
+ document.show.src = slide_before_start.src;
+ } else if (slideShowSpeed == 1) {
+ document.show.src = show_slide_slow.src;
+ } else {
+ document.show.src = show_slide.src;
+ }
+}
+
+function startTimer(time) {
+ if (albumPos < albumItems.length - 1) {
+ albumPos++;
+ } else {
+ albumPos = 1;
+ }
+ if (remoteFlag == 1) {
+ showRemoteImage(albumPos);
+ } else {
+ showImage(albumPos);
+ }
+ timer = setTimeout("startTimer(" + time + ")", time);
}
diff --git a/photark-webapp/src/main/webapp/WEB-INF/web.composite b/photark-webapp/src/main/webapp/WEB-INF/web.composite
index c72d226..6583ec8 100644
--- a/photark-webapp/src/main/webapp/WEB-INF/web.composite
+++ b/photark-webapp/src/main/webapp/WEB-INF/web.composite
@@ -190,6 +190,19 @@
<reference name="accessmanager" target="AccessManager"/>
</component>
-
+
+
+ <component name="GenericFriendFinder">
+ <implementation.java class="org.apache.photark.face.services.applications.generic.GenericFriendFinderImpl"/>
+
+ <service name="GenericFriendFinder">
+ <interface.java interface="org.apache.photark.face.services.applications.generic.GenericFriendFinder"/>
+ <binding.sca name="local"/>
+ <tuscany:binding.jsonrpc uri="/GenericFriendFinder"/>
+ </service>
+ <reference name="faceRecognitionService" target="FaceRecognitionService"/>
+ <reference name="accessmanager" target="AccessManager"/>
+
+ </component>
</composite>