Skip to content

Commit

Permalink
updated pom files; fixed import folder issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hngrylobster committed Sep 12, 2022
1 parent be32b76 commit fff5121
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 23 deletions.
2 changes: 1 addition & 1 deletion current/EMBED.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>com.brightcove</groupId>
<artifactId>com.brightcove.connector</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<type>zip</type>
</dependency>
```
Expand Down
2 changes: 1 addition & 1 deletion current/all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion current/analyse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion current/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>brightcove.core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Version("1.0")
@Version("6.0")
package com.coresecure.brightcove.wrapper.models;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.coresecure.brightcove.wrapper.sling.ServiceUtil;
import com.coresecure.brightcove.wrapper.utils.Constants;
import com.day.cq.commons.jcr.JcrUtil;
import com.day.crx.JcrConstants;

import org.apache.jackrabbit.oak.jcr.Jcr;
import org.apache.sling.api.resource.ResourceResolver;
Expand Down Expand Up @@ -124,6 +125,8 @@ public void run()
session.save();
final ServiceUtil serviceUtil = new ServiceUtil(requestedAccount);

LOGGER.trace("<<< GETTING FOLDER DATA");

JSONArray folders = serviceUtil.getFoldersAsJsonArray();
LOGGER.trace("<<< " + basePath + " USED AS BASE PATH!");
LOGGER.trace("<<< " + folders.length() + " FOLDERS FOUND IN ACCOUNT: " + requestedAccount);
Expand All @@ -134,8 +137,6 @@ public void run()
String folderId = folder.getString("id");
String folderName = folder.getString("name");

String localFolderName = folderName.replaceAll(" ", "_").toLowerCase();

// check if folder (1) already exists or (2) has been renamed
QueryManager qm = session.getWorkspace().getQueryManager();
String query = "SELECT * FROM [sling:OrderedFolder] AS node "
Expand All @@ -151,22 +152,17 @@ public void run()
Node existingFolder = results.nextNode();
existingFolder.setProperty("jcr:title", folderName);
LOGGER.trace("<<< " + existingFolder.getPath() + " EXISTING FOLDER FOUND!");

// we don't need to move if we use the folderId as the node path!
// if (!existingFolder.getPath().endsWith(localFolderName)) {
// // the folder has been renamed
// LOGGER.trace("<<< " + existingFolder + " compared to " + localFolderName);
// LOGGER.trace("<<< " + folderName + " HAS BEEN RENAMED AND MUST BE MOVED!");
// session.move(existingFolder.getPath(), basePath + localFolderName);
// }
session.save();

} else {

// folder does not exist so we need to create it
Node folderNode = JcrUtil.createPath(basePath + folderId,
"sling:OrderedFolder", session);
folderNode.setProperty("jcr:title", folderName);
LOGGER.trace("<<< " + folderId + " NEW FOLDER TITLE SET!");
folderNode.setProperty("brc_folder_id", folderId);
folderNode.setProperty("jcr:title", folderName);
session.save();

LOGGER.trace("<<< " + folderNode.getPath() + " NEW FOLDER CREATED!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@
import org.apache.sling.commons.mime.MimeTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Session;
import javax.servlet.ServletException;
import java.io.IOException;
Expand Down Expand Up @@ -132,6 +136,52 @@ private void executeRequest(final SlingHttpServletRequest req, final SlingHttpSe
session.save();
final ServiceUtil serviceUtil = new ServiceUtil(requestedAccount);

JSONArray folders = serviceUtil.getFoldersAsJsonArray();
LOGGER.trace("<<< " + basePath + " USED AS BASE PATH!");
LOGGER.trace("<<< " + folders.length() + " FOLDERS FOUND IN ACCOUNT: " + requestedAccount);

if (folders.length() > 0) {
for (int x = 0; x < folders.length(); x++) {
JSONObject folder = folders.getJSONObject(x);
String folderId = folder.getString("id");
String folderName = folder.getString("name");

// check if folder (1) already exists or (2) has been renamed
QueryManager qm = session.getWorkspace().getQueryManager();
String query = "SELECT * FROM [sling:OrderedFolder] AS node "
+ "WHERE ISDESCENDANTNODE(node, \"" + basePath +"\") "
+ "AND CONTAINS([brc_folder_id], \"" + folderId + "\")";
Query q = qm.createQuery(query, Query.JCR_SQL2);
QueryResult result = q.execute();
NodeIterator results = result.getNodes();

if (results.hasNext()) {

// folder exists so update the title if it has been renamed
Node existingFolder = results.nextNode();
existingFolder.setProperty("jcr:title", folderName);
LOGGER.trace("<<< " + existingFolder.getPath() + " EXISTING FOLDER FOUND!");
session.save();

} else {

// folder does not exist so we need to create it
Node folderNode = JcrUtil.createPath(basePath + folderId,
"sling:OrderedFolder", session);
LOGGER.trace("<<< " + folderId + " NEW FOLDER TITLE SET!");
folderNode.setProperty("brc_folder_id", folderId);
folderNode.setProperty("jcr:title", folderName);
session.save();

LOGGER.trace("<<< " + folderNode.getPath() + " NEW FOLDER CREATED!");

}

// save everything to the repository
session.save();
}
}

//GET VIDEOS
int startOffset = 0;
JSONObject jsonObject = new JSONObject(serviceUtil.searchVideo("", startOffset, 0)); //QUERY<------
Expand Down
2 changes: 1 addition & 1 deletion current/it.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion current/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<packaging>pom</packaging>
<version>2.0.0</version>
<version>6.0.0</version>
<description>Brightcove Connector</description>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion current/ui.apps.structure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion current/ui.apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion current/ui.config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion current/ui.content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion current/ui.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>com.coresecure</groupId>
<artifactId>brightcove</artifactId>
<version>2.0.0</version>
<version>6.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down

0 comments on commit fff5121

Please sign in to comment.