Skip to content

Instantly share code, notes, and snippets.

View saulovenancio's full-sized avatar

Saulo Venancio saulovenancio

View GitHub Profile
@saulovenancio
saulovenancio / index.html
Created September 17, 2014 17:12
[add your bin description] // source http://jsbin.com/ricabu/1
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
package com.sample.osgi;
import java.util.Map;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Property;
@Component(label = "Service Label", description = "Service Description", metatype = true, immediate = true)
Note 1: The following CQ curl commands assumes a admin:admin username and password.
Note 2: For Windows/Powershell users: use two "" when doing a -F cURL command.
Example: -F"":operation=delete""
Note 3: Quotes around name of package (or name of zip file, or jar) should be included.
Uninstall a bundle (use http://localhost:4505/system/console/bundles to access the Apache Felix web console)
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/"name of bundle"
Install a bundle
curl -u admin:admin -F action=install -F bundlestartlevel=20 -F
def find(key, dictionary):
for k, v in dictionary.iteritems():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
for d in v:
for result in find(key, d):
@Service
@Component(immediate=true)
public class WriteServiceImpl implements WriteService {
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference
private ResourceResolverFactory resolverFactory;
//If you are planning to use repository session
@Service
@Component(immediate=true)
public class ReadServiceImpl implements ReadService{
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference
private ResourceResolverFactory resolverFactory;
//If you are planning to use repository session
import javax.jcr.Node;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.adapter.AdapterFactory;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingConstants;
import org.apache.sling.event.EventUtil;
import org.apache.sling.event.jobs.JobProcessor;
import org.apache.sling.event.jobs.JobUtil;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventConstants;
@saulovenancio
saulovenancio / AuthCheckerServlet.java
Last active August 29, 2015 14:16 — forked from cqtips/AuthCheckerServlet.java
check if currentPersmissions cna load the resource. from uri parameter , servlet;.
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@SlingServlet(paths = "/bin/permissioncheck/html", generateComponent = true, generateService = true)
public class AuthCheckerServlet extends SlingSafeMethodsServlet {
public void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) {
@saulovenancio
saulovenancio / Test.java
Last active August 29, 2015 14:16 — forked from cqtips/Test.java
reverse replication of binary content on publish instance
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Calendar;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.ValueFactory;