Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The available commands are:
[x]alfDelete.sh
[X]alfDeleteSite.sh
[x]alfDeleteUser.sh
[x]alfDeleteUserFromSite.sh
[x]alfGetCompanyHomeNodeRef.sh
[x]alfGet.sh
[x]alfGetPermissions.sh
Expand All @@ -72,6 +73,7 @@ The available commands are:
[x]alfListGroups.sh
[x]alfListTenants.sh
[x]alfListUsers.sh
[x]alfListUsersSite.sh
[x]alfMetadata.sh
[x]alfMkdir.sh
[x]alfNodeRef2Path.sh
Expand All @@ -83,6 +85,7 @@ The available commands are:
[x]alfSetPermissions.sh
[x]alfUpdateUser.sh
[x]alfUpload.sh
[X]alfWho.sh
```

Note: alfCreateSite.sh alfDeleteSite.sh alfInviteUser.sh are not
Expand Down Expand Up @@ -127,16 +130,21 @@ usage: ./bin/alfSearch.sh [global options] [command specific options] arguments
./alfSearch.sh 'TYPE:myns:mydoctype' | wc -l
--> prints the number of documents of type myns:mydoctype

side note about the Alfresco search and the implications of the various implementations

If Alfresco uses the LUCENE search backend, the result list will not be stable. This is due
to internal performance optimizations done by Alfresco and depends on cache filling levels and
system load. As a result the search will return more results on subsequence executions.

If Alfresco is configured to use the SOLR search backend, the result list will be 'eventual consistent'
This simple means, the Alfresco content is indexed by a background job in an asynchronous manner and
and therefore will not contain all content at any point in time.
However, the result list is stable, taking into account what is indexed so far.
side note about the Alfresco search and the implications of the
various implementations

If Alfresco uses the LUCENE search backend, the result list will
not be stable. This is due to internal performance optimizations
done by Alfresco and depends on cache filling levels and system
load. As a result the search will return more results on
subsequence executions.

If Alfresco is configured to use the SOLR search backend, the
result list will be 'eventual consistent'. This simple means,
the Alfresco content is indexed by a background job in an
asynchronous manner and and therefore will not contain all
content at any point in time. However, the result list is
stable, taking into account what is indexed so far.

the alfresco shell tools are created by
lothar.maerkle@ecm4u.de - http://www.ecm4u.de - http://www.ecm-market.de
Expand Down
86 changes: 61 additions & 25 deletions bin/alfCreateUser.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
#!/bin/bash
# set -x

# Wed Dec 4 10:46:12 CET 2024
# Changes: CSRF
# spd@daphne.cps.unizar.es
# Script to create local users in alfresco.
# Status: Working against alfresco-5.1.e with CSRF protection enabled (default)

# param section

# source function library

ALFTOOLS_BIN=`dirname "$0"`
. $ALFTOOLS_BIN/alfToolsLib.sh



function __show_command_options() {
echo " command options:"
echo " -n Alfresco user name"
echo " -p Users password"
echo " -f Users first name"
echo " -l Users last name"
echo " -e Users email"
echo " -g A group name this user will become a member of. Can occur multiple times"
echo " -n UNAME , user name"
echo " -p PASS , Users password"
echo " -f FIRST_NAME , Users first name"
echo " -l LAST_NAME , Users last name"
echo " -e MAIL , Users e-mail"
echo " -g GROUP , A group name this user will become a member of."
echo " Can occur multiple times"
echo
}


# intended to be replaced in command script
function __show_command_explanation() {
echo " command explanation:"
echo " the alfCreateUser.sh creates a local user in Alfresco. It returns a JSON dump of the newly created user object"
echo " the alfCreateUser.sh creates a local user in Alfresco."
echo " It returns a JSON dump of the newly created user object"
echo
echo " usage examples:"
echo
echo " ./alfCreateUser.sh -n lothar -p pw123 -f Lothar -l Maerkle -e lothar.maerkle@ecm4u.de -g GroupA -g GroupB"
echo " --> creates an account for Lothar Maerkle with email lothar.maerkle@ecm4u.de. The user name will be"
echo " lothar with password pw123 and will become a member of the groups GroupA and GroupB."
echo " ./alfCreateUser.sh \\"
echo " -n lothar -p pw123 \\"
echo " -f Lothar -l Maerkle \\"
echo " -e lothar.maerkle@ecm4u.de \\"
echo " -g GroupA -g GroupB"
echo " --> creates an account for Lothar Maerkle"
echo " with email lothar.maerkle@ecm4u.de."
echo " The user name will be lothar with password"
echo " pw123 and will become a member of the"
echo " groups GroupA and GroupB."
echo
}

ALF_CMD_OPTIONS="${ALF_GLOBAL_OPTIONS}n:p:f:l:e:g:"
ALF_USER_NAME=""
ALF_USERNAME=""
ALF_FIRST_NAME=""
ALF_LAST_NAME=""
ALF_EMAIL=""
Expand All @@ -49,7 +62,7 @@ function __process_cmd_option() {
case $OPTNAME
in
n)
ALF_USER_NAME=$OPTARG;;
ALF_USERNAME=$OPTARG;;
f)
ALF_FIRST_NAME=$OPTARG;;
l)
Expand All @@ -75,13 +88,13 @@ then
echo " user: $ALF_UID"
echo " endpoint: $ALF_EP"
echo " curl opts: $ALF_CURL_OPTS"
echo " user name: $ALF_USER_NAME"
echo " user name: $ALF_USERNAME"
echo " first name: $ALF_FIRST_NAME"
echo " last name: $ALF_LAST_NAME"
echo " email: $ALF_EMAIL"
fi

if [[ "$ALF_USER_NAME" == "" ]]
if [[ "$ALF_USERNAME" == "" ]]
then
echo "an Alfresco user name is required"
exit 1
Expand Down Expand Up @@ -111,22 +124,45 @@ then
exit 1
fi

ALF_JSON=`echo '{"groups":[]}' | $ALF_JSHON -s "$ALF_LAST_NAME" -i lastName -s "$ALF_FIRST_NAME" -i firstName -s "$ALF_USER_NAME" -i userName -s "$ALF_EMAIL" -i email -s "$ALF_PASSWD" -i password -n 'false' -i disableAccount`
#
# First should we tell if this is an existing user
#
ALF_EUSER=`$ALFTOOLS_BIN/alfGetUser.sh ${ALF_USERNAME} 2>/dev/null`

if [ $? -eq 0 ]
then
# Existing user
echo "ERROR: Existing user ${ALF_USERNAME}"
exit 1
fi

ALF_JSON=`echo '{"groups":[]}' |\
$ALF_JSHON \
-s "$ALF_LAST_NAME" -i lastName \
-s "$ALF_FIRST_NAME" -i firstName \
-s "$ALF_USERNAME" -i userName \
-s "$ALF_EMAIL" -i email \
-s "$ALF_PASSWD" -i password \
-n 'false' -i disableAccount`

# set groups if any
for GRP in ${ALF_GROUPS[*]}
do
ALF_AUTHORITY="GROUP_${GRP}"
ALF_JSON=`echo $ALF_JSON | $ALF_JSHON -e groups -s "$ALF_AUTHORITY" -i append -p`
ALF_AUTHORITY="GROUP_${GRP}"
ALF_JSON=`echo $ALF_JSON |\
$ALF_JSHON \
-e groups -s "$ALF_AUTHORITY" -i append -p`
done

#echo $ALF_JSON

echo $ALF_JSON | curl $ALF_CURL_OPTS -u $ALF_UID:$ALF_PW -H 'Content-Type:application/json' -d@- -X POST $ALF_EP/service/api/people
echo $ALF_JSON |\
curl $ALF_CURL_OPTS \
-u $ALF_UID:$ALF_PW \
-H 'Content-Type:application/json' \
-d@- -X POST $ALF_EP/service/api/people


#{"userName":"lodda","password":"test","firstName":"Lothar","lastName":"Märkle","email":"lothar.maerkle@ecm4u.de","disableAccount":false,"quota":-1,"groups":[]}
#
#
#http://localhost:8080/share/proxy/alfresco/api/people
# {"userName":"lodda","password":"test","firstName":"Lothar","lastName":"Maerkle","email":"lothar.maerkle@ecm4u.de","disableAccount":false,"quota":-1,"groups":[]}
# http://localhost:8080/share/proxy/alfresco/api/people

93 changes: 93 additions & 0 deletions bin/alfDeleteUserFromSite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash
#set -x

# Thu May 3 12:41:18 CEST 2018
# spd@daphne.cps.unizar.es
# Delete a user from a given site. Tested only against Alfresco 5.2

# param section

# source function library

ALFTOOLS_BIN=`dirname "$0"`
. $ALFTOOLS_BIN/alfToolsLib.sh

# intended to be replaced in command script by a command specific output
function __show_command_options() {
echo " command options:"
echo " no command specific options"

}

# intended to be replaced in command script
function __show_command_arguments() {
echo " command arguments:"
echo " ALF_USER_ID the unique user name of an Alfresco user. Use - to read the user id from stdin."
echo " SHORT_NAME the sites short name".
}

# intended to be replaced in command script
function __show_command_explanation() {
echo " command explanation:"
echo " the alfDeleteUserFromSite.sh command deletes a user from Alfresco"
echo
echo " usage examples:"
echo
echo " ./alfDeleteUserFromSite.sh someuserid somesite"
echo " --> deletes the user 'someuserid' from 'somesite'"
echo
echo
}


# command local options

__process_options $@

# shift away parsed args
shift $((OPTIND-1))

# command arguments, read first line from stdin if argument is -
ALF_USER_DEL=$1
if [[ "$ALF_USER_DEL" == "-" ]]
then
read line
ALF_USER_DEL=$line
fi

SHORT_NAME=$2
if [[ "_$SHORT_NAME" == "_" ]]
then
__show_command_explanation
exit 1
fi

ALF_SERVER=`echo "$ALF_SHARE_EP" | sed -e 's,/share,,'`
ALF_SITE_SHORT_NAME=$SHORT_NAME

if $ALF_VERBOSE
then
ALF_CURL_OPTS="$ALF_CURL_OPTS -v"
echo "connection params:"
echo " user: $ALF_UID"
echo " endpoint: $ALF_EP"
echo " curl opts: $ALF_CURL_OPTS"
echo " alf user: $ALF_USER_DEL"
fi

if [[ "$ALF_USER_DEL" == "" ]]
then
echo "missing alfresco user id"
exit 1
fi


__encode_url_param $ALF_USER_DEL
ENC_UID=$ENCODED_PARAM

#URL="${ALF_EP}/service/api/people/${ENC_UID}/sites/${SHORT_NAME}"
URL=${ALF_SERVER}/alfresco/api/-default-/public/alfresco/versions/1
URL=${URL}/sites/${SHORT_NAME}/members/${ENC_UID}

curl $ALF_CURL_OPTS -u $ALF_UID:$ALF_PW -X DELETE "$URL"

23 changes: 16 additions & 7 deletions bin/alfGetPermissions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Tue May 23 13:12:49 CEST 2017
# Wed Oct 1 12:45:40 CEST 2025
# spd@daphne.cps.unizar.es

# Script to get permissions for a workspace/SpacesStore node
Expand Down Expand Up @@ -131,16 +131,21 @@ then
#
#ALF_NODE_ID=`alfPath2NodeRef.sh "/app:company_home/st:sites/cm:${ALF_SITE_SHORT_NAME}/cm:documentLibrary/cm:${ALF_FILE_NAME}" | sed -e 's,://,/,'`

ALF_FILE_NAME=`echo "${ALF_FILE_NAME}" | sed -e 's/ /%20/g'`
URL=$ALF_SERVER/alfresco/api/-default-/public/cmis/versions
URL=${URL}/1.1/browser/root/Sites/${ALF_SITE_SHORT_NAME}
URL=${URL}/documentLibrary/${ALF_FILE_NAME}?cmisSelector=object

ALF_NODE_ID=`curl $ALF_CURL_OPTS \
-u"$ALFTOOLS_USER:$ALFTOOLS_PASSWORD" \
"${URL}" | $ALF_JSHON -e properties -e cmis:objectId -e value -u`
if [ "_${ALF_NODE_ID}" = "_" ]
then
echo "## ERROR: \"$ALF_FILE_NAME\" not found" >&2 ; exit
exit 1
fi
ALF_NODE_ID="workspace/SpacesStore/${ALF_NODE_ID}"


else
ALF_NODE_ID="workspace/SpacesStore/${ALF_NODE_ID}"
fi
Expand All @@ -150,6 +155,7 @@ then
echo " node id: $ALF_NODE_ID" >&2
fi


ALF_PATH="alfresco/s/slingshot/doclib/permissions/${ALF_NODE_ID}"


Expand All @@ -158,11 +164,14 @@ OUTPUT=`curl $ALF_CURL_OPTS \
-u"$ALFTOOLS_USER:$ALFTOOLS_PASSWORD" \
$ALF_SERVER/$ALF_PATH`

filter "$OUTPUT"


# on success the server returns json describing permissions

if [ 0 -eq $? ]
then
# on success the server returns json describing permissions
filter "$OUTPUT"
else
echo "## ERROR: $ALF_SERVER/$ALF_PATH" >&2 ; exit
exit 1
fi

exit $?

Loading