use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method updateElementType.
@Override
public synchronized void updateElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
RepositoryFile folder = getElementTypeRepositoryFolder(namespace, elementType);
RepositoryFile detailsFile = findChildByName(folder.getId(), ELEMENT_TYPE_DETAILS_FILENAME, true);
DataNode dataNode = getElementTypeDataNode(elementType);
pur.updateFile(detailsFile, new NodeRepositoryFileData(dataNode), null);
elementType.setMetaStoreName(getName());
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method getElement.
@Override
public IMetaStoreElement getElement(String namespace, IMetaStoreElementType elementType, String elementId) throws MetaStoreException {
NodeRepositoryFileData data = pur.getDataForRead(elementId, NodeRepositoryFileData.class);
if (data == null) {
return null;
}
IMetaStoreElement element = newElement();
element.setId(elementId);
element.setElementType(elementType);
DataNode dataNode = data.getNode();
dataNodeToElement(dataNode, element);
return element;
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryAuthorizationIT method testInheritingNodeRemoval.
@Test
public void testInheritingNodeRemoval() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
final String parentFolderPath = ClientRepositoryPaths.getPublicFolderPath();
RepositoryFile parentFolder = repo.getFile(parentFolderPath);
DataNode node = new DataNode("kdjd");
node.setProperty("ddf", "ljsdfkjsdkf");
DataNode newChild1 = node.addNode("herfkmdx");
NodeRepositoryFileData data = new NodeRepositoryFileData(node);
RepositoryFile repoFile = repo.createFile(parentFolder.getId(), new RepositoryFile.Builder("test").build(), data, null);
RepositoryFileAcl acl = repo.getAcl(repoFile.getId());
RepositoryFileSid suzySid = new RepositoryFileSid(userNameUtils.getPrincipleId(tenantAcme, USERNAME_SUZY));
RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder(acl).ace(suzySid, EnumSet.of(RepositoryFilePermission.READ, RepositoryFilePermission.WRITE));
repo.updateAcl(newAclBuilder.build());
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
repoFile = repo.getFile(repoFile.getPath());
node = new DataNode("kdjd");
node.setProperty("foo", "bar");
newChild1 = node.addNode("sdfsdf");
data = new NodeRepositoryFileData(node);
repo.updateFile(repoFile, data, "testUpdate");
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testCreateACLNodeFile.
@Test
public void testCreateACLNodeFile() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
final String expectedName = "aclnode";
final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY);
RepositoryFile parentFolder = repo.getFile(parentFolderPath);
final String expectedPath = parentFolderPath + RepositoryFile.SEPARATOR + expectedName;
DataNode node = new DataNode("kdjd");
DataNode newChild1 = node.addNode("herfkmdx");
DataNode newChild2 = node.addNode(JcrStringHelper.fileNameEncode("pppq/qqs2"));
newChild2.setProperty(JcrStringHelper.fileNameEncode("ttt*ss4"), "843skdfj33ksaljdfj");
NodeRepositoryFileData data = new NodeRepositoryFileData(node);
RepositoryFile newFile = repo.createFile(parentFolder.getId(), new RepositoryFile.Builder(expectedName).aclNode(true).build(), data, null);
assertNotNull(newFile.getId());
RepositoryFile foundFile = repo.getFile(expectedPath);
assertNotNull(foundFile);
assertEquals(expectedName, foundFile.getName());
DataNode foundNode = repo.getDataForRead(foundFile.getId(), NodeRepositoryFileData.class).getNode();
assertEquals(node.getName(), foundNode.getName());
assertNotNull(foundNode.getId());
assertTrue(foundNode.hasNode("herfkmdx"));
DataNode foundChild1 = foundNode.getNode("herfkmdx");
assertNotNull(foundChild1.getId());
assertEquals(newChild1.getName(), foundChild1.getName());
assertEquals(newChild1.getProperty("shadow"), foundChild1.getProperty("shadow"));
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-platform by pentaho.
the class NodeRepositoryFileDataTransformer method internalCreateOrUpdate.
protected void internalCreateOrUpdate(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Node jcrParentNode, final DataNode dataNode) throws RepositoryException {
// $NON-NLS-1$
final String prefix = session.getNamespacePrefix(PentahoJcrConstants.PHO_NS) + ":";
// get or create the node represented by dataNode
Node jcrNode = null;
String nodeName = dataNode.getName();
// Not need to check the name if we encoded it
// JcrRepositoryFileUtils.checkName( dataNode.getName() );
nodeName = JcrStringHelper.fileNameEncode(nodeName);
if (NodeHelper.hasNode(jcrParentNode, prefix, nodeName)) {
jcrNode = NodeHelper.getNode(jcrParentNode, prefix, nodeName);
} else {
jcrNode = jcrParentNode.addNode(prefix + nodeName, pentahoJcrConstants.getPHO_NT_INTERNALFOLDER());
}
// set any properties represented by dataNode
for (DataProperty dataProp : dataNode.getProperties()) {
String propName = dataProp.getName();
// Not need to check the name if we encoded it
// JcrRepositoryFileUtils.checkName( propName );
propName = prefix + JcrStringHelper.fileNameEncode(propName);
switch(dataProp.getType()) {
case STRING:
{
jcrNode.setProperty(propName, dataProp.getString());
break;
}
case BOOLEAN:
{
jcrNode.setProperty(propName, dataProp.getBoolean());
break;
}
case DOUBLE:
{
jcrNode.setProperty(propName, dataProp.getDouble());
break;
}
case LONG:
{
jcrNode.setProperty(propName, dataProp.getLong());
break;
}
case DATE:
{
Calendar cal = Calendar.getInstance();
cal.setTime(dataProp.getDate());
jcrNode.setProperty(propName, cal);
break;
}
case REF:
{
jcrNode.setProperty(propName, session.getNodeByIdentifier(dataProp.getRef().getId().toString()));
break;
}
default:
{
throw new IllegalArgumentException();
}
}
}
// now process any child nodes of dataNode
for (DataNode child : dataNode.getNodes()) {
internalCreateOrUpdate(session, pentahoJcrConstants, jcrNode, child);
}
}
Aggregations