mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1641 (Create Relationship Service)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@85790 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1523,4 +1523,59 @@
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Relationship Service -->
|
||||
|
||||
<bean id="relationshipService" class="org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipServiceImpl">
|
||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService"/>
|
||||
<property name="dictionaryService" ref="DictionaryService" />
|
||||
<property name="namespacePrefixResolver" ref="namespaceService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="RelationshipService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="relationshipService"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref local="RelationshipService_transaction"/>
|
||||
<idref bean="exceptionTranslator"/>
|
||||
<idref local="RelationshipService_security"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="RelationshipService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
|
||||
<property name="transactionManager">
|
||||
<ref bean="transactionManager"/>
|
||||
</property>
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">${server.transaction.mode.default}</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="RelationshipService_security" parent="baseSecurity">
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
<![CDATA[
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.getRelationshipDefinitions=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.getRelationshipDefinition=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.createRelationshipDefinition=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.updateReleationshipDefinition=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.removeRelationshipDefinition=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.existsRelationshipDefinition=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.getRelationshipsFrom=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.getRelationshipsTo=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.addRelationship=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.removeRelationship=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService.*=RM_DENY
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
|
@@ -64,14 +64,13 @@
|
||||
|
||||
<!-- Base bean for custom reference definition web scripts -->
|
||||
<bean id="rmCustomReferenceDefinitionBase" parent="rmBaseWebscript" abstract="true">
|
||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService" />
|
||||
<property name="relationshipService" ref="RelationshipService" />
|
||||
</bean>
|
||||
|
||||
<!-- REST impl for GET Custom Reference Definitions -->
|
||||
<bean id="webscript.org.alfresco.rma.customrefdefinitions.get"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.script.CustomReferenceDefinitionsGet"
|
||||
parent="rmCustomReferenceDefinitionBase">
|
||||
<property name="dictionaryService" ref="DictionaryService" />
|
||||
</bean>
|
||||
|
||||
<!-- REST impl for PUT Custom Reference Definitions -->
|
||||
@@ -88,8 +87,7 @@
|
||||
<bean id="webscript.org.alfresco.rma.customrefs.get"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefsGet"
|
||||
parent="rmBaseWebscript">
|
||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService" />
|
||||
<property name="dictionaryService" ref="DictionaryService" />
|
||||
<property name="relationshipService" ref="RelationshipService" />
|
||||
<property name="capabilityService" ref="CapabilityService" />
|
||||
</bean>
|
||||
|
||||
@@ -97,7 +95,7 @@
|
||||
<bean id="webscript.org.alfresco.rma.customref.post"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefPost"
|
||||
parent="rmBaseWebscript">
|
||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService" />
|
||||
<property name="relationshipService" ref="RelationshipService" />
|
||||
<property name="ruleService" ref="RuleService" />
|
||||
</bean>
|
||||
|
||||
@@ -105,7 +103,7 @@
|
||||
<bean id="webscript.org.alfresco.rma.customref.delete"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefDelete"
|
||||
parent="rmBaseWebscript">
|
||||
<property name="recordsManagementAdminService" ref="RecordsManagementAdminService" />
|
||||
<property name="relationshipService" ref="RelationshipService" />
|
||||
<property name="ruleService" ref="RuleService" />
|
||||
</bean>
|
||||
|
||||
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Interface representing the relationship
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public interface Relationship
|
||||
{
|
||||
/**
|
||||
* Gets the unique name of the relationship
|
||||
*
|
||||
* @return The unique name of the relationship
|
||||
*/
|
||||
String getUniqueName();
|
||||
|
||||
/**
|
||||
* Gets the source of the relationship
|
||||
*
|
||||
* @return The source of the relationship
|
||||
*/
|
||||
NodeRef getSource();
|
||||
|
||||
/**
|
||||
* Gets the target of the relationship
|
||||
*
|
||||
* @return The target of the relationship
|
||||
*/
|
||||
NodeRef getTarget();
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||
|
||||
/**
|
||||
* Interface representing the relationship definition
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public interface RelationshipDefinition
|
||||
{
|
||||
/**
|
||||
* Gets the unique name of the relationship definition
|
||||
*
|
||||
* @return The unique name of the relationship definition
|
||||
*/
|
||||
String getUniqueName();
|
||||
|
||||
/**
|
||||
* Gets the type of the relationship definition
|
||||
*
|
||||
* @return The type of the relationship definition
|
||||
*/
|
||||
RelationshipType getType();
|
||||
|
||||
/**
|
||||
* Gets the display name of the relationship definition
|
||||
*
|
||||
* @return The display name of the relationship definition
|
||||
*/
|
||||
RelationshipDisplayName getDisplayName();
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
import static org.alfresco.util.ParameterCheck.mandatoryString;
|
||||
|
||||
/**
|
||||
* Relationship definition implementation
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class RelationshipDefinitionImpl implements RelationshipDefinition
|
||||
{
|
||||
/** The unique name of the relationship definition */
|
||||
private String uniqueName;
|
||||
|
||||
/** The type of the relationship definition */
|
||||
private RelationshipType type;
|
||||
|
||||
/** The display name of the relationship definition */
|
||||
private RelationshipDisplayName displayName;
|
||||
|
||||
/**
|
||||
* Constructor for creating a relationship definition
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship definition
|
||||
* @param type The type of the relationship definition
|
||||
* @param displayName The display name of the relationship definition
|
||||
*/
|
||||
public RelationshipDefinitionImpl(String uniqueName, RelationshipType type, RelationshipDisplayName displayName)
|
||||
{
|
||||
mandatoryString("uniqueName", uniqueName);
|
||||
mandatory("type", type);
|
||||
mandatory("displayName", displayName);
|
||||
|
||||
setUniqueName(uniqueName);
|
||||
setType(type);
|
||||
setDisplayName(displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getUniqueName()
|
||||
*/
|
||||
@Override
|
||||
public String getUniqueName()
|
||||
{
|
||||
return this.uniqueName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the relationship definition
|
||||
*
|
||||
* @param uniqueName The name of the relationship definition
|
||||
*/
|
||||
private void setUniqueName(String uniqueName)
|
||||
{
|
||||
this.uniqueName = uniqueName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getType()
|
||||
*/
|
||||
@Override
|
||||
public RelationshipType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the relationship definition
|
||||
*
|
||||
* @param type The type of the relationship definition
|
||||
*/
|
||||
private void setType(RelationshipType type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition#getDisplayName()
|
||||
*/
|
||||
@Override
|
||||
public RelationshipDisplayName getDisplayName()
|
||||
{
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name of the relationship definition
|
||||
*
|
||||
* @param displayName The display name of the relationship definition
|
||||
*/
|
||||
private void setDisplayName(RelationshipDisplayName displayName)
|
||||
{
|
||||
this.displayName = displayName;
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||
|
||||
/**
|
||||
* POJO representing the relationship display name
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class RelationshipDisplayName
|
||||
{
|
||||
/** The label text for {@link RelationshipType#BIDIRECTIONAL} */
|
||||
private String labelText;
|
||||
|
||||
/** The source text for {@link RelationshipType#PARENTCHILD} */
|
||||
private String sourceText;
|
||||
|
||||
/** The target text for {@link RelationshipType#PARENTCHILD} */
|
||||
private String targetText;
|
||||
|
||||
/**
|
||||
* Constructor for creating the relationship display name
|
||||
*
|
||||
* @param sourceText The source text of the relationship definition
|
||||
* @param targetText The target text of the relationship definition
|
||||
* @param labelText The label text of the relationship definition
|
||||
*/
|
||||
public RelationshipDisplayName(String sourceText, String targetText, String labelText)
|
||||
{
|
||||
// Parameters might be blank. No check required.
|
||||
|
||||
setSourceText(sourceText);
|
||||
setTargetText(targetText);
|
||||
setLabelText(labelText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label text of {@link RelationshipType#BIDIRECTIONAL}
|
||||
*
|
||||
* @return The label text of {@link RelationshipType#BIDIRECTIONAL}
|
||||
*/
|
||||
public String getLabelText()
|
||||
{
|
||||
return this.labelText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label text of {@link RelationshipType#BIDIRECTIONAL}
|
||||
*
|
||||
* @param labelText The label text of {@link RelationshipType#BIDIRECTIONAL}
|
||||
*/
|
||||
private void setLabelText(String labelText)
|
||||
{
|
||||
this.labelText = labelText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source text of {@link RelationshipType#PARENTCHILD}
|
||||
*
|
||||
* @return The source text of {@link RelationshipType#PARENTCHILD}
|
||||
*/
|
||||
public String getSourceText()
|
||||
{
|
||||
return this.sourceText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source text of {@link RelationshipType#PARENTCHILD}
|
||||
*
|
||||
* @param sourceText The source text of {@link RelationshipType#PARENTCHILD}
|
||||
*/
|
||||
private void setSourceText(String sourceText)
|
||||
{
|
||||
this.sourceText = sourceText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target text of {@link RelationshipType#PARENTCHILD}
|
||||
*
|
||||
* @return The target text of {@link RelationshipType#PARENTCHILD}
|
||||
*/
|
||||
public String getTargetText()
|
||||
{
|
||||
return this.targetText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target text of {@link RelationshipType#PARENTCHILD}
|
||||
*
|
||||
* @param targetText The target text of {@link RelationshipType#PARENTCHILD}
|
||||
*/
|
||||
private void setTargetText(String targetText)
|
||||
{
|
||||
this.targetText = targetText;
|
||||
}
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
import static org.alfresco.util.ParameterCheck.mandatoryString;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Relationship implementation
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class RelationshipImpl implements Relationship
|
||||
{
|
||||
/** The unique name of the relationship */
|
||||
private String uniqueName;
|
||||
|
||||
/** The source of the relationship */
|
||||
private NodeRef source;
|
||||
|
||||
/** The target of the relationship */
|
||||
private NodeRef target;
|
||||
|
||||
/**
|
||||
* Constructor for creating a relationship
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship
|
||||
* @param source The source of the relationship
|
||||
* @param target The target of the relationship
|
||||
*/
|
||||
public RelationshipImpl(String uniqueName, NodeRef source, NodeRef target)
|
||||
{
|
||||
mandatoryString("uniqueName", uniqueName);
|
||||
mandatory("source", source);
|
||||
mandatory("target", target);
|
||||
|
||||
setUniqueName(uniqueName);
|
||||
setSource(source);
|
||||
setTarget(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getUniqueName()
|
||||
*/
|
||||
@Override
|
||||
public String getUniqueName()
|
||||
{
|
||||
return uniqueName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the unique name of the relationship
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship
|
||||
*/
|
||||
private void setUniqueName(String uniqueName)
|
||||
{
|
||||
this.uniqueName = uniqueName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getSource()
|
||||
*/
|
||||
@Override
|
||||
public NodeRef getSource()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the relationship
|
||||
*
|
||||
* @param source The source of the relationship
|
||||
*/
|
||||
private void setSource(NodeRef source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.Relationship#getTarget()
|
||||
*/
|
||||
@Override
|
||||
public NodeRef getTarget()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target of the relationship
|
||||
*
|
||||
* @param target The target of the relationship
|
||||
*/
|
||||
private void setTarget(NodeRef target)
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* The relationship service interface
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public interface RelationshipService
|
||||
{
|
||||
/**
|
||||
* Gets all the existing relationship definitions
|
||||
*
|
||||
* @return All existing relationship definitions
|
||||
*/
|
||||
Set<RelationshipDefinition> getRelationshipDefinitions();
|
||||
|
||||
/**
|
||||
* Gets the relationship definition for the given unique name
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship definition
|
||||
* @return The relationship definition for the given unique name if it exist, <code>null</code> otherwise
|
||||
*/
|
||||
RelationshipDefinition getRelationshipDefinition(String uniqueName);
|
||||
|
||||
/**
|
||||
* Creates a relationship definition using the display name
|
||||
*
|
||||
* @param displayName The display name of the relationship definition
|
||||
* @return The new relationship definition
|
||||
*/
|
||||
RelationshipDefinition createRelationshipDefinition(RelationshipDisplayName displayName);
|
||||
|
||||
/**
|
||||
* Updates an existing relationship definition
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship definition
|
||||
* @param displayName The display name of the relationship definition
|
||||
* @return The updated relationship definition
|
||||
*/
|
||||
RelationshipDefinition updateReleationshipDefinition(String uniqueName, RelationshipDisplayName displayName);
|
||||
|
||||
/**
|
||||
* Removes a relationship definition
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship definition
|
||||
* @return <code>true</code> if the relationship definition was removed successfully, <code>false</code> otherwise
|
||||
*/
|
||||
boolean removeRelationshipDefinition(String uniqueName);
|
||||
|
||||
/**
|
||||
* Checks if a relationship exists or not
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship definition
|
||||
* @return <code>true</code> if the relationship definition exists, <code>false</code> otherwise
|
||||
*/
|
||||
boolean existsRelationshipDefinition(String uniqueName);
|
||||
|
||||
/**
|
||||
* Gets all the relationships that come out from the given node reference
|
||||
*
|
||||
* @param nodeRef The node reference
|
||||
* @return All relationships that come out from the given node reference
|
||||
*/
|
||||
Set<Relationship> getRelationshipsFrom(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Gets all the relationships that go in to the given node reference
|
||||
*
|
||||
* @param nodeRef The node reference
|
||||
* @return All relationships that go in to the given node reference
|
||||
*/
|
||||
Set<Relationship> getRelationshipsTo(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Adds a relationship from the given node <code>source</code>
|
||||
* to the give node <code>target</code> with the given unique name
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship
|
||||
* @param source The node reference which the relationship come from
|
||||
* @param target The node reference which the relationship go to
|
||||
*/
|
||||
void addRelationship(String uniqueName, NodeRef source, NodeRef target);
|
||||
|
||||
/**
|
||||
* Removes the relationship from the given node <code>source</code>
|
||||
* to the given node <code>target</code> with the given unique name
|
||||
*
|
||||
* @param uniqueName The unique name of the relationship
|
||||
* @param source The node reference which the relationship come from
|
||||
* @param target The node reference which the relationship go to
|
||||
*/
|
||||
void removeRelationship(String uniqueName, NodeRef source, NodeRef target);
|
||||
}
|
@@ -0,0 +1,551 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
import static org.alfresco.util.ParameterCheck.mandatoryString;
|
||||
import static org.apache.commons.lang.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* The relationship service implementation
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public class RelationshipServiceImpl implements RelationshipService
|
||||
{
|
||||
/** Records management admin service */
|
||||
private RecordsManagementAdminService recordsManagementAdminService;
|
||||
|
||||
/** Dictionary service */
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
/** Namespace prefix resolver */
|
||||
private NamespacePrefixResolver namespacePrefixResolver;
|
||||
|
||||
/**
|
||||
* Gets the records management admin service instance
|
||||
*
|
||||
* @return The records management admin service instance
|
||||
*/
|
||||
protected RecordsManagementAdminService getRecordsManagementAdminService()
|
||||
{
|
||||
return this.recordsManagementAdminService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the records management admin service instance
|
||||
*
|
||||
* @param recordsManagementAdminService The records management admin service instance
|
||||
*/
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService)
|
||||
{
|
||||
this.recordsManagementAdminService = recordsManagementAdminService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dictionary service instance
|
||||
*
|
||||
* @return The dictionary service instance
|
||||
*/
|
||||
protected DictionaryService getDictionaryService()
|
||||
{
|
||||
return this.dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dictionary service instance
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the namespace prefix resolver instance
|
||||
*
|
||||
* @return The namespace prefix resolver instance
|
||||
*/
|
||||
protected NamespacePrefixResolver getNamespacePrefixResolver()
|
||||
{
|
||||
return this.namespacePrefixResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the namespace prefix resolver instance
|
||||
*
|
||||
* @param namespacePrefixResolver The namespace prefix resolver instance
|
||||
*/
|
||||
public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
this.namespacePrefixResolver = namespacePrefixResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipDefinitions()
|
||||
*/
|
||||
@Override
|
||||
public Set<RelationshipDefinition> getRelationshipDefinitions()
|
||||
{
|
||||
Set<RelationshipDefinition> relationshipDefinitions = new HashSet<RelationshipDefinition>();
|
||||
|
||||
Map<QName, AssociationDefinition> customReferenceDefinitions = getRecordsManagementAdminService().getCustomReferenceDefinitions();
|
||||
for (Map.Entry<QName, AssociationDefinition> customReferenceDefinitionEntry : customReferenceDefinitions.entrySet())
|
||||
{
|
||||
AssociationDefinition associationDefinition = customReferenceDefinitionEntry.getValue();
|
||||
RelationshipDefinition relationshipDefinition = createRelationshipDefinition(associationDefinition);
|
||||
if (relationshipDefinition != null)
|
||||
{
|
||||
relationshipDefinitions.add(relationshipDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
return relationshipDefinitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipDefinition(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public RelationshipDefinition getRelationshipDefinition(String uniqueName)
|
||||
{
|
||||
mandatoryString("uniqueName", uniqueName);
|
||||
|
||||
RelationshipDefinition relationshipDefinition = null;
|
||||
|
||||
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||
if (associationDefinitionQName != null)
|
||||
{
|
||||
AssociationDefinition associationDefinition = getRecordsManagementAdminService().getCustomReferenceDefinitions().get(associationDefinitionQName);
|
||||
relationshipDefinition = createRelationshipDefinition(associationDefinition);
|
||||
}
|
||||
|
||||
return relationshipDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#createRelationshipDefinition(org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName)
|
||||
*/
|
||||
@Override
|
||||
public RelationshipDefinition createRelationshipDefinition(RelationshipDisplayName displayName)
|
||||
{
|
||||
mandatory("displayName", displayName);
|
||||
|
||||
RelationshipType type = determineRelationshipTypeFromDisplayName(displayName);
|
||||
|
||||
QName relationshipDefinitionQName;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case BIDIRECTIONAL:
|
||||
|
||||
String labelText = displayName.getLabelText();
|
||||
relationshipDefinitionQName = getRecordsManagementAdminService().addCustomAssocDefinition(labelText);
|
||||
break;
|
||||
|
||||
case PARENTCHILD:
|
||||
|
||||
String sourceText = displayName.getSourceText();
|
||||
String targetText = displayName.getTargetText();
|
||||
relationshipDefinitionQName = getRecordsManagementAdminService().addCustomChildAssocDefinition(sourceText, targetText);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unsupported relationship type: '")
|
||||
.append(type.toString())
|
||||
.append("'.");
|
||||
throw new AlfrescoRuntimeException(sb.toString());
|
||||
}
|
||||
|
||||
String uniqueName = relationshipDefinitionQName.getLocalName();
|
||||
|
||||
return new RelationshipDefinitionImpl(uniqueName, type, displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#updateReleationshipDefinition(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public RelationshipDefinition updateReleationshipDefinition(String uniqueName, RelationshipDisplayName displayName)
|
||||
{
|
||||
mandatoryString("uniqueName", uniqueName);
|
||||
|
||||
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||
if (associationDefinitionQName == null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("The qualified name for '")
|
||||
.append(uniqueName)
|
||||
.append("' was not found.");
|
||||
throw new AlfrescoRuntimeException(sb.toString());
|
||||
}
|
||||
|
||||
Map<QName, AssociationDefinition> customReferenceDefinitions = getRecordsManagementAdminService().getCustomReferenceDefinitions();
|
||||
AssociationDefinition associationDefinition = customReferenceDefinitions.get(associationDefinitionQName);
|
||||
RelationshipType type = getRelationshipType(associationDefinition);
|
||||
QName updatedAssociationDefinitionQName;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case BIDIRECTIONAL:
|
||||
|
||||
String labelText = displayName.getLabelText();
|
||||
|
||||
if (isBlank(labelText))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Label text '")
|
||||
.append(labelText)
|
||||
.append(" cannot be blank.");
|
||||
throw new AlfrescoRuntimeException(sb.toString());
|
||||
}
|
||||
|
||||
updatedAssociationDefinitionQName = getRecordsManagementAdminService().updateCustomAssocDefinition(associationDefinitionQName, labelText);
|
||||
break;
|
||||
|
||||
case PARENTCHILD:
|
||||
|
||||
String sourceText = displayName.getSourceText();
|
||||
String targetText = displayName.getTargetText();
|
||||
|
||||
if (isBlank(sourceText) || isBlank(targetText))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Neither source text '")
|
||||
.append(sourceText)
|
||||
.append("' nor target text '")
|
||||
.append(targetText)
|
||||
.append(" can be blank.");
|
||||
throw new AlfrescoRuntimeException(sb.toString());
|
||||
}
|
||||
|
||||
updatedAssociationDefinitionQName = getRecordsManagementAdminService().updateCustomChildAssocDefinition(associationDefinitionQName, sourceText, targetText);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unsupported relationship type: '")
|
||||
.append(type.toString())
|
||||
.append("'.");
|
||||
throw new AlfrescoRuntimeException(sb.toString());
|
||||
}
|
||||
|
||||
customReferenceDefinitions = getRecordsManagementAdminService().getCustomReferenceDefinitions();
|
||||
AssociationDefinition updatedAssociationDefinition = customReferenceDefinitions.get(updatedAssociationDefinitionQName);
|
||||
RelationshipDefinition updatedRelationshipDefinition = createRelationshipDefinition(updatedAssociationDefinition);
|
||||
if (updatedRelationshipDefinition == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The relationship definition was not updated successfully.");
|
||||
}
|
||||
|
||||
return updatedRelationshipDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationshipDefinition(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeRelationshipDefinition(String uniqueName)
|
||||
{
|
||||
mandatoryString("uniqueName", uniqueName);
|
||||
|
||||
// FIXME!!! There is no method on the backend for this. Must be implemented.
|
||||
throw new UnsupportedOperationException("Not implemented yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#existsRelationshipDefinition(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean existsRelationshipDefinition(String uniqueName)
|
||||
{
|
||||
mandatoryString("uniqueName", uniqueName);
|
||||
|
||||
boolean exists = false;
|
||||
|
||||
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||
if (associationDefinitionQName != null)
|
||||
{
|
||||
Map<QName, AssociationDefinition> customReferenceDefinitions = getRecordsManagementAdminService().getCustomReferenceDefinitions();
|
||||
exists = customReferenceDefinitions.containsKey(associationDefinitionQName);
|
||||
}
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsFrom(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public Set<Relationship> getRelationshipsFrom(NodeRef nodeRef)
|
||||
{
|
||||
mandatory("nodeRef", nodeRef);
|
||||
|
||||
Set<Relationship> relationships = new HashSet<Relationship>();
|
||||
|
||||
List<AssociationRef> customReferencesFrom = getRecordsManagementAdminService().getCustomReferencesFrom(nodeRef);
|
||||
relationships.addAll(generateRelationshipFromAssociationRef(customReferencesFrom));
|
||||
|
||||
List<ChildAssociationRef> customChildReferences = getRecordsManagementAdminService().getCustomChildReferences(nodeRef);
|
||||
relationships.addAll(generateRelationshipFromParentChildAssociationRef(customChildReferences));
|
||||
|
||||
return relationships;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#getRelationshipsTo(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public Set<Relationship> getRelationshipsTo(NodeRef nodeRef)
|
||||
{
|
||||
mandatory("nodeRef", nodeRef);
|
||||
|
||||
Set<Relationship> relationships = new HashSet<Relationship>();
|
||||
|
||||
List<AssociationRef> customReferencesTo = getRecordsManagementAdminService().getCustomReferencesTo(nodeRef);
|
||||
relationships.addAll(generateRelationshipFromAssociationRef(customReferencesTo));
|
||||
|
||||
List<ChildAssociationRef> customParentReferences = getRecordsManagementAdminService().getCustomParentReferences(nodeRef);
|
||||
relationships.addAll(generateRelationshipFromParentChildAssociationRef(customParentReferences));
|
||||
|
||||
return relationships;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#addRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void addRelationship(String uniqueName, NodeRef source, NodeRef target)
|
||||
{
|
||||
mandatoryString("uniqueName", uniqueName);
|
||||
mandatory("source", source);
|
||||
mandatory("target", target);
|
||||
|
||||
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||
getRecordsManagementAdminService().addCustomReference(source, target, associationDefinitionQName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void removeRelationship(String uniqueName, NodeRef source, NodeRef target)
|
||||
{
|
||||
mandatoryString("uniqueName", uniqueName);
|
||||
mandatory("source", source);
|
||||
mandatory("target", target);
|
||||
|
||||
QName associationDefinitionQName = getRecordsManagementAdminService().getQNameForClientId(uniqueName);
|
||||
getRecordsManagementAdminService().removeCustomReference(source, target, associationDefinitionQName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the relationship definition from the association definition
|
||||
*
|
||||
* @param associationDefinition The association definition
|
||||
* @return The relationship definition if <code>associationDefinition</code> exists, <code>null</code> otherwise
|
||||
*/
|
||||
private RelationshipDefinition createRelationshipDefinition(AssociationDefinition associationDefinition)
|
||||
{
|
||||
RelationshipDefinition relationshipDefinition = null;
|
||||
|
||||
if (associationDefinition != null)
|
||||
{
|
||||
String uniqueName = associationDefinition.getName().getLocalName();
|
||||
|
||||
RelationshipType type = getRelationshipType(associationDefinition);
|
||||
|
||||
String title = associationDefinition.getTitle(getDictionaryService());
|
||||
RelationshipDisplayName displayName = getRelationshipDisplayName(type, title);
|
||||
|
||||
relationshipDefinition = new RelationshipDefinitionImpl(uniqueName, type, displayName);
|
||||
}
|
||||
|
||||
return relationshipDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relationship type from the association definition
|
||||
*
|
||||
* @param associationDefinition The association definition
|
||||
* @return The type of the relationship definition
|
||||
*/
|
||||
private RelationshipType getRelationshipType(AssociationDefinition associationDefinition)
|
||||
{
|
||||
RelationshipType type;
|
||||
|
||||
if (associationDefinition instanceof ChildAssociationDefinition)
|
||||
{
|
||||
type = RelationshipType.PARENTCHILD;
|
||||
}
|
||||
else if (associationDefinition instanceof AssociationDefinition)
|
||||
{
|
||||
type = RelationshipType.BIDIRECTIONAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unsupported association definition: '")
|
||||
.append(associationDefinition.getName().getLocalName())
|
||||
.append("'.");
|
||||
throw new AlfrescoRuntimeException(sb.toString());
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relationship display name of the relationship definition
|
||||
*
|
||||
* @param type The type of the relationship definition
|
||||
* @param title The title of the association definition
|
||||
* @return The relationship display name of the relationship definition
|
||||
*/
|
||||
private RelationshipDisplayName getRelationshipDisplayName(RelationshipType type, String title)
|
||||
{
|
||||
String sourceText = null;
|
||||
String targetText = null;
|
||||
String labelText = null;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case BIDIRECTIONAL:
|
||||
|
||||
labelText = title;
|
||||
break;
|
||||
|
||||
case PARENTCHILD:
|
||||
|
||||
String[] sourceAndTarget = getRecordsManagementAdminService().splitSourceTargetId(title);
|
||||
sourceText = sourceAndTarget[0];
|
||||
targetText = sourceAndTarget[1];
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unsupported relationship type: '")
|
||||
.append(type.toString())
|
||||
.append("'.");
|
||||
throw new AlfrescoRuntimeException(sb.toString());
|
||||
}
|
||||
|
||||
return new RelationshipDisplayName(sourceText, targetText, labelText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates relationships from the given association references
|
||||
*
|
||||
* @param associationRefs Association references
|
||||
* @return Relationships generated from the given association references
|
||||
*/
|
||||
private Set<Relationship> generateRelationshipFromAssociationRef(List<AssociationRef> associationRefs)
|
||||
{
|
||||
Set<Relationship> relationships = new HashSet<Relationship>();
|
||||
|
||||
for (AssociationRef associationRef : associationRefs)
|
||||
{
|
||||
String uniqueName = associationRef.getTypeQName().getLocalName();
|
||||
NodeRef from = associationRef.getSourceRef();
|
||||
NodeRef to = associationRef.getTargetRef();
|
||||
relationships.add(new RelationshipImpl(uniqueName, from, to));
|
||||
}
|
||||
|
||||
return relationships;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates relationships from the given child association references
|
||||
*
|
||||
* @param childAssociationRefs Child association references
|
||||
* @return Relationships generated from the given child association references
|
||||
*/
|
||||
private Set<Relationship> generateRelationshipFromParentChildAssociationRef(List<ChildAssociationRef> childAssociationRefs)
|
||||
{
|
||||
Set<Relationship> relationships = new HashSet<Relationship>();
|
||||
|
||||
for (ChildAssociationRef childAssociationRef : childAssociationRefs)
|
||||
{
|
||||
String uniqueName = childAssociationRef.getQName().getLocalName();
|
||||
NodeRef from = childAssociationRef.getParentRef();
|
||||
NodeRef to = childAssociationRef.getChildRef();
|
||||
relationships.add(new RelationshipImpl(uniqueName, from, to));
|
||||
}
|
||||
|
||||
return relationships;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the relationship type from the display name
|
||||
*
|
||||
* @param displayName The display name of the relationship
|
||||
* @return The relationship type from the display name
|
||||
*/
|
||||
private RelationshipType determineRelationshipTypeFromDisplayName(RelationshipDisplayName displayName)
|
||||
{
|
||||
RelationshipType relationshipType;
|
||||
|
||||
String labelText = displayName.getLabelText();
|
||||
String sourceText = displayName.getSourceText();
|
||||
String targetText = displayName.getTargetText();
|
||||
|
||||
String errorMsg = "Relationship type could not be determined from the display name. It is neither biderectional nor parent/child relationship";
|
||||
|
||||
if (isBlank(labelText))
|
||||
{
|
||||
if (isBlank(sourceText) || isBlank(targetText))
|
||||
{
|
||||
throw new AlfrescoRuntimeException(errorMsg);
|
||||
}
|
||||
relationshipType = RelationshipType.PARENTCHILD;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isNotBlank(sourceText) || isNotBlank(targetText))
|
||||
{
|
||||
throw new AlfrescoRuntimeException(errorMsg);
|
||||
}
|
||||
relationshipType = RelationshipType.BIDIRECTIONAL;
|
||||
}
|
||||
|
||||
return relationshipType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.relationship;
|
||||
|
||||
/**
|
||||
* Enum representing the relationship types
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.3
|
||||
*/
|
||||
public enum RelationshipType
|
||||
{
|
||||
BIDIRECTIONAL,
|
||||
PARENTCHILD;
|
||||
}
|
@@ -34,7 +34,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Abstract base class for all RM webscript classes.
|
||||
* Includes util methods for processing the webscript request.
|
||||
* Includes utility methods for processing the webscript request.
|
||||
*
|
||||
* @author Neil McErlean
|
||||
* @author Tuna Aksoy
|
||||
@@ -43,21 +43,34 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
||||
{
|
||||
/** Constants */
|
||||
protected static final String PATH_SEPARATOR = "/";
|
||||
protected static final String STORE_TYPE = "store_type";
|
||||
protected static final String STORE_ID = "store_id";
|
||||
protected static final String ID = "id";
|
||||
protected static final String SUCCESS = "success";
|
||||
|
||||
/** Disposition service */
|
||||
protected DispositionService dispositionService;
|
||||
private DispositionService dispositionService;
|
||||
|
||||
/** Namespace service */
|
||||
protected NamespaceService namespaceService;
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
/** Node service */
|
||||
protected NodeService nodeService;
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Sets the disposition service
|
||||
* Gets the disposition service instance
|
||||
*
|
||||
* @param dispositionService The disposition serviceS
|
||||
* @return The disposition service instance
|
||||
*/
|
||||
protected DispositionService getDispositionService()
|
||||
{
|
||||
return this.dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the disposition service instance
|
||||
*
|
||||
* @param dispositionService The disposition service instance
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
@@ -65,9 +78,19 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the namespace service
|
||||
* Gets the namespace service instance
|
||||
*
|
||||
* @param namespaceService The namespace service
|
||||
* @return The namespace service instance
|
||||
*/
|
||||
protected NamespaceService getNamespaceService()
|
||||
{
|
||||
return this.namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the namespace service instance
|
||||
*
|
||||
* @param namespaceService The namespace service instance
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
@@ -75,9 +98,19 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node service
|
||||
* Gets the node service instance
|
||||
*
|
||||
* @param nodeService The node service
|
||||
* @return The node service instance
|
||||
*/
|
||||
protected NodeService getNodeService()
|
||||
{
|
||||
return this.nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node service instance
|
||||
*
|
||||
* @param nodeService The node service instance
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
@@ -97,14 +130,14 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
||||
// get the parameters that represent the NodeRef, we know they are present
|
||||
// otherwise this webscript would not have matched
|
||||
Map<String, String> templateVars = getTemplateVars(req);
|
||||
String storeType = templateVars.get("store_type");
|
||||
String storeId = templateVars.get("store_id");
|
||||
String nodeId = templateVars.get("id");
|
||||
String storeType = templateVars.get(STORE_TYPE);
|
||||
String storeId = templateVars.get(STORE_ID);
|
||||
String nodeId = templateVars.get(ID);
|
||||
|
||||
// create the NodeRef and ensure it is valid
|
||||
NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId);
|
||||
|
||||
if (!nodeService.exists(nodeRef))
|
||||
if (!getNodeService().exists(nodeRef))
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: '" +
|
||||
nodeRef.toString() + "'.");
|
||||
|
@@ -58,7 +58,7 @@ public class BaseCustomPropertyWebScript extends AbstractRmWebScript
|
||||
else
|
||||
{
|
||||
// Try and convert the string to a qname
|
||||
return QName.createQName(elementName, namespaceService);
|
||||
return QName.createQName(elementName, getNamespaceService());
|
||||
}
|
||||
}
|
||||
}
|
@@ -106,7 +106,7 @@ public class CustomPropertyDefinitionDelete extends AbstractRmWebScript
|
||||
|
||||
rmAdminService.removeCustomPropertyDefinition(propQName);
|
||||
|
||||
result.put("propertyqname", propQName.toPrefixString(namespaceService));
|
||||
result.put("propertyqname", propQName.toPrefixString(getNamespaceService()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -161,7 +161,7 @@ public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
||||
{
|
||||
if (serializableParam instanceof String)
|
||||
{
|
||||
type = QName.createQName((String)serializableParam, namespaceService);
|
||||
type = QName.createQName((String)serializableParam, getNamespaceService());
|
||||
}
|
||||
else if (serializableParam instanceof QName)
|
||||
{
|
||||
@@ -206,7 +206,7 @@ public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
||||
{
|
||||
if (serializableParam instanceof String)
|
||||
{
|
||||
constraintRef = QName.createQName((String)serializableParam, namespaceService);
|
||||
constraintRef = QName.createQName((String)serializableParam, getNamespaceService());
|
||||
}
|
||||
else if (serializableParam instanceof QName)
|
||||
{
|
||||
@@ -223,7 +223,7 @@ public class CustomPropertyDefinitionPost extends BaseCustomPropertyWebScript
|
||||
String propId = (String)params.get(PROP_ID);
|
||||
if (propId != null)
|
||||
{
|
||||
proposedQName = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_PREFIX, propId, namespaceService);
|
||||
proposedQName = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_PREFIX, propId, getNamespaceService());
|
||||
}
|
||||
|
||||
return rmAdminService.addCustomPropertyDefinition(
|
||||
|
@@ -163,7 +163,7 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
||||
}
|
||||
if (!exists)
|
||||
{
|
||||
QName constraintRefQName = QName.createQName(constraintRef, namespaceService);
|
||||
QName constraintRefQName = QName.createQName(constraintRef, getNamespaceService());
|
||||
result = rmAdminService.setCustomPropertyDefinitionConstraint(propQName, constraintRefQName);
|
||||
updated = true;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript
|
||||
{
|
||||
if (!updated)
|
||||
{
|
||||
String propIdAsString = rmAdminService.getQNameForClientId(label).toPrefixString(namespaceService);
|
||||
String propIdAsString = rmAdminService.getQNameForClientId(label).toPrefixString(getNamespaceService());
|
||||
throw new PropertyAlreadyExistsMetadataException(propIdAsString);
|
||||
}
|
||||
}
|
||||
|
@@ -23,18 +23,17 @@ import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.rule.RuleType;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Implementation for Java backed webscript to remove RM custom reference instances from a node.
|
||||
* Implementation for Java backed webscript to remove RM custom relationship from a node.
|
||||
*
|
||||
* @author Neil McErlean
|
||||
* @author Tuna Aksoy
|
||||
@@ -45,28 +44,47 @@ public class CustomRefDelete extends AbstractRmWebScript
|
||||
private static final String REF_ID = "refId";
|
||||
private static final String ST = "st";
|
||||
private static final String SI = "si";
|
||||
private static final String ID = "id";
|
||||
|
||||
/** RM admin service */
|
||||
private RecordsManagementAdminService rmAdminService;
|
||||
/** Relationship service */
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
/** Rule service */
|
||||
private RuleService ruleService;
|
||||
|
||||
/**
|
||||
* Sets the RM admin service
|
||||
* Gets the relationship service instance
|
||||
*
|
||||
* @param rmAdminService RM admin service
|
||||
* @return The relationship service instance
|
||||
*/
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
||||
protected RelationshipService getRelationshipService()
|
||||
{
|
||||
this.rmAdminService = rmAdminService;
|
||||
return this.relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rule service
|
||||
* Sets the relationship service instance
|
||||
*
|
||||
* @param ruleService Rule service
|
||||
* @param relationshipService The relationship service instance
|
||||
*/
|
||||
public void setRelationshipService(RelationshipService relationshipService)
|
||||
{
|
||||
this.relationshipService = relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rule service instance
|
||||
*
|
||||
* @return The rule service instance
|
||||
*/
|
||||
protected RuleService getRuleService()
|
||||
{
|
||||
return this.ruleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rule service instance
|
||||
*
|
||||
* @param ruleService The rule service instance
|
||||
*/
|
||||
public void setRuleService(RuleService ruleService)
|
||||
{
|
||||
@@ -74,83 +92,61 @@ public class CustomRefDelete extends AbstractRmWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||
* org.springframework.extensions.webscripts.Status,
|
||||
* org.springframework.extensions.webscripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||
|
||||
try
|
||||
{
|
||||
ruleService.disableRuleType(RuleType.OUTBOUND);
|
||||
removeCustomReferenceInstance(req);
|
||||
getRuleService().disableRuleType(RuleType.OUTBOUND);
|
||||
removeCustomRelationship(req);
|
||||
model.put(SUCCESS, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ruleService.enableRuleType(RuleType.OUTBOUND);
|
||||
getRuleService().enableRuleType(RuleType.OUTBOUND);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes custom reference instance
|
||||
* Removes a custom relationship
|
||||
*
|
||||
* @param req The webscript request
|
||||
*/
|
||||
private void removeCustomReferenceInstance(WebScriptRequest req)
|
||||
private void removeCustomRelationship(WebScriptRequest req)
|
||||
{
|
||||
NodeRef fromNode = parseRequestForNodeRef(req);
|
||||
NodeRef toNodeRef = getToNode(req);
|
||||
QName associationQName = getAssociationQName(req);
|
||||
String uniqueName = getRequestParameterValue(req, REF_ID);
|
||||
NodeRef source = parseRequestForNodeRef(req);
|
||||
NodeRef target = getTargetNode(req);
|
||||
|
||||
rmAdminService.removeCustomReference(fromNode, toNodeRef, associationQName);
|
||||
rmAdminService.removeCustomReference(toNodeRef, fromNode, associationQName);
|
||||
getRelationshipService().removeRelationship(uniqueName, source, target);
|
||||
getRelationshipService().removeRelationship(uniqueName, target, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the node from which the reference will be removed
|
||||
* Gets the target node
|
||||
*
|
||||
* @param req The webscript request
|
||||
* @return The node from which the reference will be removed
|
||||
* @return The target node
|
||||
*/
|
||||
private NodeRef getToNode(WebScriptRequest req)
|
||||
private NodeRef getTargetNode(WebScriptRequest req)
|
||||
{
|
||||
// Get the toNode from the URL query string.
|
||||
String storeType = req.getParameter(ST);
|
||||
String storeId = req.getParameter(SI);
|
||||
String nodeId = req.getParameter(ID);
|
||||
|
||||
// Create the NodeRef and ensure it is valid
|
||||
NodeRef toNode = new NodeRef(storeType, storeId, nodeId);
|
||||
if (!nodeService.exists(toNode))
|
||||
NodeRef targetNode = new NodeRef(storeType, storeId, nodeId);
|
||||
if (!getNodeService().exists(targetNode))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find toNode: '" +
|
||||
toNode.toString() + "'.");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find the target node: '" +
|
||||
targetNode.toString() + "'.");
|
||||
}
|
||||
|
||||
return toNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the QName of the association
|
||||
*
|
||||
* @param req The webscript request
|
||||
* @return QName of the association
|
||||
*/
|
||||
private QName getAssociationQName(WebScriptRequest req)
|
||||
{
|
||||
String clientsRefId = getRequestParameterValue(req, REF_ID);
|
||||
QName qName = rmAdminService.getQNameForClientId(clientsRefId);
|
||||
|
||||
if (qName == null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||
"Unable to find reference type: '" + clientsRefId + "'.");
|
||||
}
|
||||
|
||||
return qName;
|
||||
return targetNode;
|
||||
}
|
||||
}
|
@@ -24,11 +24,10 @@ import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.rule.RuleType;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
@@ -36,7 +35,7 @@ import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Implementation for Java backed webscript to add RM custom reference instances to a node.
|
||||
* Implementation for Java backed webscript to add RM custom relationship to a node.
|
||||
*
|
||||
* @author Neil McErlean
|
||||
* @author Tuna Aksoy
|
||||
@@ -47,26 +46,46 @@ public class CustomRefPost extends AbstractRmWebScript
|
||||
private static final String TO_NODE = "toNode";
|
||||
private static final String REF_ID = "refId";
|
||||
|
||||
/** RM admin service */
|
||||
private RecordsManagementAdminService rmAdminService;
|
||||
/** Relationship service */
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
/** Rule service */
|
||||
private RuleService ruleService;
|
||||
|
||||
/**
|
||||
* Sets the RM admin service
|
||||
* Gets the relationship service instance
|
||||
*
|
||||
* @param rmAdminService RM admin service
|
||||
* @return The relationship service instance
|
||||
*/
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
||||
protected RelationshipService getRelationshipService()
|
||||
{
|
||||
this.rmAdminService = rmAdminService;
|
||||
return this.relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rule service
|
||||
* Sets the relationship service instance
|
||||
*
|
||||
* @param ruleService Rule service
|
||||
* @param relationshipService The relationship service instance
|
||||
*/
|
||||
public void setRelationshipService(RelationshipService relationshipService)
|
||||
{
|
||||
this.relationshipService = relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rule service instance
|
||||
*
|
||||
* @return The rule service instance
|
||||
*/
|
||||
protected RuleService getRuleService()
|
||||
{
|
||||
return this.ruleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rule service instance
|
||||
*
|
||||
* @param ruleService The rule service instance
|
||||
*/
|
||||
public void setRuleService(RuleService ruleService)
|
||||
{
|
||||
@@ -74,79 +93,59 @@ public class CustomRefPost extends AbstractRmWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||
* org.springframework.extensions.webscripts.Status,
|
||||
* org.springframework.extensions.webscripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||
|
||||
try
|
||||
{
|
||||
ruleService.disableRuleType(RuleType.INBOUND);
|
||||
addCustomReferenceInstance(req);
|
||||
getRuleService().disableRuleType(RuleType.INBOUND);
|
||||
addCustomRelationship(req);
|
||||
model.put(SUCCESS, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ruleService.enableRuleType(RuleType.INBOUND);
|
||||
getRuleService().enableRuleType(RuleType.INBOUND);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom reference instance
|
||||
* Adds a custom relationship
|
||||
*
|
||||
* @param req The webscript request
|
||||
*/
|
||||
protected void addCustomReferenceInstance(WebScriptRequest req)
|
||||
protected void addCustomRelationship(WebScriptRequest req)
|
||||
{
|
||||
NodeRef fromNode = parseRequestForNodeRef(req);
|
||||
JSONObject json = getRequestContentAsJsonObject(req);
|
||||
NodeRef toNode = getToNode(json);
|
||||
QName associationQName = getAssociationQName(json);
|
||||
String uniqueName = getStringValueFromJSONObject(json, REF_ID);
|
||||
NodeRef target = getTargetNode(json);
|
||||
NodeRef source = parseRequestForNodeRef(req);
|
||||
|
||||
rmAdminService.addCustomReference(fromNode, toNode, associationQName);
|
||||
getRelationshipService().addRelationship(uniqueName, source, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the node to which the reference will be added
|
||||
* Gets the target node
|
||||
*
|
||||
* @param json Request content as json object
|
||||
* @return The node to which the reference will be added
|
||||
* @return The target node
|
||||
*/
|
||||
private NodeRef getToNode(JSONObject json)
|
||||
private NodeRef getTargetNode(JSONObject json)
|
||||
{
|
||||
String toNodeString = getStringValueFromJSONObject(json, TO_NODE);
|
||||
NodeRef toNode = new NodeRef(toNodeString);
|
||||
String targetNodeString = getStringValueFromJSONObject(json, TO_NODE);
|
||||
NodeRef targetNode = new NodeRef(targetNodeString);
|
||||
|
||||
if (!nodeService.exists(toNode))
|
||||
if (!getNodeService().exists(targetNode))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find toNode: '" +
|
||||
toNode.toString() + "'.");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find the target node: '" +
|
||||
targetNode.toString() + "'.");
|
||||
}
|
||||
|
||||
return toNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the QName of the association
|
||||
*
|
||||
* @param json Request content as json object
|
||||
* @return QName of the association
|
||||
*/
|
||||
private QName getAssociationQName(JSONObject json)
|
||||
{
|
||||
String clientsRefId = getStringValueFromJSONObject(json, REF_ID);
|
||||
QName qName = rmAdminService.getQNameForClientId(clientsRefId);
|
||||
|
||||
if (qName == null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||
"Unable to find reference type: '" + clientsRefId + "'.");
|
||||
}
|
||||
|
||||
return qName;
|
||||
return targetNode;
|
||||
}
|
||||
}
|
@@ -20,11 +20,9 @@ package org.alfresco.module.org_alfresco_module_rm.script;
|
||||
|
||||
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
/**
|
||||
* Base class for custom reference definition classes
|
||||
@@ -42,62 +40,41 @@ public class CustomReferenceDefinitionBase extends AbstractRmWebScript
|
||||
protected static final String TARGET = "target";
|
||||
protected static final String CUSTOM_REFS = "customRefs";
|
||||
protected static final String URL = "url";
|
||||
protected static final String SUCCESS = "success";
|
||||
|
||||
/** Records Management Admin Service */
|
||||
private RecordsManagementAdminService rmAdminService;
|
||||
/** Relationship service */
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
/**
|
||||
* Sets the records management admin service
|
||||
* Gets the relationship service instance
|
||||
*
|
||||
* @param rmAdminService The records management admin service
|
||||
* @return The relationship service instance
|
||||
*/
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
||||
protected RelationshipService getRelationshipService()
|
||||
{
|
||||
this.rmAdminService = rmAdminService;
|
||||
return this.relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the records management admin service instance
|
||||
* Sets the relationship service instance
|
||||
*
|
||||
* @return The records management admin service instance
|
||||
* @param relationshipService The relationship service instance
|
||||
*/
|
||||
protected RecordsManagementAdminService getRmAdminService()
|
||||
public void setRelationshipService(RelationshipService relationshipService)
|
||||
{
|
||||
return this.rmAdminService;
|
||||
this.relationshipService = relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the QName for the given custom reference id
|
||||
*
|
||||
* @param referenceId The reference id
|
||||
* @return The QName for the given custom reference id
|
||||
*/
|
||||
protected QName getCustomReferenceQName(String referenceId)
|
||||
{
|
||||
QName customReferenceQName = getRmAdminService().getQNameForClientId(referenceId);
|
||||
if (customReferenceQName == null)
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Unable to find QName for the reference: '");
|
||||
msg.append(referenceId);
|
||||
msg.append("'.");
|
||||
String errorMsg = msg.toString();
|
||||
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, errorMsg);
|
||||
}
|
||||
return customReferenceQName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom reference type from the json object
|
||||
* Creates the relationship display name from request content
|
||||
*
|
||||
* @param requestContent The request content as json object
|
||||
* @return Returns the custom reference type which is either parent/child or bidirectional
|
||||
* @return The relationship display name
|
||||
*/
|
||||
protected CustomReferenceType getCustomReferenceType(JSONObject requestContent)
|
||||
protected RelationshipDisplayName createDisplayName(JSONObject requestContent)
|
||||
{
|
||||
String referenceType = getStringValueFromJSONObject(requestContent, REFERENCE_TYPE);
|
||||
return CustomReferenceType.getEnumFromString(referenceType);
|
||||
String sourceText = getStringValueFromJSONObject(requestContent, SOURCE, false, false);
|
||||
String targetText = getStringValueFromJSONObject(requestContent, TARGET, false, false);
|
||||
String labelText = getStringValueFromJSONObject(requestContent, LABEL, false, false);
|
||||
return new RelationshipDisplayName(sourceText, targetText, labelText);
|
||||
}
|
||||
}
|
||||
|
@@ -19,16 +19,15 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.script;
|
||||
|
||||
import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject;
|
||||
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
@@ -41,69 +40,40 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
public class CustomReferenceDefinitionPost extends CustomReferenceDefinitionBase
|
||||
{
|
||||
/**
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||
* org.springframework.extensions.webscripts.Status,
|
||||
* org.springframework.extensions.webscripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
JSONObject requestContent = getRequestContentAsJsonObject(req);
|
||||
CustomReferenceType customReferenceType = getCustomReferenceType(requestContent);
|
||||
QName customReference = addCustomReference(requestContent, customReferenceType);
|
||||
RelationshipDisplayName displayName = createDisplayName(requestContent);
|
||||
RelationshipDefinition relationshipDefinition = getRelationshipService().createRelationshipDefinition(displayName);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
String servicePath = req.getServicePath();
|
||||
Map<String, Object> customReferenceData = getCustomReferenceData(customReferenceType, customReference, servicePath);
|
||||
model.putAll(customReferenceData);
|
||||
Map<String, Object> customRelationshipData = createRelationshipDefinitionData(relationshipDefinition, servicePath);
|
||||
model.putAll(customRelationshipData);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom reference to the model
|
||||
* Creates relationship definition data for the ftl template
|
||||
*
|
||||
* @param requestContent The request content as json object
|
||||
* @param customReferenceType The custom reference type
|
||||
* @return Returns the {@link QName} of the new custom reference
|
||||
*/
|
||||
private QName addCustomReference(JSONObject requestContent, CustomReferenceType customReferenceType)
|
||||
{
|
||||
QName referenceQName;
|
||||
|
||||
if (CustomReferenceType.PARENT_CHILD.equals(customReferenceType))
|
||||
{
|
||||
String source = getStringValueFromJSONObject(requestContent, SOURCE);
|
||||
String target = getStringValueFromJSONObject(requestContent, TARGET);
|
||||
referenceQName = getRmAdminService().addCustomChildAssocDefinition(source, target);
|
||||
}
|
||||
else if (CustomReferenceType.BIDIRECTIONAL.equals(customReferenceType))
|
||||
{
|
||||
String label = getStringValueFromJSONObject(requestContent, LABEL);
|
||||
referenceQName = getRmAdminService().addCustomAssocDefinition(label);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unsupported custom reference type.");
|
||||
}
|
||||
|
||||
return referenceQName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom reference data
|
||||
*
|
||||
* @param customReferenceType The custom reference type
|
||||
* @param customReference The qualified name of the custom reference
|
||||
* @param relationshipDefinition The relationship definition
|
||||
* @param servicePath The service path
|
||||
* @return The custom reference data
|
||||
* @return The relationship definition data
|
||||
*/
|
||||
private Map<String, Object> getCustomReferenceData(CustomReferenceType customReferenceType, QName customReference, String servicePath)
|
||||
private Map<String, Object> createRelationshipDefinitionData(RelationshipDefinition relationshipDefinition, String servicePath)
|
||||
{
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
String qnameLocalName = customReference.getLocalName();
|
||||
result.put(REFERENCE_TYPE, customReferenceType.toString());
|
||||
result.put(REF_ID, qnameLocalName);
|
||||
result.put(URL, servicePath + PATH_SEPARATOR + qnameLocalName);
|
||||
result.put(SUCCESS, Boolean.TRUE);
|
||||
return result;
|
||||
Map<String, Object> relationshipDefinitionData = new HashMap<String, Object>(4);
|
||||
String uniqueName = relationshipDefinition.getUniqueName();
|
||||
relationshipDefinitionData.put(REFERENCE_TYPE, relationshipDefinition.getType().toString());
|
||||
relationshipDefinitionData.put(REF_ID, uniqueName);
|
||||
relationshipDefinitionData.put(URL, servicePath + PATH_SEPARATOR + uniqueName);
|
||||
relationshipDefinitionData.put(SUCCESS, Boolean.TRUE);
|
||||
return relationshipDefinitionData;
|
||||
}
|
||||
}
|
@@ -20,16 +20,14 @@ package org.alfresco.module.org_alfresco_module_rm.script;
|
||||
|
||||
import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject;
|
||||
import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
||||
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
@@ -43,64 +41,39 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
public class CustomReferenceDefinitionPut extends CustomReferenceDefinitionBase
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||
* org.springframework.extensions.webscripts.Status,
|
||||
* org.springframework.extensions.webscripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String uniqueName = getRequestParameterValue(req, REF_ID);
|
||||
JSONObject requestContent = getRequestContentAsJsonObject(req);
|
||||
String referenceId = getRequestParameterValue(req, REF_ID);
|
||||
updateCustomReference(requestContent, referenceId);
|
||||
RelationshipDisplayName displayName = createDisplayName(requestContent);
|
||||
getRelationshipService().updateReleationshipDefinition(uniqueName, displayName);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
String servicePath = req.getServicePath();
|
||||
Map<String, Object> customReferenceData = getCustomReferenceData(servicePath, referenceId);
|
||||
Map<String, Object> customReferenceData = createRelationshipDefinitionData(servicePath, uniqueName);
|
||||
model.putAll(customReferenceData);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the custom reference
|
||||
*
|
||||
* @param requestContent The request content as json object
|
||||
* @param referenceId The reference id
|
||||
*/
|
||||
private void updateCustomReference(JSONObject requestContent, String referenceId)
|
||||
{
|
||||
QName referenceQName = getCustomReferenceQName(referenceId);
|
||||
CustomReferenceType customReferenceType = getCustomReferenceType(requestContent);
|
||||
|
||||
if (CustomReferenceType.PARENT_CHILD.equals(customReferenceType))
|
||||
{
|
||||
String source = getStringValueFromJSONObject(requestContent, SOURCE);
|
||||
String target = getStringValueFromJSONObject(requestContent, TARGET);
|
||||
getRmAdminService().updateCustomChildAssocDefinition(referenceQName, source, target);
|
||||
}
|
||||
else if (CustomReferenceType.BIDIRECTIONAL.equals(customReferenceType))
|
||||
{
|
||||
String label = getStringValueFromJSONObject(requestContent, LABEL);
|
||||
getRmAdminService().updateCustomAssocDefinition(referenceQName, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unsupported custom reference type.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom reference data
|
||||
* Creates relationship definition data for the ftl template
|
||||
*
|
||||
* @param servicePath The service path
|
||||
* @param String The reference id
|
||||
* @return The custom reference data
|
||||
* @param String The relationship unique name
|
||||
* @return The relationship definition data
|
||||
*/
|
||||
private Map<String, Object> getCustomReferenceData(String servicePath, String referenceId)
|
||||
private Map<String, Object> createRelationshipDefinitionData(String servicePath, String uniqueName)
|
||||
{
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put(URL, servicePath);
|
||||
result.put(REF_ID, referenceId);
|
||||
result.put(SUCCESS, Boolean.TRUE);
|
||||
return result;
|
||||
Map<String, Object> relationshipDefinitionData = new HashMap<String, Object>(3);
|
||||
relationshipDefinitionData.put(URL, servicePath);
|
||||
relationshipDefinitionData.put(REF_ID, uniqueName);
|
||||
relationshipDefinitionData.put(SUCCESS, Boolean.TRUE);
|
||||
return relationshipDefinitionData;
|
||||
}
|
||||
}
|
@@ -19,18 +19,18 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.script;
|
||||
|
||||
import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
@@ -44,175 +44,93 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
*/
|
||||
public class CustomReferenceDefinitionsGet extends CustomReferenceDefinitionBase
|
||||
{
|
||||
/** Dictionary Service */
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
/**
|
||||
* Sets the dictionary service
|
||||
*
|
||||
* @param dictionaryService The dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dictionary service instance
|
||||
*
|
||||
* @return The dictionary service instance
|
||||
*/
|
||||
protected DictionaryService getDictionaryService()
|
||||
{
|
||||
return this.dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||
* org.springframework.extensions.webscripts.Status,
|
||||
* org.springframework.extensions.webscripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String referenceId = getRequestParameterValue(req, REF_ID, false);
|
||||
Map<QName, AssociationDefinition> customReferenceDefinitions = getCustomReferenceDefinitions(referenceId);
|
||||
List<Map<String, String>> customReferenceData = getCustomReferenceData(customReferenceDefinitions);
|
||||
String uniqueName = getRequestParameterValue(req, REF_ID, false);
|
||||
Set<RelationshipDefinition> relationshipDefinitions = getRelationshipDefinitons(uniqueName);
|
||||
List<Map<String, String>> relationshipDefinitionData = createRelationshipDefinitionData(relationshipDefinitions);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(CUSTOM_REFS, customReferenceData);
|
||||
|
||||
model.put(CUSTOM_REFS, relationshipDefinitionData);
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom reference definition(s) for the given reference id
|
||||
* Gets the relationship definition for the unique name. If the unique
|
||||
* name is blank all relationship definitions will be retrieved
|
||||
*
|
||||
* @param referenceId The reference id
|
||||
* @return If the reference id is not blank the custom definition for the given reference id will be returned,
|
||||
* otherwise all custom definitions will be returned.
|
||||
* @param uniqueName The unique name of the relationship definition
|
||||
* @return Relationship definition for the given unique name or all
|
||||
* relationship definitions if unique name is blank
|
||||
*/
|
||||
private Map<QName, AssociationDefinition> getCustomReferenceDefinitions(String referenceId)
|
||||
private Set<RelationshipDefinition> getRelationshipDefinitons(String uniqueName)
|
||||
{
|
||||
Map<QName, AssociationDefinition> customReferenceDefinitions = new HashMap<QName, AssociationDefinition>();
|
||||
Set<RelationshipDefinition> relationshipDefinitions = new HashSet<RelationshipDefinition>();
|
||||
|
||||
if (StringUtils.isNotBlank(referenceId))
|
||||
if (isBlank(uniqueName))
|
||||
{
|
||||
QName referenceQName = getCustomReferenceQName(referenceId);
|
||||
AssociationDefinition associationDefinition = getAssosiationDefinitionForCustomReference(referenceQName);
|
||||
customReferenceDefinitions.put(referenceQName, associationDefinition);
|
||||
relationshipDefinitions.addAll(getRelationshipService().getRelationshipDefinitions());
|
||||
}
|
||||
else
|
||||
{
|
||||
customReferenceDefinitions.putAll(getRmAdminService().getCustomReferenceDefinitions());
|
||||
RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName);
|
||||
if (relationshipDefinition != null)
|
||||
{
|
||||
relationshipDefinitions.add(relationshipDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
return customReferenceDefinitions;
|
||||
return relationshipDefinitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the association definition for the given reference QName
|
||||
* Creates relationship definition data for the ftl template
|
||||
*
|
||||
* @param referenceQName The reference QName
|
||||
* @return The association definition for the given reference QName
|
||||
* @param relationshipDefinitions The relationship definitions
|
||||
* @return The relationship definition data
|
||||
*/
|
||||
private AssociationDefinition getAssosiationDefinitionForCustomReference(QName referenceQName)
|
||||
private List<Map<String, String>> createRelationshipDefinitionData(Set<RelationshipDefinition> relationshipDefinitions)
|
||||
{
|
||||
AssociationDefinition associationDefinition = getRmAdminService().getCustomReferenceDefinitions().get(referenceQName);
|
||||
if (associationDefinition == null)
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Unable to find association definition for the reference: '");
|
||||
msg.append(referenceQName.getLocalName());
|
||||
msg.append("'.");
|
||||
String errorMsg = msg.toString();
|
||||
List<Map<String, String>> relationshipDefinitionData = new ArrayList<Map<String, String>>();
|
||||
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, errorMsg);
|
||||
}
|
||||
return associationDefinition;
|
||||
}
|
||||
for (RelationshipDefinition relationshipDefinition : relationshipDefinitions)
|
||||
{
|
||||
Map<String, String> data = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Gets the custom reference type from the association definition
|
||||
*
|
||||
* @param associationDefinition The association definition
|
||||
* @return Returns the custom reference type which is either parent/child or bidirectional
|
||||
*/
|
||||
private CustomReferenceType getCustomReferenceType(AssociationDefinition associationDefinition)
|
||||
{
|
||||
CustomReferenceType referenceType;
|
||||
RelationshipType type = relationshipDefinition.getType();
|
||||
RelationshipDisplayName displayName = relationshipDefinition.getDisplayName();
|
||||
|
||||
if (associationDefinition instanceof ChildAssociationDefinition)
|
||||
if (RelationshipType.BIDIRECTIONAL.equals(type))
|
||||
{
|
||||
referenceType = CustomReferenceType.PARENT_CHILD;
|
||||
data.put(LABEL, displayName.getLabelText());
|
||||
}
|
||||
else if (associationDefinition instanceof AssociationDefinition)
|
||||
else if (RelationshipType.PARENTCHILD.equals(type))
|
||||
{
|
||||
referenceType = CustomReferenceType.BIDIRECTIONAL;
|
||||
data.put(SOURCE, displayName.getSourceText());
|
||||
data.put(TARGET, displayName.getTargetText());
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Unsupported association definition: '");
|
||||
msg.append(associationDefinition.getName().getLocalName());
|
||||
msg.append("'.");
|
||||
String errorMsg = msg.toString();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unsupported relationship type '")
|
||||
.append(type)
|
||||
.append("'.");
|
||||
|
||||
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, errorMsg);
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, sb.toString());
|
||||
}
|
||||
|
||||
return referenceType;
|
||||
data.put(REF_ID, relationshipDefinition.getUniqueName());
|
||||
data.put(REFERENCE_TYPE, type.toString().toLowerCase());
|
||||
|
||||
relationshipDefinitionData.add(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom reference data
|
||||
*
|
||||
* @param customReferenceDefinitions The custom reference definitions
|
||||
* @return Custom reference data
|
||||
*/
|
||||
private List<Map<String, String>> getCustomReferenceData(Map<QName, AssociationDefinition> customReferenceDefinitions)
|
||||
{
|
||||
List<Map<String, String>> customReferences = new ArrayList<Map<String, String>>();
|
||||
|
||||
for (Entry<QName, AssociationDefinition> entry : customReferenceDefinitions.entrySet())
|
||||
{
|
||||
Map<String, String> customReference = new HashMap<String, String>();
|
||||
AssociationDefinition associationDefinition = entry.getValue();
|
||||
CustomReferenceType referenceType = getCustomReferenceType(associationDefinition);
|
||||
String title = getAssociationDefinitionTitle(associationDefinition);
|
||||
|
||||
if (CustomReferenceType.PARENT_CHILD.equals(referenceType))
|
||||
{
|
||||
String[] sourceAndTarget = getRmAdminService().splitSourceTargetId(title);
|
||||
customReference.put(SOURCE, sourceAndTarget[0]);
|
||||
customReference.put(TARGET, sourceAndTarget[1]);
|
||||
}
|
||||
else if (CustomReferenceType.BIDIRECTIONAL.equals(referenceType))
|
||||
{
|
||||
customReference.put(LABEL, title);
|
||||
}
|
||||
|
||||
String referenceId = entry.getKey().getLocalName();
|
||||
customReference.put(REF_ID, referenceId);
|
||||
customReference.put(REFERENCE_TYPE, referenceType.toString());
|
||||
|
||||
customReferences.add(customReference);
|
||||
}
|
||||
|
||||
return customReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the association definition title
|
||||
*
|
||||
* @param associationDefinition The association definition
|
||||
* @return The title of the association definition
|
||||
*/
|
||||
private String getAssociationDefinitionTitle(AssociationDefinition associationDefinition)
|
||||
{
|
||||
String title = associationDefinition.getTitle(getDictionaryService());
|
||||
if (StringUtils.isBlank(title))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "Association definition title is blank.");
|
||||
}
|
||||
return title;
|
||||
return relationshipDefinitionData;
|
||||
}
|
||||
}
|
@@ -22,21 +22,22 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipDisplayName;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
@@ -62,38 +63,46 @@ public class CustomRefsGet extends AbstractRmWebScript
|
||||
private static final String NODE_NAME = "nodeName";
|
||||
private static final String NODE_TITLE = "nodeTitle";
|
||||
|
||||
/** RM admin service */
|
||||
private RecordsManagementAdminService rmAdminService;
|
||||
|
||||
/** Dictionary service */
|
||||
private DictionaryService dictionaryService;
|
||||
/** Relationship service */
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
/** Capability service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/**
|
||||
* Sets the RM admin service
|
||||
* @param rmAdminService RM admin service
|
||||
* Gets the relationship service instance
|
||||
*
|
||||
* @return The relationship service instance
|
||||
*/
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
||||
protected RelationshipService getRelationshipService()
|
||||
{
|
||||
this.rmAdminService = rmAdminService;
|
||||
return this.relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dictionary service
|
||||
* Sets the relationship service instance
|
||||
*
|
||||
* @param dictionaryService Dictionary service
|
||||
* @param relationshipService The relationship service instance
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
public void setRelationshipService(RelationshipService relationshipService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
this.relationshipService = relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the capability service
|
||||
* Gets the capability service instance
|
||||
*
|
||||
* @param capabilityService Capability service
|
||||
* @return The capability service instance
|
||||
*/
|
||||
protected CapabilityService getCapabilityService()
|
||||
{
|
||||
return this.capabilityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the capability service instance
|
||||
*
|
||||
* @param capabilityService Capability service instance
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
@@ -101,15 +110,17 @@ public class CustomRefsGet extends AbstractRmWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||
* org.springframework.extensions.webscripts.Status,
|
||||
* org.springframework.extensions.webscripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>(4);
|
||||
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||
model.put(NODE_NAME, nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
|
||||
model.put(NODE_TITLE, nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE));
|
||||
model.put(NODE_NAME, getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME));
|
||||
model.put(NODE_TITLE, getNodeService().getProperty(nodeRef, ContentModel.PROP_TITLE));
|
||||
model.put(CUSTOM_REFS_FROM, getOutwardReferences(nodeRef));
|
||||
model.put(CUSTOM_REFS_TO, getInwardReferenceData(nodeRef));
|
||||
return model;
|
||||
@@ -124,13 +135,8 @@ public class CustomRefsGet extends AbstractRmWebScript
|
||||
private List<Map<String, String>> getOutwardReferences(NodeRef nodeRef)
|
||||
{
|
||||
List<Map<String, String>> outwardReferenceData = new ArrayList<Map<String, String>>();
|
||||
|
||||
List<AssociationRef> assocsFromThisNode = rmAdminService.getCustomReferencesFrom(nodeRef);
|
||||
outwardReferenceData.addAll(getBidirectionalReferenceData(assocsFromThisNode));
|
||||
|
||||
List<ChildAssociationRef> childAssocs = rmAdminService.getCustomChildReferences(nodeRef);
|
||||
outwardReferenceData.addAll(getParentChildReferenceData(childAssocs));
|
||||
|
||||
Set<Relationship> relationships = getRelationshipService().getRelationshipsFrom(nodeRef);
|
||||
outwardReferenceData.addAll(getRelationshipData(relationships));
|
||||
return outwardReferenceData;
|
||||
}
|
||||
|
||||
@@ -143,91 +149,68 @@ public class CustomRefsGet extends AbstractRmWebScript
|
||||
private List<Map<String, String>> getInwardReferenceData(NodeRef nodeRef)
|
||||
{
|
||||
List<Map<String, String>> inwardReferenceData = new ArrayList<Map<String, String>>();
|
||||
|
||||
List<AssociationRef> assocsToThisNode = rmAdminService.getCustomReferencesTo(nodeRef);
|
||||
inwardReferenceData.addAll(getBidirectionalReferenceData(assocsToThisNode));
|
||||
|
||||
List<ChildAssociationRef> parentAssocs = rmAdminService.getCustomParentReferences(nodeRef);
|
||||
inwardReferenceData.addAll(getParentChildReferenceData(parentAssocs));
|
||||
|
||||
Set<Relationship> relationships = getRelationshipService().getRelationshipsTo(nodeRef);
|
||||
inwardReferenceData.addAll(getRelationshipData(relationships));
|
||||
return inwardReferenceData;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method goes through the associationRefs specified and constructs a Map<String, String>
|
||||
* for each assRef. FTL-relevant data are added to that map. The associationRefs must all be
|
||||
* parent/child references.
|
||||
* Creates relationship data for the ftl template
|
||||
*
|
||||
* @param childAssocs Association references
|
||||
* @return The reference data
|
||||
* @param relationships The relationships
|
||||
* @return The relationship data
|
||||
*/
|
||||
private List<Map<String, String>> getParentChildReferenceData(List<ChildAssociationRef> childAssocs)
|
||||
private List<Map<String, String>> getRelationshipData(Set<Relationship> relationships)
|
||||
{
|
||||
List<Map<String, String>> referenceData = new ArrayList<Map<String, String>>();
|
||||
List<Map<String, String>> relationshipData = new ArrayList<Map<String, String>>();
|
||||
|
||||
for (ChildAssociationRef childAssRef : childAssocs)
|
||||
for (Relationship relationship : relationships)
|
||||
{
|
||||
String uniqueName = relationship.getUniqueName();
|
||||
RelationshipDefinition relationshipDefinition = getRelationshipService().getRelationshipDefinition(uniqueName);
|
||||
|
||||
NodeRef source = relationship.getSource();
|
||||
NodeRef target = relationship.getTarget();
|
||||
|
||||
if (relationshipDefinition != null && hasView(source) && hasView(target))
|
||||
{
|
||||
Map<String, String> data = new HashMap<String, String>();
|
||||
|
||||
data.put(CHILD_REF, childAssRef.getChildRef().toString());
|
||||
data.put(PARENT_REF, childAssRef.getParentRef().toString());
|
||||
RelationshipType type = relationshipDefinition.getType();
|
||||
RelationshipDisplayName displayName = relationshipDefinition.getDisplayName();
|
||||
|
||||
QName typeQName = childAssRef.getTypeQName();
|
||||
AssociationDefinition assDef = rmAdminService.getCustomReferenceDefinitions().get(typeQName);
|
||||
|
||||
if (assDef != null &&
|
||||
hasView(childAssRef.getParentRef()) &&
|
||||
hasView(childAssRef.getChildRef()))
|
||||
if (RelationshipType.BIDIRECTIONAL.equals(type))
|
||||
{
|
||||
String compoundTitle = assDef.getTitle(dictionaryService);
|
||||
|
||||
String[] sourceAndTarget = rmAdminService.splitSourceTargetId(compoundTitle);
|
||||
data.put(SOURCE, sourceAndTarget[0]);
|
||||
data.put(TARGET, sourceAndTarget[1]);
|
||||
data.put(REFERENCE_TYPE, CustomReferenceType.PARENT_CHILD.toString());
|
||||
data.put(REF_ID, typeQName.getLocalName());
|
||||
|
||||
referenceData.add(data);
|
||||
data.put(LABEL, displayName.getLabelText());
|
||||
data.put(SOURCE_REF, source.toString());
|
||||
data.put(TARGET_REF, target.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return referenceData;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method goes through the associationRefs specified and constructs a Map<String, String>
|
||||
* for each assRef. FTL-relevant data are added to that map. The associationRefs must all be
|
||||
* bidirectional references.
|
||||
*
|
||||
* @param assocs Association references
|
||||
* @return The reference data
|
||||
*/
|
||||
private List<Map<String, String>> getBidirectionalReferenceData(List<AssociationRef> assocs)
|
||||
else if (RelationshipType.PARENTCHILD.equals(type))
|
||||
{
|
||||
List<Map<String, String>> referenceData = new ArrayList<Map<String, String>>();
|
||||
|
||||
for (AssociationRef assRef : assocs)
|
||||
{
|
||||
Map<String, String> data = new HashMap<String, String>();
|
||||
|
||||
QName typeQName = assRef.getTypeQName();
|
||||
AssociationDefinition assDef = rmAdminService.getCustomReferenceDefinitions().get(typeQName);
|
||||
|
||||
if (assDef != null &&
|
||||
hasView(assRef.getTargetRef()) &&
|
||||
hasView(assRef.getSourceRef()))
|
||||
{
|
||||
data.put(LABEL, assDef.getTitle(dictionaryService));
|
||||
data.put(REF_ID, typeQName.getLocalName());
|
||||
data.put(REFERENCE_TYPE, CustomReferenceType.BIDIRECTIONAL.toString());
|
||||
data.put(SOURCE_REF, assRef.getSourceRef().toString());
|
||||
data.put(TARGET_REF, assRef.getTargetRef().toString());
|
||||
|
||||
referenceData.add(data);
|
||||
data.put(SOURCE, displayName.getSourceText());
|
||||
data.put(TARGET, displayName.getTargetText());
|
||||
data.put(PARENT_REF, source.toString());
|
||||
data.put(CHILD_REF, target.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unsupported relationship type '")
|
||||
.append(type)
|
||||
.append("'.");
|
||||
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, sb.toString());
|
||||
}
|
||||
|
||||
return referenceData;
|
||||
data.put(REFERENCE_TYPE, type.toString().toLowerCase());
|
||||
data.put(REF_ID, uniqueName);
|
||||
|
||||
relationshipData.add(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return relationshipData;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +223,7 @@ public class CustomRefsGet extends AbstractRmWebScript
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
Capability viewRecordCapability = capabilityService.getCapability(ViewRecordsCapability.NAME);
|
||||
Capability viewRecordCapability = getCapabilityService().getCapability(ViewRecordsCapability.NAME);
|
||||
if (AccessStatus.ALLOWED.equals(viewRecordCapability.hasPermission(nodeRef)))
|
||||
{
|
||||
result = true;
|
||||
|
@@ -63,11 +63,11 @@ public class DispositionAbstractBase extends AbstractRmWebScript
|
||||
DispositionSchedule schedule = null;
|
||||
if (inherited)
|
||||
{
|
||||
schedule = this.dispositionService.getDispositionSchedule(nodeRef);
|
||||
schedule = getDispositionService().getDispositionSchedule(nodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
schedule = dispositionService.getAssociatedDispositionSchedule(nodeRef);
|
||||
schedule = getDispositionService().getAssociatedDispositionSchedule(nodeRef);
|
||||
}
|
||||
if (schedule == null)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ public class DispositionAbstractBase extends AbstractRmWebScript
|
||||
|
||||
if (actionDef.getPeriodProperty() != null)
|
||||
{
|
||||
model.put("periodProperty", actionDef.getPeriodProperty().toPrefixString(this.namespaceService));
|
||||
model.put("periodProperty", actionDef.getPeriodProperty().toPrefixString(getNamespaceService()));
|
||||
}
|
||||
|
||||
if (actionDef.getLocation() != null)
|
||||
@@ -181,7 +181,7 @@ public class DispositionAbstractBase extends AbstractRmWebScript
|
||||
scheduleModel.put("nodeRef", schedule.getNodeRef().toString());
|
||||
scheduleModel.put("recordLevelDisposition", schedule.isRecordLevelDisposition());
|
||||
scheduleModel.put("canStepsBeRemoved",
|
||||
!this.dispositionService.hasDisposableItems(schedule));
|
||||
!getDispositionService().hasDisposableItems(schedule));
|
||||
|
||||
if (schedule.getDispositionAuthority() != null)
|
||||
{
|
||||
@@ -200,10 +200,10 @@ public class DispositionAbstractBase extends AbstractRmWebScript
|
||||
for (DispositionActionDefinition actionDef : schedule.getDispositionActionDefinitions())
|
||||
{
|
||||
NodeRef actionDefNodeRef = actionDef.getNodeRef();
|
||||
if (nodeService.hasAspect(actionDefNodeRef, RecordsManagementModel.ASPECT_UNPUBLISHED_UPDATE))
|
||||
if (getNodeService().hasAspect(actionDefNodeRef, RecordsManagementModel.ASPECT_UNPUBLISHED_UPDATE))
|
||||
{
|
||||
unpublishedUpdates = true;
|
||||
publishInProgress = ((Boolean)nodeService.getProperty(actionDefNodeRef, RecordsManagementModel.PROP_PUBLISH_IN_PROGRESS)).booleanValue();
|
||||
publishInProgress = ((Boolean) getNodeService().getProperty(actionDefNodeRef, RecordsManagementModel.PROP_PUBLISH_IN_PROGRESS)).booleanValue();
|
||||
}
|
||||
|
||||
actions.add(createActionDefModel(actionDef, actionsUrl + "/" + actionDef.getId()));
|
||||
|
@@ -67,7 +67,7 @@ public class DispositionActionDefinitionDelete extends DispositionAbstractBase
|
||||
{
|
||||
if (dispositionActionDefinition.getIndex() >= index)
|
||||
{
|
||||
dispositionService.removeDispositionActionDefinition(schedule, dispositionActionDefinition);
|
||||
getDispositionService().removeDispositionActionDefinition(schedule, dispositionActionDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -114,7 +114,7 @@ public class DispositionActionDefinitionPost extends DispositionAbstractBase
|
||||
|
||||
if (json.has("periodProperty"))
|
||||
{
|
||||
QName periodProperty = QName.createQName(json.getString("periodProperty"), this.namespaceService);
|
||||
QName periodProperty = QName.createQName(json.getString("periodProperty"), getNamespaceService());
|
||||
props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty);
|
||||
}
|
||||
|
||||
@@ -154,6 +154,6 @@ public class DispositionActionDefinitionPost extends DispositionAbstractBase
|
||||
}
|
||||
|
||||
// add the action definition to the schedule
|
||||
return this.dispositionService.addDispositionActionDefinition(schedule, props);
|
||||
return getDispositionService().addDispositionActionDefinition(schedule, props);
|
||||
}
|
||||
}
|
@@ -113,7 +113,7 @@ public class DispositionActionDefinitionPut extends DispositionAbstractBase
|
||||
|
||||
if (json.has("periodProperty"))
|
||||
{
|
||||
QName periodProperty = QName.createQName(json.getString("periodProperty"), this.namespaceService);
|
||||
QName periodProperty = QName.createQName(json.getString("periodProperty"), getNamespaceService());
|
||||
props.put(RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY, periodProperty);
|
||||
}
|
||||
|
||||
@@ -153,6 +153,6 @@ public class DispositionActionDefinitionPut extends DispositionAbstractBase
|
||||
}
|
||||
|
||||
// update the action definition
|
||||
return this.dispositionService.updateDispositionActionDefinition(actionDef, props);
|
||||
return getDispositionService().updateDispositionActionDefinition(actionDef, props);
|
||||
}
|
||||
}
|
@@ -63,7 +63,7 @@ public class DispositionLifecycleGet extends DispositionAbstractBase
|
||||
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||
|
||||
// make sure the node passed in has a next action attached
|
||||
DispositionAction nextAction = this.dispositionService.getNextDispositionAction(nodeRef);
|
||||
DispositionAction nextAction = getDispositionService().getNextDispositionAction(nodeRef);
|
||||
if (nextAction == null)
|
||||
{
|
||||
Map<String, Object> nextActionModel = new HashMap<String, Object>(2);
|
||||
@@ -81,7 +81,7 @@ public class DispositionLifecycleGet extends DispositionAbstractBase
|
||||
nextActionModel.put("url", serviceUrl);
|
||||
nextActionModel.put("name", nextAction.getName());
|
||||
nextActionModel.put("label", nextAction.getLabel());
|
||||
nextActionModel.put("eventsEligible", this.dispositionService.isNextDispositionActionEligible(nodeRef));
|
||||
nextActionModel.put("eventsEligible", getDispositionService().isNextDispositionActionEligible(nodeRef));
|
||||
|
||||
if (nextAction.getAsOfDate() != null)
|
||||
{
|
||||
@@ -168,13 +168,13 @@ public class DispositionLifecycleGet extends DispositionAbstractBase
|
||||
NodeRef user = this.personService.getPerson(userName);
|
||||
if (user != null)
|
||||
{
|
||||
String firstName = (String)this.nodeService.getProperty(user, ContentModel.PROP_FIRSTNAME);
|
||||
String firstName = (String) getNodeService().getProperty(user, ContentModel.PROP_FIRSTNAME);
|
||||
if (firstName != null)
|
||||
{
|
||||
model.put(propertyPrefix + "FirstName", firstName);
|
||||
}
|
||||
|
||||
String lastName = (String)this.nodeService.getProperty(user, ContentModel.PROP_LASTNAME);
|
||||
String lastName = (String) getNodeService().getProperty(user, ContentModel.PROP_LASTNAME);
|
||||
if (lastName != null)
|
||||
{
|
||||
model.put(propertyPrefix + "LastName", lastName);
|
||||
|
@@ -85,7 +85,7 @@ public class RecordedVersionConfigGet extends AbstractRmWebScript implements Rec
|
||||
private boolean isVersionPolicySelected(RecordableVersionPolicy recordableVersionPolicy, NodeRef nodeRef)
|
||||
{
|
||||
boolean isVersionPolicySelected = false;
|
||||
String policy = (String) nodeService.getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY);
|
||||
String policy = (String) getNodeService().getProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY);
|
||||
if (StringUtils.isNotBlank(policy))
|
||||
{
|
||||
if (RecordableVersionPolicy.valueOf(policy).equals(recordableVersionPolicy))
|
||||
|
@@ -52,7 +52,7 @@ public class RecordedVersionConfigPost extends AbstractRmWebScript implements Re
|
||||
{
|
||||
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||
RecordableVersionPolicy recordableVersionPolicy = getRecordableVersionPolicy(req);
|
||||
nodeService.setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, recordableVersionPolicy);
|
||||
getNodeService().setProperty(nodeRef, PROP_RECORDABLE_VERSION_POLICY, recordableVersionPolicy);
|
||||
return new HashMap<String, Object>(1);
|
||||
}
|
||||
|
||||
|
@@ -227,7 +227,7 @@ public final class WebScriptUtils
|
||||
checkMandatoryJsonParam(jsonObject, key);
|
||||
}
|
||||
|
||||
String value;
|
||||
String value = null;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -238,9 +238,12 @@ public final class WebScriptUtils
|
||||
}
|
||||
}
|
||||
catch (JSONException error)
|
||||
{
|
||||
if (checkValue)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get value for the key '" + key + "'.", error);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user