when we set custom attribute for stream in web UI. how to get those custom attrbute value in java (in SCM )
I am checking the RTC 6.0.5 feature.When in the Web UI Project Area configuration page, on the left hand navigator, click 'Source Control' --> 'Attribute Definition' and configure custom attribute value for a Stream as below figure.
Now i am trying to get the custom attribute via java code for server side extension(below is plugin code),but I am not able to get custom attribute value, what i set in the UI (mention in above figure).
public void run(final AdvisableOperation operation, final IProcessConfigurationElement participantConfig,
final IParticipantInfoCollector collector, final IProgressMonitor monitor) throws TeamRepositoryException {
try {
Object operationData = operation.getOperationData();
DeliverOperationData deliveryData = null;
IScmDeltaSource scmDeltaSrc = null;
if (operationData instanceof DeliverOperationData) {
deliveryData = (DeliverOperationData) operationData;
}
// Get Service I need
IScmService scmService = getService(IScmService.class);
if (deliveryData != null) {
System.out.println(deliveryData.getSourceWorkspace().getName());
System.out.println(deliveryData.getDestWorkspace().getName());
IWorkspace destWorkspace = deliveryData.getDestWorkspace();
String streamName = destWorkspace.getName();
if (destWorkspace.isStream()) {
System.out.println(streamName);
System.out.println(destWorkspace.isImmutable());
}
// to get the custom attributes of the stream
Map<String, Object> customAttributes = destWorkspace.getCustomAttributes();
Set<String> keySet = customAttributes.keySet();
for (String key : keySet) {
System.out.println(key + ": " + customAttributes.get(key));
}
}
catch (Exception e) {
e.printStackTrace();
collector.addInfo(collector.createExceptionInfo("Exception Occurs in follow-up action: " + e.getMessage(), e));
}
Accepted answer
IGenericAttributes attributesToAdd,
String[] attributesToRemove,
ISynchronizationTimes[] syncTimes,
IRepositoryProgressMonitorHandle monitor)
* Return the defined custom attribute identifiers for the given type in the given project area.
*
* @param projectArea
* The project area. Never {@code null}.
* @param artifactType
* The artifact type. One of:
* <ul>
* <li>{@link CustomAttributeConstants#ARTIFACT_FILE}</li>
* <li>{@link CustomAttributeConstants#ARTIFACT_STREAM}</li>
* <li>{@link CustomAttributeConstants#ARTIFACT_BASELINE}</li>
* <li>{@link CustomAttributeConstants#ARTIFACT_BASELINE_SET}</li>
* <li>{@link CustomAttributeConstants#COMPONENT}</li>
* </ul>
* @param monitor
* A repository progress monitor, may be {@code null} if
* progress reporting and cancellation is not required.
*
* @return the defined attribute identifiers.
*
* @throws TeamRepositoryException
*
* @since 0.11.0.6 (RTC 6.0.6)
*
* @see CustomAttributeConstants
*/
public String[] getDefinedCustomAttributeIdentifiers(
throws TeamRepositoryException;
* Return the defined custom attribute identifiers for the given type in the given project area.
*
* @param projectArea
* The project area. Never {@code null}.
* @param artifactType
* The artifact type. One of:
* <ul>
* <li>{@link CustomAttributeConstants#ARTIFACT_FILE}</li>
* <li>{@link CustomAttributeConstants#ARTIFACT_STREAM}</li>
* <li>{@link CustomAttributeConstants#ARTIFACT_BASELINE}</li>
* <li>{@link CustomAttributeConstants#ARTIFACT_BASELINE_SET}</li>
* <li>{@link CustomAttributeConstants#COMPONENT}</li>
* </ul>
* @param monitor
* A progress monitor, or {@code null} if progress reporting is not desired.
*
* @return the defined attribute identifiers.
*
* @throws TeamRepositoryException
*
* @LongOp This is a long operation; it may block indefinitely; must not be
* called from a responsive thread.
*
* @since 0.11.0.6 (RTC 6.0.6)
*/
public String[] getDefinedCustomAttributeIdentifiers(
throws TeamRepositoryException;
One other answer
I believe that https://rsjazz.wordpress.com/2016/02/04/setting-custom-attributes-for-scm-versionables/ shows the API involved.
Comments
Thank you @Ralph Schoon for information but i just want to know, how i will get those custom attribute for server side. In the below uri its deal with client side
https://jazz.net/forum/questions/217952/how-to-retrieve-the-set-of-allowed-custom-scm-attributes-via-plain-java-client-api